Clone wiki

robobo-programming / ros / Using-Robobo-ROS

This wiki moved

Please use the new location: https://github.com/mintforpeople/robobo-programming/wiki


Using Robobo from ROS

Introduction

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:

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

Clone the repository robobo-ros-msgs or directly download the file robobo_msgs-1.2.0.zip and uncompress it. Them, with a ROS workspace already in place, follow these steps:

  1. Copy the 'robobo_msgs' directory, which contains the Robobo messages and services, into the 'src' of your ROS workspace.
  2. At the root directory of your workspace run 'catkin_make install'.
  3. 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()
  1. We import the IRs message necessary to be able to receive IR notifications from Robobo.
  2. We start the ROS node in which we will receive the status messages.
  3. We define a listener that prints each message received by console.
  4. We subscribe to the 'irs' Robobo topic.

The execution of this script has the following output (it is only partially shown):

Demo1.png

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'))
  1. We import the messages needed to execute the ROS services.
  2. We start the ROS node.
  3. We create the proxys to use the Robobo services.
  4. We publish/send some example commands to some of the Robobo services.

Camera

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.

Captura de pantalla de 2017-10-26 12-48-11.png

Captura de pantalla de 2017-10-26 12-48-33.png

Updated