ros msgs
ros msgs usually used in C++, as our ADS data tool is implemented in Python, I’d try to build *.msg
to python module. find two blogs from ROS doc:
to build msg into python module, the package.yml
should at least include the following lines:
|
|
the default CMakeList.txt
looks like:
|
|
the generated msg python module is located at ~/catkin_ws/devel/lib/python2.7/dist-packages/my_msg_py/msg
,which can add to $PYTHONPATH
for later usage
create ros node with catkin
first check your $ROS_PAKCAGE_PATH
, the default pkg path is /opt/ros/kinetic/share
, append custom pkgs path from ~/cakin_ws/devel/share
.
|
|
catkin_create_pkg
will create a CMakeList.txt
at pkg level, and a src
folder, where can hold custom nodes definition.
sensor serial data to ros node
sensors(e.g. rtk, imu) to ros is communication from external world to ros sys. Things need to take care: mostly sensor hardware device doesn’t support ROS driver directly, so first need device serial or CAN or Ethernet to get the raw sensor data, and package it as sensor/raw_msg
to publish out; the real ros-defined sensor node, will subscribe sensor/raw_msg
and publish the repackaged sensor/data
to the ros system, (which usually happened in ros callback).
|
|
sensor CAN data to ros node
sensors(such as camera, radar, lidar e.t.c) go to ros sys through Veh CAN Bus. the difference between CAN msg and serial msg is data atomicity. as serial msg is only one variable, which gurantee atomicity in application level; while each CAN frame usually include a few variables, which need custom implement atomicity in application level.
|
|
ros node to external device
another kind of communication, is from ros system to external device/env, such as dSPACE. the external device, if not communication through serial, then usually support Ethernet(udp/tcp), which then need to implement a custom udp/tcp data recv/send func. the ros node subscribe the necessary data, then send it out through udp/tcp.
|
|
xml-rpc && tcpros
the ros sytem has two communication, to register/update ros node, publish/subscribe topics to ros master. this kind of message go through xml-rpc
. after worker nodes registered in master node, the P2P communication can generated, and the data is transfered through tcpros
.
each ros node has a xml-rpc
server, in code, nodeHandler.advertise()
called in publisher/subscriber node, to register their topices to ros master.
once a subscribe node register to master, which topics it subscribed, master returns a URI as response, then the subscriber and publisher can build connection through this URI. when a publish node register to master, master call publisherUpdate()
to notify all subscriber, who subscribe topices from this publisher.
ros visual(rviz)
- how rviz works ?
If you want to create a node providing a set of interactive markers, you need to instantiate an InteractiveMarkerServer object. This will handle the connection to the client (usually RViz) and make sure that all changes you make are being transmitted and that your application is being notified of all the actions the user performs on the interactive markers.
- rviz rosbag
rviz config can customize the rviz display, the default located at ~/.rviz/default.rviz
.
the idea to play rosbag and render in rviz is to define a custom node, to receive the custom pkg_msg
from replayed rosbag, then repckage pkg_msg
as corresponded marker/markerArray
, then publish these msg out, which will be received by rviz
usually we define a custom node to receive replayed topics from rosbag.play()
, and define a callback func to publish its marker objects out.
|
|
ros summary
ros is a very common communciation way and message type in ADS dev, many demo are implemented based on ros, which gives a bunch of ros related tools. in this blog, we review three of them:
- ros based sensor device data collection
- ros rviz
- rosbag.play
which can support a few kinds of applications, e.g. debuging, replay, data collection.