General usage of ROS¶
VEROSIM supports the use of a variety of features inside a model or VEROSIM project, that are provided by ROS. You will therefore learn how to access the interfaces that allow you to access hardware and functions that are defined outside the simulation system.
In order to access ROS nodes on the network your simulation computer is attached to, you will need to make sure to set the
ROS_MASTER_URI environment variable according to the VEROSIM
Getting Started section. This also implies that you will need a
roscore running on one computer that is accessible on your network.
All available ROS functionality comes in the form of extensions that you can attach to the database elements in your model. The following image shows all available ROS extensions that you can place inside your model.
From left to right you will find general extensions that map the ROS Publisher/Subscriber model, a set of classes to access an external MongoDB storage and extensions that are specific to the ReconCell work environment.
The naming scheme follows a simple pattern that helps to identify a ROS extension’s functionality and datatype. All general extensions are in the VSLibROS namespace. That means that you can select every basic ROS extension by searching for that name while adding a new extension.
ROS Subscribers are named VSLibROS::Sub<MsgPackage><MsgType>. The <MsgPackage> defines the ROS package and the <MsgType> the type inside that package that this extension is supposed to receive. Everything that a subscriber receives will be forwarded to the IO-Board. In addition to the ROS Subscriber, VEROSIM also supports ROS Publisher. These extensions follow the same naming scheme, but differ in the first part of the name: VSLibROS::Pub<MsgPackage><MsgType>. Again, data is accessed via the IO Board, but instead of reading values from the network, these extensions are able to push data to other ROS nodes.
Everything related to MongoDB can be found by searching for VSLibROS::MongoDB. A management extension is responsible for the database access and the references (VSLibROS::MongoDBRef) for the conversion between ROS and VEROSIM data types. These ROS extensions come in handy if you want to store data in a central database or to read configuration or calibration data that is accessed by different nodes inside the ReconCell ecosystem.
Using the ROS extensions¶
The following setup will serve well as a general and basic example of extending a robot model with an external datasource. As you can see, the name of the Extension is
SubSensorMsgsJointState. Following the above naming scheme, it is obvious that this extension implements a Subscriber that receives data from the network. The message type is
JointState that is available from the
SensorMsgs package. The screenshot and the name indicates that you can use this extension to handle positional information for robot’s individual joints. An example for a practical application would be to mirror the motion of a physical robot inside the simulation system.
You should notice that there are two widgets in the “Properties Dockwidget” that provide specific information. Firstly, the “All Properties” Widget provides the
ROS Topic and
ROS Namespace properties. These have the same meaning as the topic and namespace in the original ROS context. You need to specify the topic, which is basically just the name of the ROS topic that you want to use.
Likewise, the ROS Namespace corresponds to the namespace in the ROS context.
The “ROS Message Info” shows all available data on the specified topic that is currently available. This inspection tool is used in this case to look into the JointState message during runtime. It is most useful to debug your application and shows the most recent dataset that was pushed to or received from the network.