ros2的 安装 (humble version)
1.换源
2.过程
sudo apt update && sudo apt install locales sudo locale-gen en_US en_US.UTF-8 sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 export LANG=en_US.UTF-8 sudo apt install curl gnupg lsb-release sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null sudo apt update && sudo apt upgrade sudo apt install ros-humble-desktop echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
3.测试
ros2 run demo_nodes_cpp talker ros2 run demo_nodes_py listener
4.基本语法
#ROS1 --> #ROS2 # ----------------------------------- roscore --> ros2 rosrun --> ros2 run rosnode --> ros2 node roslaunch --> ros2 launch rosparam --> ros2 param rospkg --> ros2 pkg rosservice --> ros2 service rossrv --> ros2 srv rostopic --> ros2 topic rosaction --> ros2 action
5.colcon命令
colcon build #–packages-select 命令 colcon build --packages-select YOUR_PKG_NAME #编译指定包,可以多个 #–packages-ignore 命令 colcon build --packages-ignore YOUR_PKG_NAME #忽略指定包,可以多个 #–continue-on-error 命令 colcon build --continue-on-error #在编译出错之后继续编译其他模块 #–symlink-install 命令 colcon build --symlink-install #表示编译时如果 install 中文件已经存在于 src 或者 build 文件夹中,就用超链接指向该文件,避免浪费空间,也可以实现同步更新 #–merge-install 命令 colcon build --merge-install #默认会使用install使用作为所有软件包的安装前缀,而不是 安装库中特定于软件包的子目录; #如果没有这个选项,每个包都会贡献自己的环境路径,导致环境变量特别长;使用此选项,环境变量更短; #–parallel-workers 命令 colcon build --parallel-workers NUMBER #要并行处理的最大作业数, 默认值是逻辑 CPU 内核数 #–cmake-args 命令 colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release #表示传入cmake编译选项参数
6.package.xml 文件
<package> <!--1. 根标签--> <name> <!--2. 包名--> <version> <!--3. 版本号--> <description> <!--4. 包描述--> <maintainer> <!--5. 维护者--> <license> <!--6. 软件许可--> <buildtool_depend> <!--7. 编译构建工具,通常为catkin--> <depend> <!--8. 指定依赖项为编译、 导出、 运行需要的依赖,最常用的依赖标记。--> <build_depend> <!--9. 编译依赖项--> <build_export_depend> <!--10. 导出依赖项--> <exec_depend> <!--11. 运行依赖项--> <test_depend> <!--12. 测试用例依赖项--> <doc_depend> <!--13. 文档依赖项--> </package> <!--根标签-->
7.关于 ros 的命名规则
https://blog.csdn.net/zvvzxzko2006/article/details/110222802?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-3-110222802-blog-120363007.pc_relevant_3mothn_strategy_and_data_recovery&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-3-110222802-blog-120363007.pc_relevant_3mothn_strategy_and_data_recovery&utm_relevant_index=6
8.数据录制与回放
ros2 bag record topic_name ros2 topic list ros2 bag play -l *.db3 ros2 topic hz topic_name ros2 topic echo topic_name
9.launch 文件的编写
import os from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch_ros.actions import Node def generate_launch_description(): # config_file = os.path.join(get_package_share_directory("app_locator"), "config", "app_locator.yaml") return LaunchDescription([ Node( package='app_controller', namespace='/', executable='app_controller_node', name='app_controller_node', output='screen', emulate_tty=True, ) ])
foxy version: https://blog.csdn.net/feimeng116/article/details/106602562
TRANSLATE with x English TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back 标签:记录,--,sudo,文档,ROS2,install,ros,ros2,build From: https://www.cnblogs.com/E-Dreamer-Blogs/p/17332198.html