ros2常用功能
创建包
ros2 pkg create --build-type ament_cmake --node-name my_node my_package --license Apache-2.0
colcon
命令使用tab补齐
echo "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" >> ~/.bashrc
常用便捷命令
-
--packages-up-to
builds the package you want, plus all its dependencies, but not the whole workspace (saves time) -
--symlink-install
saves you from having to rebuild every time you tweak python scripts -
--event-handlers console_direct+
shows console output while building (can otherwise be found in thelog
directory) -
--packages-select my_package
参数、launch文件修改后无需重新build
启用--symlink-install
后将不会把文拷贝到install目录,而是通过创建符号链接的方式。修改参数和launch文件后无需重新编译程序。
the option --symlink-install
. This allows the installed files to be changed by changing the files in the source
space (e.g. Python files or other non-compiled resources) for faster iteration.
rosdepc
rosdepc 是小鱼制作的国内版rosdep,是一个用于安装依赖的工具。该工具的安装可以采用一键安装进行,选项编号为3。安装完成后运行一次rodepc update即可使用。
安装rosdepc:
wget http://fishros.com/install -O fishros && . fishros使用rosdepc:
rosdepc install -r --from-paths src --ignore-src --rosdistro $ROS_DISTRO -y
参数和动态配置
在 ROS1 中,全局参数和节点特定动态配置参数是两个独立的概念。
在 ROS2中,正在使用统一的方法。它类似于动态配置,名为"全局参数服务"的节点将接受无条件设置值的请求。在 ROS1中需要对所有参数进行轮询,如果发生改变就发布出去,但ROS2中只要发生改变就可以通知其他节点。
Monitoring for parameter changes (C++) — ROS 2 Documentation: Humble documentation
qos策略设置:
当订阅不到消息时可以参考
使用GDB回溯调试
Get Backtrace in ROS 2 / Nav2 — Nav2 1.0.0 documentation