ROS2 - yszheda/wiki GitHub Wiki

Example Projects

Installation

Performance

intra-process communication

DDS

Design

Executor

Fast RTPS

Intra-process delivery

XRCE-DDS

discovery

OpenDDS

QUIC

iceoryx

crash when sending big message

remote node discovery

QoS

serialization

idl msgs

// Current way
int16 FOO=0
int16 BAR=1
int16 value

// Proposed way
enum foo_bar { FOO, BAR }

Time

UUID

type conversion

cv_bridge

point cloud


ROS2 parameters

All parameters are dynamically reconfigurable, and built off of ROS 2 services.


colcon

python dependencies

ament

Cmake option

colcon build --cmake-args -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON --packages-select <package>

gdb

ros2 run --prefix 'gdb -ex run --args' package_name executable_name

launch

on_exit

node arguments

parameters

environment

respawn

emulate_tty

ComposableNode

def generate_launch_description():
    """Generate launch description with multiple components."""
    container = ComposableNodeContainer(
            node_name='my_container',
            node_namespace='',
            package='rclcpp_components',
            node_executable='component_container',
            composable_node_descriptions=[
                ComposableNode(
                    package='composition',
                    node_plugin='composition::Talker',
                    node_name='talker',
                    extra_arguments=[{'use_intra_process_comms': True}]),
                ComposableNode(
                    package='composition',
                    node_plugin='composition::Listener',
                    node_name='listener',
                    extra_arguments=[{'use_intra_process_comms': True}])
            ],
            output='screen',
    )

cannot pass parameter file?

LifecycleNode

launch.conditions

IncludeLaunchDescription

DeclareLaunchArgument

log

export RCUTILS_CONSOLE_OUTPUT_FORMAT="[{severity} {time}] [{name}]: {message} ({function_name}() at {file_name}:{line_number})"

industrial_robot_client

node status monitor

ros2bag: record data

Test

Deployment / Packaging

snap

Trouble-shooting

ERROR: the following packages/stacks could not have their rosdep keys resolved to system dependencies:

ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
ros2doctor: No definition of [python3-ifcfg] for OS version [xenial]
rviz_assimp_vendor: No definition of [assimp] for OS version [xenial]
ament_clang_tidy: No definition of [clang-tidy] for OS version [xenial]

Solved: rosdep install --from-paths src --ignore-src --rosdistro eloquent -y --skip-keys "console_bridge fastcdr fastrtps libopensplice67 libopensplice69 rti-connext-dds-5.3.1 urdfdom_headers" -y --os=debian:stretch

tracetools_trace

Starting >>> tracetools_trace                                                                       
[0.212s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/bot/Code/rviz/install' in the environment variable CMAKE_PREFIX_PATH seems to be a catkin workspace but it doesn't contain any 'local_setup.*
' files. Maybe the catkin version is not up-to-date?             
[0.212s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/bot/Development/dr-ros/install_isolated' in the environment variable CMAKE_PREFIX_PATH seems to be a catkin workspace but it doesn't containa
ny 'local_setup.*' files. Maybe the catkin version is not up-to-date?
Traceback (most recent call last):trace - 0.1s]    
  File "<string>", line 1, in <module>                                                        
  File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 111, in get_setup_arguments
    runpy.run_path(str(setup_py))                                                         
  File "/usr/lib/python3.5/runpy.py", line 261, in run_path
    code, fname = _get_code_from_file(run_name, path_name)                                      
  File "/usr/lib/python3.5/runpy.py", line 236, in _get_code_from_file
    code = compile(f.read(), fname, 'exec')                                                                                    
  File "/home/bot/ros2_ws/src/micro-ROS/ros_tracing/ros2_tracing/tracetools_trace/setup.py", line 33
    f'trace = {package_name}.trace:main',                                                                
                                       ^
SyntaxError: invalid syntax                                                                                                                            
--- stderr: tracetools_trace                         
Traceback (most recent call last):                                                                 
  File "/usr/lib/python3/dist-packages/colcon_core/executor/__init__.py", line 91, in __call__
    rc = await self.task(*args, **kwargs)                                                                                                                                                                          
  File "/usr/lib/python3/dist-packages/colcon_core/task/__init__.py", line 92, in __call__                                                                                                                  
    return await task_method(*args, **kwargs)                                                              
  File "/usr/lib/python3/dist-packages/colcon_ros/task/ament_python/build.py", line 50, in build
    setup_py_data = get_setup_data(self.context.pkg, env)                                                                  
  File "/usr/lib/python3/dist-packages/colcon_core/task/python/__init__.py", line 20, in get_setup_data
    return dict(pkg.metadata[key](env))                                                              
  File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 128, in getter
    str(desc.path / 'setup.py'), env)                                                                                                                                                                              
  File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 209, in get_setup_arguments_with_context                      
    cmd, stdout=subprocess.PIPE, env=env, check=True)                                               
  File "/usr/lib/python3.5/subprocess.py", line 398, in run                                                                                            
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-c', "import sys;sys.path.insert(0, '/usr/lib/python3');from colcon_python_setup_py.package_identification.python_setup_py import get_setup_arguments
;output = repr(get_setup_arguments('/home/bot/ros2_ws/src/micro-ROS/ros_tracing/ros2_tracing/tracetools_trace/setup.py'));sys.stdout.buffer.write(output.encode('utf-8'))"]' returned non-zero exit status 1
---
Failed   <<< tracetools_trace   [ Exited with code 1 ]

