Turtlebot2 used with Wanderer to carry around drinks
Scan_msg classMuch 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
msgto hold the twist message, variables
sect_3, and 3 dictionaries -
dbgmsg- to hold the angular speed, linear speed, and debug message for each possible instance, respectively.
sect_3each represent a specific part of the field of view of the turtlebot (see image below).
Illustration of turtlebot field of view
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_3) the obstacle is located in and changes the value of that section to 1.
movement()takes in the values of
sect_3and 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
sectis 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).
Finally, thesect = 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] rospy.loginfo(self.dbgmsg[sect]) self.pub.publish(self.msg)
reset_sect()function is run to reset the values of
for_callback()takes in a laserscan message and runs both of the above functions.
listener() and call_back functions
listener()function first initializes the node
navigation_sensors, and then creates a subscriber with callback function
call_back()takes a Scan_msg object and passes the laserscan message to the class function
At the start of this program, a Scan_msg object called
listener()is then run, starting the subscriber, which passes a laserscan message to the
call_back()passes the laserscan message to
sort(), which updates variables
sect_3accordingly, 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.
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 wanderer.app 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 wanderer.py program (see below).
<node name="navigation_sensors" pkg ="navigation_sensors" type="wanderer.py" 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.
All source code available at:Wanderer appears on the far right along with the other apps in App Chooser