ROS tutorial - Indigo

This tutorial will try to explain in a simple way how you can manage to have V-REP ROS enabled, based on ROS Indigo and Catkin build.

First of all you should make sure that you have gone through the official ROS tutorials, at least the beginner section, and that you have installed the Catkin tools. Then, we assume that you have the latest Ubuntu running, that ROS Indigo is installed, and that the workspace folders are set. Here also refer to the official documentation regarding the ROS installation.

The general ROS functionality in V-REP is supported via the RosInterface ( The Linux distribution should include that file already compiled in V-REP/compiledRosPlugins, but it first needs to be copied to V-REP/, otherwise it won't be loaded. You might however experience plugin load problems, depending on your system specificities: make sure to always inspect the terminal window of V-REP for details about plugin load operations. Plugins are loaded when V-REP is launched. The ROS plugin will only successfully load and initialize if roscore is running at that time (roscore is the ROS master).

If the plugin cannot be loaded, then you should recompile it by yourself. It is open source and can be modified as much as needed in order to support a specific feature or to extend its functionality. The programming/ros_packages folder contains 4 packages:

  • ros_bubble_rob2: this is the package of a very simple robot controller that connects to V-REP via the RosInterface. This node will be in charge of controlling the bright red robot in the demo scene controlTypeExamples.ttt
  • v_repExtRosInterface: this package is the RosInterface that will be compiled to a ".so" file, and that is used by V-REP.
  • vrep_skeleton_msg_and_srv and vrep_plugin_skeleton: those two packages can be used to create your own specific ROS plugin for V-REP (e.g. to support ROS messages for a specific robot).
  • Above packages should be copied to your catkin_ws/src folder. Make sure that ROS is aware of those packages, i.e. that you can switch to above package folders with:

    $ roscd vrep_ros_interface
    $ roscd ros_bubble_rob2
    $ roscd vrep_skeleton_msg_and_srv
    $ roscd vrep_plugin_skeleton

    In order to build the packages, navigate to the catkin_ws folder and type:

    $ export VREP_ROOT=~/path/to/v_rep/folder
    $ catkin build

    That's it! The packages should have been generated and compiled to an executable or library. Copy and paste the created files to the V-REP installation folder. The plugins are now ready to be used!

    Now open a terminal and start the ROS master with:

    $ roscore

    Open another terminal, move to the V-REP installation folder and start V-REP. This is what you should have (or similar):

    $ ./
    License file 'v_rep':
    ---> ok
    Simulator launched.
    Plugin 'BubbleRob': loading...
    Plugin 'BubbleRob': load succeeded.
    Plugin 'K3': loading...
    Plugin 'K3': load succeeded.
    Plugin 'RemoteApi': loading...
    Plugin 'RemoteApi': load succeeded.
    Plugin 'RosInterface': loading...
    Plugin 'RosInterface': load succeeded.

    Upon succesful RosInterface load, checking the available nodes gives this:

    $ rosnode list

    In an empty V-REP scene, select an object, then attach a non-threaded child script to it with [Menu bar --> Add --> Associated child script --> non threaded]. Open the script editor for that script and replace the content with following:

    function subscriber_callback(msg)
        -- This is the subscriber callback function
        simAddStatusbarMessage('subscriber receiver following Float32: '
    function getTransformStamped(objHandle,name,relTo,relToName)
        -- This function retrieves the stamped transform for a specific object
        return {
    if (sim_call_type==sim_childscriptcall_initialization) then
        -- The child script initialization
        -- Check if the required RosInterface is there:
        while moduleName do
            if (moduleName=='RosInterface') then
        -- Prepare the float32 publisher and subscriber (we subscribe to the topic we advertise):
        if rosInterfacePresent then
    if (sim_call_type==sim_childscriptcall_actuation) then
        -- Send an updated simulation time message, and send the transform of the object attached to this script:
        if rosInterfacePresent then
            -- To send several transforms at once, use simExtRosInterface_sendTransforms instead
    if (sim_call_type==sim_childscriptcall_cleanup) then
        -- Following not really needed in a simulation script (i.e. automatically shut down at simulation end):
        if rosInterfacePresent then

    Above script will publish the simulation time, and subscribe to it at the same time. It will also publish the transform of the object the script is attached to. You should be able to see the simulation time topic with:

    $ rostopic list

    To see the message content, you can type:

    $ rostopic echo /simulationTime

    Now load the demo scene "rosInterfaceTopicPublisherAndSubscriber.ttt", and run the simulation. The code in the child script attached to "Vision_sensor" will enable a publisher to stream the vision sensor's image, and also enable a subscriber to listen to that same stream. The subscriber applies the read data to the passive vision sensor, that is only used as a data container. So V-REP is streaming data, while listening to the same data! This is what is happening:

    [Image publisher and image subscriber demo]

    Try experimenting a little bit with the code. You can also visualize the image that V-REP streams with following command:

    $ rosrun image_view image_view image:=/visionSensorData

    Had you been streaming simpler data, then you could also have visualized it with:

    $ rostopic echo /visionSensorData

    Now stop the simulation and load the demo scene controlTypeExamples.ttt, and run the simulation. The scene illustrates the main 5 control methods currently supported in V-REP. The robots are simplistic, and also behaving in a simplistic way for simplification purposes. Run the simulation and focus on the red robot, which is controlled via the RosInterface:

    [External client application controlling the red robot via ROS]

    The child script attached to the red robot, and running in a non-threaded fashion, is in charge of following:

  • determine some object handles (e.g. motor joint handles and proximity sensor handle)
  • verify if the RosInterface is loaded
  • add a banner
  • Launch motor speed subscribers
  • Launch a sensor publisher and a simulation time publisher
  • and finally launch a client application. The application is called with some topic names as arguments, so that it will know which topics to listen to and to subscribe. The client application ("rosBubbleRob2") is then taking over the control of the red robot via ROS.
  • While simulation is running, copy and paste a few times the red robot (well, actually any of the robots!). Notice that every copy is directly operational and independent. This is one of the many strengths of V-REP.

    Now stop the simulation and open a new scene, then drag following model into it: Models/tools/rosInterface helper tool.ttm. This model is constituted by a single customization script that offers following topic publishers and subscribers:

  • startSimulation topic: can be used to start a simulation by publishing on this topic a std_msgs::Bool message.
  • pauseSimulation topic: can be used to pause a simulation by publishing on this topic a std_msgs::Bool message.
  • stopSimulation topic: can be used to stop a simulation by publishing on this topic a std_msgs::Bool message.
  • enableSyncMode topic: by publishing a std_msgs::Bool message on this topic, you can enable/disable the synchronous simulation mode.
  • triggerNextStep topic: by publishing a std_msgs::Bool message on this topic, you can trigger the next simulation step, while in the synchronous simulation mode.
  • simulationStepDone topic: a message of type std_msgs::Bool will be published at the end of each simulation pass.
  • simulationState topic: messages of type std_msgs::Int32 will be published on a regular basis. 0 indicates that the simulation is stopped, 1 that it is running and 2 that it is paused.
  • simulationTime topic: messages of type std_msgs::Float32 will be published on a regular basis, indicating the current simulation time.
  • Have a look at the content of the customization script, that can be fully customized for various purposes. Try generating topic messages from the command line, for instance:

    $ rostopic pub /startSimulation std_msgs/Bool true --once
    $ rostopic pub /pauseSimulation std_msgs/Bool true --once
    $ rostopic pub /stopSimulation std_msgs/Bool true --once
    $ rostopic pub /enableSyncMode std_msgs/Bool true --once
    $ rostopic pub /startSimulation std_msgs/Bool true --once
    $ rostopic pub /triggerNextStep std_msgs/Bool true --once
    $ rostopic pub /triggerNextStep std_msgs/Bool true --once
    $ rostopic pub /triggerNextStep std_msgs/Bool true --once
    $ rostopic pub /stopSimulation std_msgs/Bool true --once

    In order to display the current simulation time, you could type:

    $ rostopic echo /simulationTime

    Finally, make sure to have a look at the remote API functionality in V-REP: similarly to ROS, it allows for remote function execution, fast data streaming back and forth, is quite simple to use, leightweight, cross-platform, and available for 7 different languages. It can be an interesting alternative to ROS in some cases.