Summary: 0 packages finished [0.30s]
  1 package failed: tracetools_trace
  1 package had stderr output: tracetools_trace
Command '['/usr/bin/python3', '-c', "import sys;sys.path.insert(0, '/usr/lib/python3');from colcon_python_setup_py.package_identification.python_setup_py import get_setup_arguments;output = repr(get_setup_argume
nts('/home/bot/ros2_ws/src/micro-ROS/ros_tracing/ros2_tracing/tracetools_trace/setup.py'));sys.stdout.buffer.write(output.encode('utf-8'))"]' returned non-zero exit status 1
cd ~
python3.6 -m venv virtualenv --without-pip
cd virtualenv/
source bin/activate

vcs

raceback (most recent call last):
  File "/usr/bin/vcs", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3017, in <module>
    @_call_aside
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3003, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3030, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 659, in _build_master
    ws.require(__requires__)
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 967, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 853, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'vcstool==0.2.4' distribution was not found and is required by the application

Solution:

$ head /usr/bin/vcs
#!/usr/bin/python3.5

[pip] subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1

colcon-core

colcon build --symlink-install           Traceback (most recent call last):
  File "/usr/bin/colcon", line 6, in <module>                                                                                                                                       
    from pkg_resources import load_entry_point 
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3017, in <module>                                                                          
    @_call_aside                                   
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3003, in _call_aside                                                                     
    f(*args, **kwargs)                                 
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3030, in _initialize_master_working_set                                                        
    working_set = WorkingSet._build_master()   
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 659, in _build_master                                                                       
    ws.require(__requires__)                            
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 967, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 853, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'colcon-core==0.4.3' distribution was not found and is required by the application

rviz_rendering

--- stderr: rviz_rendering
CMake Warning at /home/bot/ros2_dashing/install/ament_cmake_gmock/share/ament_cmake_gmock/cmake/ament_add_gmock.cmake:67 (add_executable):
  Cannot generate a safe runtime search path for target
  billboard_line_test_target because files in some directories may conflict
  with libraries in implicit directories:

    runtime library [libfreetype.so.6] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /home/bot/anaconda2/lib
    runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /home/bot/anaconda2/lib
    runtime library [libcurl.so.4] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /home/bot/anaconda2/lib

  Some of these libraries may not be found correctly.
Call Stack (most recent call first):
  /home/bot/ros2_dashing/install/ament_cmake_gmock/share/ament_cmake_gmock/cmake/ament_add_gmock.cmake:50 (_ament_add_gmock)
  CMakeLists.txt:203 (ament_add_gmock)


CMake Warning at /home/bot/ros2_dashing/install/ament_cmake_gmock/share/ament_cmake_gmock/cmake/ament_add_gmock.cmake:67 (add_executable):
  Cannot generate a safe runtime search path for target
  movable_text_test_target because files in some directories may conflict
  with libraries in implicit directories:

    runtime library [libfreetype.so.6] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /home/bot/anaconda2/lib
    runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /home/bot/anaconda2/lib
    runtime library [libcurl.so.4] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /home/bot/anaconda2/lib

...


