ROS2与STM32入门教程-micro_ros的linux版本
说明:
介绍如何安装使用micro_ros
步骤:
安装ros2版本foxy,查看教程
加载ros2环境
source ~/ros2_foxy/install/setup.bash
也可以把这一句加到bashrc文件,新开终端就不用再输入
安装micro-xrce-dds,查看教程
mkdir -p ~/tools/
cd ~/tools/
git clone https://github.com/eProsima/Micro-XRCE-DDS.git
cd Micro-XRCE-DDS
mkdir build && cd build
cmake ..
make
sudo make install
sudo ldconfig /usr/local/lib/
安装micro_ros_setup
mkdir -p ~/microros_ws
cd ~/microros_ws
git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_setup.git src/micro_ros_setup
# Update dependencies using rosdep
sudo apt update && rosdep update
rosdep install --from-path src --ignore-src -y
# Install pip
sudo apt-get install python3-pip
# Build micro-ROS tools and source them
colcon build
source install/local_setup.bash
创建工作空间
cd ~/microros_ws
ros2 run micro_ros_setup create_firmware_ws.sh host
这一步下载micro-ROS apps
位于src/uros/micro-ROS-demos/rcl下
编译工作空间
ros2 run micro_ros_setup build_firmware.sh
source install/local_setup.bash
创建代理端工作空间
cd ~/microros_ws
ros2 run micro_ros_setup create_agent_ws.sh
编译工作空间
ros2 run micro_ros_setup build_agent.sh
source install/local_setup.bash
新终端运行代理
ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888
新终端运行例子
cd ~/microros_ws
source install/local_setup.bash
# Run a micro-ROS node
ros2 run micro_ros_demos_rclc ping_pong
新终端输入话题列表
$ ros2 topic list
/microROS/ping
/microROS/pong
/parameter_events
/rosout
输入话题内容
$ ros2 topic echo /microROS/ping
stamp:
sec: 7636
nanosec: 507000000
frame_id: '2132843206_1085377743'
---
stamp:
sec: 7638
nanosec: 509000000
frame_id: '111120688_1085377743'
---
stamp:
sec: 7640
nanosec: 508000000
frame_id: '1461198358_1085377743'