Skip to content

Examples for individual ROS2 functionalities inc. Subscribers, Publishers, Timers, Services, Parameters. ...

Notifications You must be signed in to change notification settings

ctu-mrs/ros2_examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROS2 examples

This example package is meant to explore the possibilities of ROS2 from the point of view of current ROS1 features and how the ROS1 feature translate into the new ROS2 architecture. We investigate the aspects that are currently utilized in MRS UAV System with the intention of a potential future transition.

Meant to be tested on 24.04 - Jazzy

Minimalistic Examples

Everything is a component. We happily nodelet everything in ROS1, so why otherwise?

  • ServiceClientExample - periodically calls a service
    • retreiving result synchronously needs to be done outside of ROS with waiting for the std::future
  • PublisherExample - periodically publishes
  • ServiceServerExample - getting called, ok
  • SubscriberExample - subscribes, ok
  • TimerExample - runs multiple timers in parallel
    • timer callbacks are not executed in parallel even with multi-threaded container (with multi-threaded executor, looks like the same problem can appear even with single-threaded executor) --> timers were constructed as part of mutual exclusive callbackGroup
  • ParamsExample - load params from yaml and launch file
    • param server callback is hooked up
    • custom configs work
  • Tf2BroadcasterExample - publishing transforms, ok
    • no innovation in TF structure form ROS1, still missing the option to have multiple parents
  • Tf2ListenerExample - receiving transforms, lookup table works, ok

Running the examples

  • there are tmux sessions within the example packages

First ROS2 impressions

  • colcon, the build system... is it really the best we have got? I want my catkin back.
    • creates workspace wherever colcon build is called
    • therefore, cannot build in subdirectories
    • no colcon clean, no colcon init
    • overall not much user friendly
    • TODO workspace-wide profiles with custom flags
      • profiles are not supported by colcon yet. See discussion
      • predefining of build setting with custom flags can be done using mixin
        • install: sudo apt install python3-colcon-mixin
        • REPO with readme and mixin examples: repo
        • example of usage: colcon build --mixin rel-with-deb-info
  • Sourcing ROS2 workspace
    • ROS2 sourcing
  source /opt/ros/jazzy/setup.zsh
  source ~/ros2_workspace/install/setup.zsh
  • When ros2 launch fails due to python error (nondescriptive), launch it as ros2 launch -d ...
  • Topic the subscribers and publisher have to have compatible Quality of Service (QoS) settings -- reliable or best effort. For example RViZ is setting different profile (reliable) that is by default (best effort). QoS
  • CMakeLists.txt
    • basics are fine
    • building (and using) custom libraries
    • building standalone executable nodelets
  • [.] Launch files
    • they are in python now
    • remappings
    • passing args
    • TODO passing terminal arguments not working (nonexistant??)
    • TODO connecting to existing component containers (nodelet managers)
    • TODO how to add launch prefix, e.g., gdb
  • Subscribers - work fine, just be aware of difference between CallbackGroupType::Reentrant and CallbackGroupType::MutuallyExclusive (default one).
  • Publishers - works fine, not a big difference from ROS1
  • [o] Service client
    • it is asynchronous only!!!!
    • make a wrapper that will default to synchronous services
  • Service server - works fine
  • Timers - works fine, just be aware of difference between CallbackGroupType::Reentrant and CallbackGroupType::MutuallyExclusive (default one).
  • [O] Parameters
    • basic params work from yaml and launch
    • Beware! loading an empty yaml file causes a long and cryptic error ([ERROR] [launch]: Caught exception in launch (see debug for traceback): 'NoneType' object has no attribute 'items'). Solution: add some unused parameter to the file.
    • Nesting is distinguished by "." in the code (it was "/" in ROS1)
    • overloading multiple configs over each other works, the ones loaded last rule
    • TODO test more complex types: lists, matrices, ...
  • [o] DRS - has a direct implementation in the default parameters
    • callback hooked to the external change of the parameters works
    • validation of the parameters has to be performed in our code -> we will need a custom wrapper for that, otherwise madness madness
    • ROS2 rqt_reconfigure works
  • why is the terminal output monochromatic? I want my colors back...
    • export RCUTILS_COLORIZED_OUTPUT=1
  • ROS Time
    • TODO test duration, rate, sleep, wall time vs. sim time (we need sim time for faster/slower than real time simulations)
      • To be able to listen sim time, parameter use_sime_time=1 has to be set individually for every node. PR
      • While using sim time, the get_clock()->now() clock runs at 10 Hz by default. Need to increase the rate as described here.
  • Transformations
    • TODO
    • I really hope that ROS2 will support more than just the TF tree, e.g., an Acyclic graph. We need more parents for a node to allow a robot to being localized within more coordinated systems at a time.
    • What about relativistic transformations? Meaning the frames could have a velocity and, therefore, we could transform a moving object (a ball) from a moving frame (a drone) to a world frame.
  • [o] Tests
    • unit testing works
    • integration testing works almost like in ROS1, more complex now but also more powerfull
  • Pluginlib
    • TODO
  • Actionlib
    • TODO
  • Lifecycles (new feature)
    • TODO

Messages/Services

  • In order to use the messages generated in the same package we need to use the following CMake code:

    rosidl_target_interfaces(publish_address_book
    ${PROJECT_NAME} "rosidl_typesupport_cpp")

    This finds the relevant generated C++ code from AddressBook.msg and allows your target to link against it.

    You may have noticed that this step was not necessary when the interfaces being used were from a package that was built separately. This CMake code is only required when you want to use interfaces in the same package as the one in which they are used. Source

About

Examples for individual ROS2 functionalities inc. Subscribers, Publishers, Timers, Services, Parameters. ...

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published