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 -E ./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.
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
$ sudo -E ./examples/ros2/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 three topics
With
$ ros2 node list
you will see the new node.
$ ros2 topic list
will list the three topics which are published be our node, /test/val, /test/vector, and /test/safetyLevel. Open another shell to show the messages sent by EEROS, e.g.
$ ros2 topic echo /test/vector
With
$ ros2 topic hz /test/val
you can easily check how often data is sent from out ROS node.
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
$ ros2 topic pub /rosNodeTalker/val example_interfaces/msg/Float64 "data: -2.3" $ ros2 topic pub /rosNodeTalker/vector example_interfaces/msg/Float64MultiArray "{layout: {dim: [], data_offset: 0}, data: [2.5, 1.76]}"
Use
$ rqt
to show a graph with all involved nodes together with their topics or to plot messages.