ROS2 学习古月居ros21讲学习笔记

这篇博客详细记录了在Ubuntu上安装ROS2 Foxy后,如何启动小海龟仿真、键盘控制小海龟、查看ROS节点及消息、发送运动指令等操作。还介绍了使用rqt创建新海龟和服务,以及使用colcon编译解决环境问题。同时,提到了ROS2下setup.sh文件的作用,并给出了创建功能包的参考链接。
摘要由CSDN通过智能技术生成

ROS21讲学习笔记
在Ubuntu上安装的是ros2 foxy

启动小海龟

ros2 run turtlesim turtlesim_node

启动键盘控制

ros2 run turtlesim turtle_teleop_key 

查看运行的节点及其关系

rqt_graph

查看节点

ros2 node list

发送运动指令
暂时不清楚怎么快速调出这六个数据的方式,只能全部打出这些参数,需要注意空格

ros2 topic pub  /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 1.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"

查看消息都有哪些

ros2 topic info /turtle1/cmd_vel 

查看消息的数据结构

ros2 interface show geometry_msgs/msg/Twist

查看服务

ros2 service list

暂时没有找到如何从命令行中创建新海龟,采用通过rqt的方式创建,

rqt

在Plugins -> services -> service caller 中在service下拉列表中选中/spawn,然后在下面输入新海龟的信息,然后call出去。

src 代码空间
build 编译空间
devel 开发空间
install 安装空间

mkdir catkin_ws
cd catkin_ws/
mkdir src
cd src/

git clone https://github.com/ros2/examples src/examples -b foxy

安装rosdep
sudo apt install python3-rosdep2
rosdep update
更新通过代理安装

rosdep install -i --from-path src --rosdistro foxy -y
解决依赖问题

source /opt/ros/foxy/setup.bash
设置环境变量

ROS2 下不再通过catkin编译,而是使用colcon编译

colcon build 失败
解决方法
pip install pytest-rerunfailures

显示目录层级
tree -L 2

参考:
https://blog.csdn.net/qq_45701501/article/details/119282003

colcon build --symlink-install
colcon test

ros2 run examples_rclcpp_minimal_subscriber subscriber_member_function
新终端开发,source setup.sh
ros2 run examples_rclcpp_minimal_publisher publisher_member_function

疑问:
ROS根目录下的setup.sh和包里install目录下的setup.sh有什么区别
source 是为了把这些添加到环境变量

创建功能包:
参考链接:
https://www.guyuehome.com/35371

程序发布

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值