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 [2020/12/03 10:36] – [Control System Talking to ROS] ursgrafgetting_started:tutorials:systemros1 [2023/02/27 14:00] (current) – [Subscribing] ursgraf
Line 1: Line 1:
 ====== Control System Talking to ROS ====== ====== Control System Talking to ROS ======
-In the EEROS library you will find a directory with examples. 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 [[getting_started:ros#Preparations_and_Building|Preparations and Building]]. Open a shell and run + 
 +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 ===== 
 +In the EEROS library you will find a directory with examples. For this example see [[https://github.com/eeros-project/eeros-framework/blob/master/examples/ros/RosTest1.cpp|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 [[getting_started:ros_prep|Preparations and Building]].  
 + 
 +If you work on a target make sure to setup the environment as given in [[getting_started:ros_run|]]. 
 + 
 +Open a shell and run 
 <code> <code>
 $ roscore $ roscore
Line 8: Line 18:
 $ sudo -E ./examples/ros/rosTest1 $ sudo -E ./examples/ros/rosTest1
 </code> </code>
-IMPORTANT You have to run a program using real time threads with root privileges. Also make sure to have run the ''setup.bash'' script of ROS in your shell as described in [[getting_started:ros#Preparations_and_Building|Preparations and Building]].+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
Line 23: Line 33:
 $ 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 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. Open another shell to show the messages sent by EEROS, e.g.
 <code> <code>
Line 41: Line 51:
   * /rosNodeTalker/vector  (of type Matrix<2,1,double>)   * /rosNodeTalker/vector  (of type Matrix<2,1,double>)
   * /rosNodeTalker/val     (of type double)   * /rosNodeTalker/val     (of type double)
-and logs its transported message values into the console. Use+and logs its transported message values into the console. Alternatively you could publish a single message from the command line with  
 +<code> 
 +$ 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]}" 
 +</code> 
 + 
 +Use
 <code> <code>
 $ rqt_graph $ rqt_graph
 </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.
 +
 +===== Using ROS2 =====
 +In the EEROS library you will find a directory with examples. For this example see [[https://github.com/eeros-project/eeros-framework/blob/master/examples/ros2/RosTest1.cpp|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 [[getting_started:ros_prep|Preparations and Building]]. 
 +
 +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 
 +<code>
 +$ sudo -E ./examples/ros2/rosTest1
 +</code>
 +IMPORTANT You have to run a program using real time threads with root privileges. 
 +==== Publishing ====
 +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/val             (of type double)
 +  * /test/safetyLevel     (of type unit32_t)
 +
 +With 
 +<code>
 +$ ros2 node list
 +</code>
 +you will see the new node. 
 +<code>
 +$ ros2 topic list
 +</code>
 +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.
 +<code>
 +$ ros2 topic echo /test/vector
 +</code>
 +With 
 +<code>
 +$ ros2 topic hz /test/val
 +</code>
 +you can easily check how often data is sent from out ROS node. 
 +
 +==== Subscribing ====
 +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/val     (of type double)
 +and logs its transported message values into the console. Alternatively you could publish a single message from the command line with 
 +<code>
 +$ ros2 topic pub /rosNodeTalker/val std_msgs/msg/Float64 "data: -2.3"
 +$ ros2 topic pub /rosNodeTalker/vector std_msgs/msg/Float64MultiArray "{layout: {dim: [], data_offset: 0}, data: [2.5, 1.76]}"
 +</code>
 +
 +Use
 +<code>
 +$ rqt
 +</code>
 +to show a graph with all involved nodes together with their topics or to plot messages.
  
getting_started/tutorials/systemros1.1606988212.txt.gz · Last modified: 2020/12/03 10:36 by ursgraf