Skip to content

Tutorials: ROS Interface

Maxime Busy edited this page Sep 6, 2019 · 20 revisions

In this tutorial we will detail how to setup the qiBullet ROS wrapper, allowing to connect qiBullet to the ROS framework via a simple Python script. If you are not familiar with the ROS framework, you might want to take a look at some ROS tutorials before reading this one. The ROS wrapper for qiBullet has been tested on ROS Kinetic and ROS Indigo.

Installations

Assuming that you installed qiBullet and ROS, first download the meshes for your robot (the meshes will for instance be used by RViz to display your robot):

# Replace distribution by kinetic or indigo, and robot by pepper or nao
sudo apt-get install ros-distribution-robot-meshes

# For Pepper with ROS kinetic:
sudo apt-get install ros-kinetic-pepper-meshes

You can then create a catkin workspace, and clone the following repositories in the workspace:

  • naoqi_driver: the Protolab team's fork of the naoqi_driver repository
  • naoqi_bridge_msgs: the Protolab team's fork of the naoqi_bridge_msgs repository

Once the repositories are cloned, compile and source your workspace.

Launching the wrapper

Create a Python script, and launch a qiBullet simulation.

import rospy
from qibullet import PepperVirtual
from qibullet import PepperRosWrapper
from qibullet import SimulationManager

if __name__ == "__main__":
    simulation_manager = SimulationManager()
    client = simulation_manager.launchSimulation(gui=True)
    pepper = simulation_manager.spawnPepper(client, spawn_ground_plane=True)

You can then instantiate a PepperRosWrapper object, and use it to launch the ROS wrapper:

wrap = PepperRosWrapper()
wrap.launchWrapper(pepper, "/naoqi_driver")

Notice the "/naoqi_driver" passed as a second argument to the launchWrapper method: this string will be used as a namespace for some of the published and subscribed ROS topics. The topic names should be transparent whether you use qiBullet or naoqi_driver.

For the sake of the tutorial, let's assume that you want to access to the top camera data within the ROS framework:

pepper.subscribeCamera(PepperVirtual.ID_CAMERA_TOP)
rospy.spin()

(As specified in the Virtual Robot section, only one camera can be subscribed at a time, meaning that you cannot retrieve images from 2 different cameras simultaneously)

The data is published on a ROS topic, and the spin method can be called. You can now launch that script from a terminal where you sourced the aforementioned catkin workspace, to launch a simulation interfaced with ROS.