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
程序发布