Skip to content

ROS2 workspace

安装 colcon

colcon 最常用的两个方法是构建(build)和测试(test)。构建方法用于构建工作空间中的所有包,而测试方法用于运行工作空间中的所有测试。

bash
sudo apt install python3-colcon-common-extensions

An image

创建 workspace

bash
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws
colcon build

An image

ROS2 项目的 bash 配置

类似于 ROS1 的 bash 配置,在~/.bashrc 中添加以下内容:

bash
source /opt/ros/foxy/setup.bash
source ~/ros2_ws/install/setup.bash

参考截图如下: An image

rviz2 工具

bash
rviz2

参考截图如下: An image

An image

An image

  • build
  • install
  • log
  • src
  • ......

创建 package

bash
cd ~/ros2_ws/src
ros2 pkg create --build-type ament_cmake cpp_pkg --dependencies rclcpp std_msgs

An image

编写 package

bash
cd ~/ros2_ws/src/cpp_pkg
touch CMakeLists.txt
touch package.xml

其他