Monday, July 29, 2013

Turtlebot Wanderer

The Wanderer program allows the turtlebot to move around randomly while avoiding any nearby objects.  Using the attached Xbox Kinect, the robot reads its laserscan messages and determines if there are any obstacles closer than 0.6 meters.  If there are none, it moves forward.  If it does detect any obstacles, it rotates away from them and then continues moving forward.

Turtlebot2 used with Wanderer to carry around drinks

Scan_msg class

Much of this program depends on a class called Scan_msg.  At it's initialization, a Scan_msg object creates a publisher, pub, for twist messages, variable msg to hold the twist message, variables sect_1, sect_2, and sect_3, and 3 dictionaries - ang, fwd, and dbgmsg- to hold the angular speed, linear speed, and debug message for each possible instance, respectively.
Variables sect_1, sect_2, and sect_3 each represent a specific part of the field of view of the turtlebot (see image below). 
Illustration of turtlebot field of view
The two main functions of this class are sort() and movement()

sort() takes in a laserscan message and goes through all the ranges read by the robot.  If any of the ranges is less than 0.6 m (an obstacle is detected), it determines which section of the field of view (sect_1, sect_2, or sect_3) the obstacle is located in and changes the value of that  section to 1.   

movement()  takes in the values of sect_1, sect_2, and sect_3 and uses them to determine how to move.  To do this, it creates a number with the values of these 3 variables and assigns that number to the  variable sectsect is then used with the class dictionaries to change the angular and linear velocities  of msg to the proper values and display the correct debug message.  Finally, movement() published this modified twist message (see code below).
sect = int(str(self.sect_1) + str(self.sect_2) + str(self.sect_3))
self.msg.angular.z = self.ang[sect]
self.msg.linear.x = self.fwd[sect]
Finally, the reset_sect() function is run to reset the values of sect_1, sect_2, and sect_3 to 0.   

The function for_callback() takes in a laserscan message and runs both of the above functions. 

listener() and call_back functions
The listener() function first initializes the node navigation_sensors, and then creates a subscriber with callback function call_back()call_back() takes a Scan_msg object and passes the laserscan message to the class function for_callback(). 

At the start of this program, a Scan_msg object called sub_obj is created.  listener() is then run, starting the subscriber, which passes a laserscan message to the call_back() function.  call_back() passes the laserscan message to sub_obj's for_callback() function.  for_callback() first runs sort(), which updates variables sect_1, sect_2, and sect_3 accordingly, then passes these updated variables to movement() which uses them to determine where to go, updates the class twist message, and publishes that message.  This process repeats for each laserscan message. 

App Chooser
Wanderer was also added as an additional feature to  App Chooser (for android).  In order to do this, I wrote files wanderer.launch, wanderer.interface, and and added a wanderer_icon.jpeg (for the icon) in a folder called wanderer_app.  The interface file lists any publishers and subscribers.  In the wanderer app, there were none.  The launch file defines a single node, "navigation_sensors" from the program (see below).
   <node name="navigation_sensors" pkg ="navigation_sensors" type="" cwd="node"/></launch>  

Lastly, the app file defines a few attributes of the app and also gives the package/name of the other files and image.  In order to add this app to App Chooser, I edited the file turtlebot_apps.installed to include the wanderer app.
 Wanderer appears on the far right along with the other apps in App Chooser
All source code available at:

Wednesday, July 24, 2013

ROS Hydro Beta and T-Shirts

Now returning to our regularly scheduled programming.

ROS Hydro Beta 1 is now ready for testing. We also expect to have an ISO for the TurtleBot ready by the end of August.

Limited edition ROS Hydro T-Shirts are also available.