Mastering ROS for Robotics Programming(Second Edition)
上QQ阅读APP看书,第一时间看更新

Understanding the vrep_plugin

The vrep_plugin is part of the V-REP API framework. Even though the plugin is correctly installed in your system, the load operation will fail if the roscore was not running at that time. A pop-up error will inform users if the simulations scenes need the vrep_plugin because the roscore was not running before running the simulator, or it is not installed in the system:

Figure 5: Error displayed when vrep_plugin is used without running the roscore

After starting up V-REP with the vrep_plugin correctly loaded, V-REP will act as a ROS node called /vrep. This can be shown using the following command:

    $ rosnode list  
Figure 6: List of active ROS nodes after running V-REP with vrep_plugin

Other ROS nodes can communicate with V-REP in the following ways:

  • vrep_plugin offers ROS services. Different services are available after launching V-REP to control the simulation scene or its state.
  • vrep_plugin can be enabled to subscribe or advertise topics. As a normal ROS node, simulation models can communicate via topics.

We can start interacting with V-REP using services. Let's create a ROS package with the following dependencies:

$ catkin_create_pkg vrep_demo_pkg roscpp vrep_common std_msgs geometry_msgs  

Alternatively, it is possible to clone the entire package from the following GitHub repository or get the entire package from the book's source code:

$ git clone https://github.com/jocacace/vrep_demo_pkg.git