DiffBot Messages Package
As mentioned before, the nodes in ROS communicate with each other by publishing messages to topics.
ROS provides the
std_msgs package that includes ROS' common message types to represent primitive data types (see the ROS msg specification for primitive types) and other basic message constructs, such as multiarrays.
Note howerver, the following from the
The types in
std_msgs do not convey semantic meaning about their contents: every message simply has a field called "data".
Therefore, while the messages in this package can be useful for quick prototyping, they are NOT intended for "long-term" usage.
For ease of documentation and collaboration, we recommend that existing messages be used, or new messages created, that provide meaningful field name(s).
Therefore, we create a package that contains message definitions specific to DiffBot.
The following command uses
catkin-tools to create the
1 2 3 4 5 6
The following is based on ROS Tutorials Creating Msg And Srv.
In this tutorial you can find the required configurations for the
Currently there is no encoder message definition in ROS (see the
which is why a dedicated message is created for the encoders. For this, a simple msg description file,
Encoders.msg is created in the
msg/ subdirectory of this
1 2 3 4 5 6 7 8
Having this encoder message description gives semantic meaning to the encoder messages and for example avoids having two separate int32 publishers for each encoder. Combining the encoder message into a single one alleviates additional timing problems.
There exists also the
common_msgs meta package for common, generic robot-specific message types.
common_msgs DiffBot uses for example the
nav_msgs for navigation with the navigation stack. Other relevant message definitions are the
where both are definitions from the
To command a joint velocity for each wheel
diffbot_msgs provides the
This specifies the
Header and a float64 array for the angular wheel joint velocities.
1 2 3 4 5 6
After building the package and its messages using
catkin build let's make sure that ROS can see it using the rosmsg show command.
1 2 3 4 5 6
When using the a ros command such as
rosmsg make use of the Tab key to auto complete the message name.
The generated messages in this packages are used on the Teensy microcontroller, which is using
Integrating these messages requires the following steps.
- Generate rosserial libraries in a temporary folder using the
This will generate all messages for ALL installed packages, but in our case only the
diffbot_msgs package is needed to avoid missing includes.
- Copy the generated
~/Arduino/tmp/diffbot_msgsmessage folder to the
srcfolder of the
rosserialArduino library. When
rosserialwas installed with the Arduino Library Manager, the location is
The new messages, specific to DiffBot, can be used by including the generated header, for example