Skip to content

Example Rover - ROS

Link to module repo: Example Rover - Software


Preparations

There are several steps to make in order to turn your rover software into a ROS node. First of all, you have to compile your EEROS framework with ROS support.

  • Read Preparations and Building EEROS with ROS Support.
  • Insert the line set(USE_ROS2 True) in your top-level CMakeLists.txt file. It will look like
    ...
    set(USE_CAN True)
    set(VERBOSE True)
    set(USE_ROS2 True)
    ...
    
  • For a successful build you have to first source the setup.bash script of your ROS distribution.

EEROS as a ROS Node

Turn your EEROS software into a ROS node. You can then exchange regular messages with other nodes.

flowchart LR
    A[Node 1]
    B[Node 2]
    C[Node ...]
    subgraph D [EEROS Node]
        E@{ img: "https://wiki.eeros.org/_media/getting_started/architecture.png?w=600&h=302&tok=95ea14", pos: "t", h: 200, constraint: "on" }
    end
    A <--> B & D <--> C
    A <--> D
    B <--> C

Additions in main.cpp

Add the following lines to main.cpp

#include <eeros/control/ros2/RosTools.hpp>

RosTools::initRos(argc, argv);
auto node = RosTools::initNode("eerosNode");
if (node != nullptr) log.info() << "ROS node initialized: " << node->get_name();

Additions to your Control System

You may want to publish the safety level together with positional data. Further, instead of receiving a twist message you may receive a twist message from the navigation stack from ROS, see Nav2. Add necessary blocks to your control system, such as:

RosPublisherSafetyLevel slOut(node, "/rover/safetyLevel");
RosPublisherOdometry odom(node, "/rover/odom", "rbf", "of");
RosSubscriberTwist twistIn(node, "/nav2/twist");