User Tools

Site Tools


getting_started:tutorials:systemros1

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 Preparations and Building. Open a shell and run

$ roscore

Open another shell in the build directory of your EEROS library and run

$ sudo -E ./examples/ros/rosTest1

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 Preparations and Building.

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

$ rosnode list

you will see the new node.

$ rostopic list

will list the two 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.

$ rostopic echo /test/vector

With

$ rostopic hz /test/val

you can easily check how often data is sent from out ROS node. Try to plot the data with

$ rqt_plot /test/val /test1/vector/data[0] /test/vector/data[1] /test/safetyLevel

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

$ rostopic pub /rosNodeTalker/val std_msgs/Float64 -- -2.3
$ rostopic pub /rosNodeTalker/vector std_msgs/Float64MultiArray "layout:
    dim:
    - label: ''
      size: 0
      stride: 0
    data_offset: 0
  data: [2.5, 1.76]"

Use

$ rqt_graph

to show a graph with all involved nodes together with their topics.

getting_started/tutorials/systemros1.txt · Last modified: 2020/12/03 11:07 by ursgraf