vrep_ros_plugin Documentation

vrep_ros_plugin

The vrep_ros_plugin package

The Ros V-Rep Plugin

Introduction

ROS V-Rep Bridge is a plugin for V-Rep developed by the Inria Lagadic team located at Inria Rennes.

The main application of the plugin is to provide a communication interface between V-Rep and (ROS). The aim is to control the V-Rep simulation externally using ROS messages and ROS services.

V-Rep is a General purpose 3D robot simulator with integrated development environment developed by Coppelia Robotics. Sensors, mechanisms, robots and whole systems can be modelled and simulated in various ways

How it works

A plugin is a shared library that is automatically loaded by V-REP's main client application at program start-up. It searches objects in the scene that it knows how to manage. It creates ROS publishers to send information about the simulation (for example pose and velocity of object present in the scene) and it receives messages the outside (subscribers).

How the plugin find the object in the scene? In V-Rep it is possible to add tag to the objects with an ID. In access.h we define a list of ID that correspond to our objects. The plugin looks for objects with a known ID and when it finds them, it creates a handler to manage them. We will use this method also to pass to the plugin some custom data ( for example the frequency of the vision sensor ).

The Plugin has the following handlers:

Robots: Manipulator Quadrotor Sensors: Vision sensor IMU sensor and this is the list of the handler to control and describe the simulation:

Rigid body handler: Pose: Set pose Get pose Twist: Set Twist

Ros V-Rep Plugin used the pluginlib package pluginlib package . Pluginlib is a C++ library for loading and unloading plugins from within a ROS package. Plugins are dynamically loadable classes that are loaded from a runtime library (i.e. shared object, dynamically linked library). In this way ours handler are actually plugins with some dependencies. Ifwe don't need an handler or we don't have installed its dependencies we are still able to build our plugin ( this plugin will not be avaible). For example, the Quadrotor_Tel handler needs Telekyb, if we don't want to install Telekyb we can just add a file called CATKIN_IGNORE in the handler folder and it will not be considered. In spite of this the others handler will be avaible.

Manipulator

The Manipulator handler searches a manipulator and it finds all its joints. After which it creates a ROS publisher JointStatus:

In addition it gives us the possibility to control the joints using commands from ROS in serveral ways:

Quadrotor handler

Publisher:

Subscriber:

Custom Data:

IMU

In V-Rep exist a sensor for the IMU that simulate a real one with a mass and a force sensor. The resul of the acceleration was a little bit noisy so a low-pass filter is applied.

Publisher:

Custom Data:

Vision Sensor

The quadrotor is equipped with a camera on the bottom. In V-Rep after a double-click on the Vision-Sensor, we can set some parameters like the resolution and the field of view of the camera. In addition we added a GUI to set the frequency of acquisition and if the camera is RGB or grayscale.

Publisher:

Custom Data:

Pose Handler

When we tag an object of the scene with the pose Handler a publisher is created with the name of the object. It will publish its pose.

Publisher:

Custom Data:

Twist Handler

When we tag an object of the scene with the twist Handler a publisher is created with the name of the object. It will publish its twist (angular and linear velocity).

Publisher:

Installation

Note: The Ubuntu version used is 13.04.

  1. Install ROS Hydro
  2. Install V-Rep
  3. Install Plugin
  4. Install external packages:
    1. Quadrotor plugin: Install Telekyb

Installation ROS Hydro

Follow instructions you find in this page.

Installation V-Rep

Installation Plugin

Install external packages

Installation Telekyb

Note for the simulation

NOTE: Use ODE as physics engine. Bullet stops after some time or if you create a new subscriber.

To simulate multiple quadrotor in real time at a frequency of 500Hz

  1. Go to Simulation -> Simulation settings
  2. In Main settings select "dt=XX ms (custom)"
  3. Set "Time step" to 0.002 (500Hz)
  4. Get "Simulation passes per frame (ppf)" to 50 (10fps). Note: the rendering will actually go faster than this (~ 15fps)
  5. In Main settings select any other item
  6. In Main settings select "dt=2.0 ms (custom)" again.

Note: 5) and 6) are necessary to actually save the setting but they might fix this in future vrep releases.

How to create a new handler

