EEROS can work with ROS1 or ROS2. However, you have to make sure, that you compile EEROS with support for the right version of ROS. Further, the naming and use of the tools in ROS1 and ROS2 have slightly changed.
In the EEROS library you will find a directory with examples. For this example see RosTest1.cpp.
Open a shell in the build directory of your EEROS library. This examples with ROS will only be present in your build directory if ROS was installed before building EEROS with -DUSE_ROS=TRUE set, see Preparations and Building.
If you work on a target make sure to setup the environment as given in Running your ROS Example.
Open a shell and run
$ roscore
Open another shell in the build directory of your EEROS library and run
$ sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./examples/ros/rosTest1
You have to run a program using real time threads with root privileges.
This example runs your EEROS application as a ROS node under the name /eerosNode. It publishes six topics
With
$ rosnode list
you will see the new node.
$ rostopic list
will list all the topics which are published be our node. Open another shell to show the messages sent by EEROS, e.g.
$ rostopic echo /test/analogSignalVector
With
$ rostopic hz /test/analogSignalVector
you can easily check how often data is sent from out ROS node. Try to plot the data with
$ rqt_plot /test/analogSignal /test/analogSignalVector/val[0] /test/analogSignalVector/val[1] /test/safetyLevel
Open another shell in the build directory of your EEROS library and run rosNodeTalker. This is not a EEROS program but simply starts a ROS node which publishes a couple of test topics. As soon as rosNodeTalker runs, your example application will receive the two topics
and logs its transported message values into the console. Alternatively you could publish a single message from the command line with
$ rostopic pub /rosNodeTalker/val std_msgs/Float64 -- -2.3
$ rostopic pub /rosNodeTalker/vector std_msgs/Float64MultiArray "{layout: {dim: [], data_offset: 0}, data: [2.5, 1.76]}"
Use
$ rqt_graph
to show a graph with all involved nodes together with their topics.
In the EEROS library you will find a directory with examples. For this example see RosTest1.cpp.
Open a shell in the build directory of your EEROS library. This examples with ROS2 will only be present in your build directory if ROS2 was installed before building EEROS with -DUSE_ROS2=TRUE set, see Preparations and Building.
Next, you have to run your ROS setup script together with the setup script for your EEROS messages.
$ source /opt/ros/<distro-name>/setup.bash $ source <eeros-install-dir>/share/eeros_msgs/local_setup.bash
If you work on a target make sure to setup the environment as given in Running your ROS Example.
Open a shell in the build directory of your EEROS library and run
$ ./examples/ros2/rosTest1
This example runs your EEROS application as a ROS node under the name /eerosNode. It publishes three topics
With
$ ros2 node list
you will see the new node.
$ ros2 topic list
will list all the topics which are published be our node. Open another shell to show the messages sent by EEROS, e.g.
$ ros2 topic echo /test/analogSignalVector
With
$ ros2 topic hz /test/analogSignal
you can easily check how often data is sent from out ROS node.
The topic /test/twistStamped is published by our node and received at the same time. You should be able to observe the values in the log.
Open another shell in the build directory of your EEROS library and run rosNodeTalker. This is not a EEROS program but simply starts a ROS node which publishes a couple of test topics. As soon as rosNodeTalker runs, your example application will receive the two topics
and logs its transported message values into the console. Alternatively you could publish messages from the command line with
$ ros2 topic pub /rosNodeTalker/analogSignal eeros_msgs/msg/AnalogSignal "{timestamp: {sec: 1, nanosec: 1000}, val: [10.5]}"
$ ros2 topic pub /rosNodeTalker/analogSignalVector eeros_msgs/msg/AnalogSignal "{timestamp: {sec: 2, nanosec: 2000}, val: [-1, 0.5]}"
Use
$ rqt
to show a graph with all involved nodes together with their topics or to plot messages.