Skip to content

Using Robobo ROS

Tami-32 edited this page Jul 28, 2021 · 9 revisions

Configuration

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:

These 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.3.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. Download the open CV dependencies in the “src” folder: git clone https://github.com/ros-perception/opencv_apps
  3. At the root directory of your workspace run 'catkin_make install'.
  4. 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.

Setting a connection with the Robobo ROS master

As mentioned, the application creates its own a ROS master in the smartphone. If you want to use it, the ROS nodes must use the smartphone's IP address as ROS Master URI.

  • For example, if the smartphone's IP address is 192.168.0.18, the environment variable: ROS_MASTER_URI must be set with the value http://192.168.0.18:11311.

  • The application uses the port 11311, the same port used by ROS by default. Then:

    export ROS_MASTER_URI=http://192.168.0.18:11311/

Once the ROS_MASTER_URI is set, we can already communicate with the master and see the different topics and services available in Robobo with: rostopic list rosservice list

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 the console.
  4. 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'))
  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 image 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 to process or view them in applications such as *rqt_image_view* or *rviz*.

Clone this wiki locally