/usr/lib/x86_64-linux-gnu/libSM.so: undefined reference to `uuid_generate@UUID_1.0'
/home/bot/anaconda2/lib/libpng16.so.16: undefined reference to `inflateValidate@ZLIB_1.2.9'
/usr/lib/x86_64-linux-gnu/libSM.so: undefined reference to `uuid_unparse_lower@UUID_1.0'
collect2: error: ld returned 1 exit status
conda remove libpng
sudo apt-get install libpng16-16

ros1_bridge

--- stderr: ros1_bridge                                                     
Traceback (most recent call last):                                                                                            
  File "bin/ros1_bridge_generate_factories", line 11, in <module>                    
    from ros1_bridge import generate_cpp                                               
  File "/home/bot/ros2_dashing/src/ros2/ros1_bridge/ros1_bridge/__init__.py", line 23, in <module>
    import genmsg                                                           
ImportError: No module named 'genmsg'                              
make[2]: *** [generated/get_factory.cpp] Error 1                                     
make[1]: *** [CMakeFiles/ros1_bridge.dir/all] Error 2
make: *** [all] Error 2
[0.844s] WARNING:colcon.colcon_core.package_selection:ignoring unknown package 'ros1_bridge' in --packages-select
                     
Summary: 0 packages finished [1.18s]
[1.527s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/bot/Development/dr-ros/install_isolated' in the environment variable CMAKE_PREFIX_PATH seems to be a catkin workspace but it doesn't contain any 'local_setup.*' files. Maybe the catkin version is not up-to-date?

rqt

Could not import "pyqt" bindings of qt_gui_cpp library - so C++ plugins will not be available:
Traceback (most recent call last):                                                                           
  File "/home/bot/ros2_dashing/install/qt_gui_cpp/lib/python3.5/site-packages/qt_gui_cpp/cpp_binding_helper.py", line 43, in <module>
    from . import libqt_gui_cpp_sip                                                        
ImportError: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.9' not found (required by /home/bot/ros2_dashing/install/qt_gui_cpp/lib/python3.5/site-packages/qt_gui_cpp/libqt_gui_cpp_sip.so)
                                                                                       
RosPluginProvider.load(rqt_gui_py/RosPyPluginProvider) exception raised in __builtin__.__import__(rqt_gui_py.ros_py_plugin_provider, [RosPyPluginProvider]):
Traceback (most recent call last):                                                         
  File "/home/bot/ros2_dashing/build/rqt_gui/src/rqt_gui/ros_plugin_provider.py", line 81, in load
    attributes['module_name'], fromlist=[attributes['class_from_class_type']], level=0)      
ImportError: No module named 'rqt_gui_py'                                                  
                                                                                               
RecursivePluginProvider.discover() loading plugin "rqt_gui_py/RosPyPluginProvider" failed:
Traceback (most recent call last):                                                     
  File "/home/bot/ros2_dashing/install/qt_gui/lib/python3.5/site-packages/qt_gui/recursive_plugin_provider.py", line 60, in discover
    instance = self._plugin_provider.load(plugin_descriptor.plugin_id(), None)
  File "/home/bot/ros2_dashing/build/rqt_gui/src/rqt_gui/ros_plugin_provider.py", line 91, in load
    raise e
  File "/home/bot/ros2_dashing/build/rqt_gui/src/rqt_gui/ros_plugin_provider.py", line 81, in load
    attributes['module_name'], fromlist=[attributes['class_from_class_type']], level=0)
ImportError: No module named 'rqt_gui_py'

rqt_gui

Traceback (most recent call last):
  File "/home/bot/ros2_dashing/install/rqt_console/lib/rqt_console/rqt_console", line 5, in <module>
    from rqt_gui.main import Main
ImportError: No module named 'rqt_gui'

ros2 run: No executable found

combine Python & C++

[xrce dds] can't find ros2 topic

ROS Subsystem Prefix
ROS Topics rt
ROS Service Request rq
ROS Service Response rr
ROS Service rs
ROS Parameter rp
ROS Action ra

Could not determine the type for the passed topic

local network

ROS_LOCALHOST_ONLY

[ERROR] [launch]: Caught exception in launch (see debug for traceback): init() missing 1 required keyword-only argument: 'node_name'

[ros2 launch] AttributeError: 'NoneType' object has no attribute 'complete'

what(): goal_handle attempted invalid transition from state EXECUTING with event CANCELED

[parameters] rclcpp::exceptions::ParameterAlreadyDeclaredException Parameter has already been declared

  rclcpp::NodeOptions options;
  options.allow_undeclared_parameters(true);
terminate called after throwing an instance of 'rclcpp::exceptions::ParameterAlreadyDeclaredException'
what():  parameter '' has already been declared      
Aborted (core dumped)

[parameters] Received invalid sequence number. Ignoring...

this only happens when I run two of the same node simultaneously and send parameters to that node name. (I wasn't doing that intentionally.)

kill node

ros2 lifecycle set <nodename> shutdown
kill -9 $(pgrep -f "`which ros2` launch")

[action] Executing action client but nothing is ready

[action] ClientGoalHandle::async_result()

[action] UnknownGoalHandleError

terminate called after throwing an instance of 'rclcpp_action::exceptions::UnknownGoalHandleError'                                            
[singulation_app-5]   what():  Goal handle is not known to this client.
⚠️ **GitHub.com Fallback** ⚠️