This wiki moved
Please use the new location: https://github.com/mintforpeople/robobo-programming/wiki
Using Robobo from ROS
As explained briefly in the previous section, the application Robobo Developer contains an implementation of the Robobo remote control system, implemented in Java + Rosjava, that connects the remote control system with a ROS Master, thus converting the Robobo into a 'node' that other ROS 'nodes' can use.
To achieve this, the Robobo Developer application, after having created its own ROS Master, or having connected to an existing one, will create the following ROS elements:
- A set of topics where Robobo publishes notifications of changes in the values of its sensors and other functionalities. More information at Documentation of Robobo Sensor Topics.
- A set of services that allow any ROS node to command/actuate the robot. More information at Documentaton of Robobo Services.
This topics and services use a combination of custom and standard ROS message types, thus in order for other ROS nodes to use Robobo, it is required for them to know and use Robobo's own messages and services package.
Installation of 'robobo_msgs' the Robobo message package for ROS
- Copy the 'robobo_msgs' directory, which contains the Robobo messages and services, into the 'src' of your ROS workspace.
- At the root directory of your workspace run 'catkin_make install'.
- And finally run 'source devel/setup.bash'.
After executing these steps you will have installed the required message types, and thus you should be able to use 'rostopic' and 'rossservice' commands to explore and play with the Robobo topics and services.
Example of how to use Robobo with Python
Once you have imported the Robobo message package into your workspace, you just need to create a ROS application in Python to send commands and receive status messages from the base.
Receiving Status Updates
The following code shows how to receive status messages from the infrared sensors of Robobo:
#!/usr/bin/env python import rospy from robobo_msgs.msg import IRs rospy.init_node("robobo__demo") def listener(info): print 'Info: ', info sub=rospy.Subscriber("/robot/irs", IRs, listener) rospy.spin()
- We import the IRs message necessary to be able to receive IR notifications from Robobo.
- We start the ROS node in which we will receive the status messages.
- We define a listener that prints each message received by console.
- We subscribe to the 'irs' Robobo topic.
The execution of this script has the following output (it is only partially shown):
Send commands to Robobo
The following piece of code is an example of how to send a command to Robobo using ROS, that is, how to use the ROS services:
#!/usr/bin/env python import rospy from std_msgs.msg import String, Int8, Int16, Int32 from robobo_msgs.srv import MoveWheels, SetEmotion, Talk rospy.init_node("robobo__demo") robobo_move_srv = rospy.ServiceProxy('robot/moveWheels', MoveWheels) robobo_emotion_srv = rospy.ServiceProxy('robot/setEmotion', SetEmotion) robobo_talk_srv = rospy.ServiceProxy('robot/talk', Talk) robobo_emotion_srv(String('sad')) robobo_move_srv(Int8(20), Int8(-20), Int32(2000), Int16(0)) robobo_talk_srv(String('Hi, my name is Robobo')) rospy.sleep(1) robobo_move_srv(Int8(-20), Int8(20), Int32(2000), Int16(0)) robobo_emotion_srv(String('happy'))
- We import the messages needed to execute the ROS services.
- We start the ROS node.
- We create the proxys to use the Robobo services.
- We publish/send some example commands to some of the Robobo services.
The application also supports the images publication from the smartphone front camera in a ROS topic. The images are published in the topic /robot/camera/image/compressed and the compressed_image_transport is the transport method. Users can employ these images for processing or to view them in applications such as rqt_image_view or rviz.