User Tools

Site Tools


getting_started:tutorials:systemros1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
getting_started:tutorials:systemros1 [2023/02/09 10:35] – [Using ROS2] ursgrafgetting_started:tutorials:systemros1 [2026/04/12 16:01] (current) – [Using ROS2] ursgraf
Line 1: Line 1:
 ====== Control System Talking to ROS ====== ====== Control System Talking to ROS ======
  
-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 ROS tools have changed.+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.
  
 ===== Using ROS1 ===== ===== Using ROS1 =====
Line 16: Line 16:
 Open another shell in the build directory of your EEROS library and run  Open another shell in the build directory of your EEROS library and run 
 <code> <code>
-$ sudo -E ./examples/ros/rosTest1+$ sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./examples/ros/rosTest1
 </code> </code>
 IMPORTANT You have to run a program using real time threads with root privileges.  IMPORTANT You have to run a program using real time threads with root privileges. 
 ==== Publishing ==== ==== Publishing ====
-This example runs your EEROS application as a ROS node under the name ///eerosNode//. It publishes three topics +This example runs your EEROS application as a ROS node under the name ///eerosNode//. It publishes six topics 
-  * /test/vector          (of type Matrix<7,1,double>+  * /test/analogSignal          (of type eeros_msgs/msg/AnalogSignal with a single double value
-  * /test/val             (of type double) +  * /test/analogSignalVector    (of type eeros_msgs/msg/AnalogSignal with a vector of 7 entries of type double
-  * /test/safetyLevel     (of type unit32_t)+  * /test/digitalSignal          (of type eeros_msgs/msg/DigitalSignal with a single bool value) 
 +  * /test/digitalSignalVector    (of type eeros_msgs/msg/DigitalSignal with a vector of 7 entries of type bool
 +  * /test/safetyLevel     (currently active safety level of type std_msgs/msg/String) 
 +  * /test/odom     (odometry data of type nav_msgs/msg/Odometry)
  
 With  With 
Line 33: Line 36:
 $ rostopic list $ rostopic list
 </code> </code>
-will list the two topics which are published be our node, ///test/val//, ///test/vector//, and ///test/safetyLevel//.+will list all the topics which are published be our node.
 Open another shell to show the messages sent by EEROS, e.g. Open another shell to show the messages sent by EEROS, e.g.
 <code> <code>
-$ rostopic echo /test/vector+$ rostopic echo /test/analogSignalVector
 </code> </code>
 With  With 
 <code> <code>
-$ rostopic hz /test/val+$ rostopic hz /test/analogSignalVector
 </code> </code>
 you can easily check how often data is sent from out ROS node. Try to plot the data with you can easily check how often data is sent from out ROS node. Try to plot the data with
 <code> <code>
-$ rqt_plot /test/val /test1/vector/data[0] /test/vector/data[1] /test/safetyLevel+$ rqt_plot /test/analogSignal /test/analogSignalVector/val[0] /test/analogSignalVector/val[1] /test/safetyLevel
 </code> </code>
  
Line 68: Line 71:
 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 [[getting_started:ros_prep|Preparations and Building]].  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 [[getting_started:ros_prep|Preparations and Building]]. 
  
 +Next, you have to run your ROS setup script together with the setup script for your EEROS messages.
 +<code>
 +$ source /opt/ros/<distro-name>/setup.bash
 +$ source <eeros-install-dir>/share/eeros_msgs/local_setup.bash
 +</code>
 If you work on a target make sure to setup the environment as given in [[getting_started:ros_run|]]. If you work on a target make sure to setup the environment as given in [[getting_started:ros_run|]].
  
 Open a shell in the build directory of your EEROS library and run  Open a shell in the build directory of your EEROS library and run 
 <code> <code>
-sudo -E ./examples/ros2/rosTest1+$ ./examples/ros2/rosTest1
 </code> </code>
-IMPORTANT You have to run a program using real time threads with root privileges. +
 ==== Publishing ==== ==== Publishing ====
 This example runs your EEROS application as a ROS node under the name ///eerosNode//. It publishes three topics This example runs your EEROS application as a ROS node under the name ///eerosNode//. It publishes three topics
-  * /test/vector          (of type Matrix<7,1,double>+  * /test/analogSignal          (of type eeros_msgs/msg/AnalogSignal
-  * /test/val             (of type double+  * /test/analogSignalVector    (of type eeros_msgs/msg/AnalogSignal) 
-  * /test/safetyLevel     (of type unit32_t)+  * /test/digitalSignal         (of type eeros_msgs/msg/DigitalSignal) 
 +  * /test/digitalSignalVector   (of type eeros_msgs/msg/DigitalSignal
 +  * /test/safetyLevel           (of type std_msgs/msg/String) 
 +  * /test/odom                  (of type nav_msgs/msg/Odometry) 
 +  * /test/twistStamped          (of type geometry_msgs/msg/TwistStamped)
  
 With  With 
 <code> <code>
-rosnode list+ros2 node list
 </code> </code>
 you will see the new node.  you will see the new node. 
 <code> <code>
-rostopic list+ros2 topic list
 </code> </code>
-will list the two topics which are published be our node, ///test/val//, ///test/vector//, and ///test/safetyLevel//.+will list all the topics which are published be our node.
 Open another shell to show the messages sent by EEROS, e.g. Open another shell to show the messages sent by EEROS, e.g.
 <code> <code>
-rostopic echo /test/vector+ros2 topic echo /test/analogSignalVector
 </code> </code>
 With  With 
 <code> <code>
-rostopic hz /test/val +ros2 topic hz /test/analogSignal
-</code> +
-you can easily check how often data is sent from out ROS node. Try to plot the data with +
-<code> +
-$ rqt_plot /test/val /test1/vector/data[0] /test/vector/data[1] /test/safetyLevel+
 </code> </code>
 +you can easily check how often data is sent from out ROS node. 
  
 ==== Subscribing ==== ==== Subscribing ====
 +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 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
-  * /rosNodeTalker/vector  (of type Matrix<2,1,double>+  * /rosNodeTalker/analogSignal        (of type eeros_msgs/msg/AnalogSignal) 
-  * /rosNodeTalker/val     (of type double+  * /rosNodeTalker/analogSignalVector  (of type eeros_msgs/msg/AnalogSignal
-and logs its transported message values into the console. Alternatively you could publish a single message from the command line with +  * /rosNodeTalker/digitalSignal       (of type eeros_msgs/msg/DigitalSignal) 
 +  * /rosNodeTalker/digitalSignalVector (of type eeros_msgs/msg/DigitalSignal) 
 +  * /rosNodeTalker/twist               (of type geometry_msgs/msg/Twist) 
 + 
 +and logs its transported message values into the console. Alternatively you could publish messages from the command line with 
 <code> <code>
-rostopic pub /rosNodeTalker/val std_msgs/Float64 -- -2.3 +ros2 topic pub /rosNodeTalker/analogSignal    eeros_msgs/msg/AnalogSignal "{timestamp: {sec: 1, nanosec: 1000}, val: [10.5]}" 
-rostopic pub /rosNodeTalker/vector std_msgs/Float64MultiArray "{layout: {dim[]data_offset0}, data: [2.5, 1.76]}"+ros2 topic pub /rosNodeTalker/analogSignalVector  eeros_msgs/msg/AnalogSignal "{timestamp: {sec2nanosec2000}, val: [-1, 0.5]}"
 </code> </code>
  
 Use Use
 <code> <code>
-rqt_graph+rqt
 </code> </code>
-to show a graph with all involved nodes together with their topics.+to show a graph with all involved nodes together with their topics or to plot messages.
  
getting_started/tutorials/systemros1.1675935305.txt.gz · Last modified: by ursgraf