ROS tutorialThis tutorial will try to explain in a simple way how you can manage to have V-REP ROS enabled (by default, the V-REP distribution for Linux should be automatically ROS enabled). First of all you should make sure that you have gone through the official ROS tutorials, at least the beginner section. Then, we assume that you have the latest Ubuntu running, that ROS Fuerte is installed, and that the workspace and package folders are set. Here also refer to the official documentation regarding the ROS installation. The ROS functionality in V-REP is supported via a plugin (libv_repExtRos.so or libv_repExtRos.dylib). The Linux distribution should include that file already compiled. 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 to V-REP 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 yourself. The plugin 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_stacks folder contains 2 stacks: Above stacks should be copied to your ROS_WORKSPACE folder. Make sure to inspect the stack and package dependencies (in the files stack.xml and manifest.xml). Make sure also that ROS is aware of those stacks, i.e. that you can switch to above stack folders with: $ roscd vrep $ roscd rosBubbleRob You might have to run: $ rosstack profile The vrep stack contains two packages: In order to build the vrep_common package, navigate to the vrep_common package folder with: $ roscd vrep_common and type: $ make That's it! Now any other ROS package will be able to use the V-REP services and stream messages by just adding the vrep_common package to its dependencies. Compiling the vrep_plugin is not much more difficult, except that you will have to first create 3 symbolic links: Refer to the instruction "ln -s" for symbolic link creation. Now navigate to the vrep_plugin package folder with: $ roscd vrep_plugin and type: $ make The plugin should have been generated in the vrep_plugin/lib folder. Copy and paste the created plugin to the V-REP installation folder. Make sure that the name is libv_repExtRos.so. The plugin is now ready to be used! Once you have the ROS plugin in place, 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): $ ./vrep.sh 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 'Ros': loading... Plugin 'Ros': load succeeded. Upon succesful ROS plugin load, checking the available nodes gives this: $ rosnode list /rosout /vrep The "/vrep" node is the node that the plugin has spawned. All services should be advertised: $ rosservice list /rosout/get_loggers /rosout/set_logger_level /vrep/get_loggers /vrep/set_logger_level /vrep/simRosAddStatusbarMessage /vrep/simRosAuxiliaryConsoleClose /vrep/simRosAuxiliaryConsoleOpen /vrep/simRosAuxiliaryConsolePrint /vrep/simRosAuxiliaryConsoleShow ... /vrep/simRosStopSimulation /vrep/simRosSynchronous /vrep/simRosSynchronousTrigger /vrep/simRosTransferFile Refer to the full list of services that V-REP supports. Checking the available topics yields this: $ rostopic list /rosout /rosout_agg /vrep/info As you can see, there is a single V-REP topic that is advertised: "info". The info publisher is the only one that is started as soon as the plugin is launched. All other V-REP topic publishers or V-REP topic subscribers have to be individually enabled. This can only happen while a simulation is running. Two equivalent mechanisms are supported for enabling/disabling publishers/subscribers: There are many supported publisher types or subscriber types, and there is no limit in number of activated publishers/subscribers. All enabled publishers and subscribers will be automatically disabled when a simulation ends. Only the info publisher will continue running. Try following example to start a simulation: $ rosservice call /vrep/simRosStartSimulation result: 1 Following command will stop a running simulation: $ rosservice call /vrep/simRosStopSimulation result: 1 Now load the demo scene "rosTopicPublisherAndSubscriber.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 automatically applies the read data to the object/item it refers to (in that case a 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] Make sure to double-click on the script icon next to object "Vision_sensor" in the scene hierarchy: this will open the script. 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:=/vrep/visionSensorData Had you been streaming simpler data, then you could also have visualized it with: $ rostopic echo /vrep/visionSensorData Now stop the simulation and load the demo scene "controlTypeExamples.ttt", and run the simulation. The scene illustrates the 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 ROS: [External client application controlling the red robot via ROS] The child script attached to the red robot, and running in a threaded fashion, is in charge of following: After executing above's steps, the threaded child script ends, but the simulation continues. The client application "rosBubbleRob" is the second stack previously mentioned. It is also located in the programming/ros_stacks folder. The ros_bubble_rob package can be compiled in the same way as the vrep_plugin package. 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! Type following to inspect the data being streamed from/to V-REP: $ rostopic list /rosBubbleRob11808854/wheel /rosBubbleRob11814031/wheel /rosBubbleRob11818573/wheel /rosout /rosout_agg /vrep/info /vrep/proxData11808854 /vrep/proxData11814031 /vrep/proxData11818573 Each instance of the rosBubbleRob client will enable V-REP publishers/subscribers on a different topic name (in above example there are 3 instances of "rosBubbleRob" running at the same time) Make sure to have a look at the rosBubbleRob client code, which contains many explanatory comments. 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 much simpler to use, leightweight, cross-platform, and available for 5 different languages. It can be an interesting alternative to ROS in some cases. |