To create a new handler:

  1. Create in the file include/access.h a new define for the object header number in order to connect our object (in the simulation) with the handler in our program. (See point 5) to set the number in the custom data of the object directly in the simulation)
  2. Now we have to create the class that will manage our object. We can use one esisting handler as template and modify it. Copy and paste in the same folder the files *Handler.h and *Handler.cpp from /include and /src, and renominate them (let's say _Test_Handler.h and _Test_Handler.cpp).
  3. Open the file _Test_Handler.h:
    1. Change the token of the #ifndef
    2. Change the name of the class and the name of the constructor and destructor
    3. In the class define member or function we need (Publisher and/or subscriber of ROS, frequency of the publisher ect.)
  4. Open the file _Test_Handler.cpp:
    1. Change the #include with the right name
    2. Replace class and function names
    3. Initialize properly the members of the class in the constructor and replace the old ones in the code
    4. Replace old header with the new one (*_DATA_MAIN)
    5. The handleSimulation() is called at each step of the simulation. Here you can publish and receive the command via ROS
  5. Open " GenericObjectContainer.cpp ":
    1. Add a new elseif with the right parameters (--> *_DATA_MAIN in the first line and --> new *Handler() when we create the object )
    2. Add #include "_Test_Handler.h"
  6. Open src/CMakeLists.txt :
    1. Add _Test_Handler.cpp in set(...)
  7. Add custom data to the object:
    1. [Menu bar --> Tools --> Scene object properties]. You can also open the dialog with a double-click on an object icon in the scene hierarchy.
    2. Click on "Common" and "View/Edit custom data"
    3. In the command line you can write your data. Add: allows adding simple custom data to an object. The data to be added should be written in the command line in following format: header number, data1ID, data1Length, data1. Numbers written without '.' are assumed to be integers, otherwise they are assumed to be floating-point numbers. Numbers are added to the custom data buffer for the given header number in a little-endian fashion. The header number of lagadic is 769710397, for the header number ID you have to put the same one that you used at pount 1). An example: 769710397,500,4,0.

How to create a new handler (Example)

This section will show how to to create a new handler "SetObjTwist" starting from one already existed (TwistObjHandler).

  1. Create in the file include/access.h a new define for the object header number in order to connect our object (in the simulation) with the handler in our program. (See point 5) to set the number in the custom data of the object directly in the simulation).
        /The main identifier of a Set Twist object.
        const static unsigned int SET_OBJ_TWIST_DATA_MAIN=550;
    
  2. Open the file src/include.cpp. Now we link a new Custom Lua Variable with the identifier we created in the previous step:
     // Set Object twist defines
        simRegisterCustomLuaVariable("sim_ext_ros_bridge_set_obj_twist_data_main", (boost::lexical_cast<std::string>(int(SET_OBJ_TWIST_DATA_MAIN))).c_str());
    
  3. Now we have to create the class that will receive the velocity from ROS and will set it to the object. Copy and paste in the same folder the files TwistObjHandler.h and TwistObjHandler.cpp from /include/ObjectHandlers and /src/ObjectHandlers, and renominate them (let's say SetTwistObjHandler.h and SetTwistObjHandler.cpp).
  4. Open the file SetTwistObjHandler.h:
    1. Change the token of the # ifndef
    2. Change the name of the class and the name of the constructor and destructor
    3. In the class define member or function we need (Publisher and/or subscriber of ROS, frequency of the publisher ect.)
  5. Open the file _Test_Handler.cpp:
    1. Change the #include with the right name #include "ObjectHandlers/SetTwistObjHandler.h"
    2. Replace class and function names
    3. Initialize properly the members of the class in the constructor and replace the old ones in the code
    4. Replace old header (OBJ_TWIST_DATA_MAIN) with the new one (SET_OBJ_TWIST_DATA_MAIN)
    5. The handleSimulation() is called at each step of the simulation. Here you can publish and receive the command via ROS
  6. Open " GenericObjectContainer.cpp ":
    1. Add a new elseif with the right parameters (--> *_DATA_MAIN in the first line and --> new *Handler() when we create the object )
       else if ((objectFound = CAccess::extractSerializationData(developerCustomData, CustomDataHeaders::SET_OBJ_TWIST_DATA_MAIN, tempMainData)) == true) {
      // Yes, the tag is there. We have to add a new GenericObjectHandler object associated with this scene object:
      objectHandler = new SetObjTwistHandler();
      ss << "Found 'Set Object twist'. " << std::endl;
      
    2. Add at the beginning:
      #include "ObjectHandlers/SetTwistObjHandler.h"
      
  7. Open src/CMakeLists.txt :
    1. Add "ObjectHandlers/SetTwistObjHandler.cpp" in set(...)
  8. Add custom data to the object (Read here):


vrep_ros_plugin
Author(s): Riccardo Spica , Giovanni Claudio
autogenerated on Mon Apr 3 2017 04:03:39