当前位置:网站首页>【ROS玩转Turtlesim小海龟】
【ROS玩转Turtlesim小海龟】
2022-06-24 19:39:00 【又菜又爱玩_】
ROS玩转Turtlesim小海龟
Turtlesim 是一个用于学习 ROS的轻量级模拟器,因为其有个乌龟,所以也经常被称为小乌龟.
本人是ROS初学者,才刚刚接触,给大家分享一下ROS的学习经历,想要学习ROS的朋友可以参考一下。 使用到: ubuntu ,ros
/
/
一_键盘控制小海龟移动
1.首先要打开 ROS Master ,打开一个新的终端(Ctrl+alt+T),输入:
~$ roscore
2.再打开一个终端,启动小海龟仿真器:
~$ rosrun turtlesim turtlesim_node
启动成功后出现窗口:
3.再打开一个新的终端,启动小海龟控制节点,输入:
~$ rosrun turtlesim turtle_teleop_key
成功后出现
[email protected]:~$ rosrun turtlesim turtle_teleop_key
Reading from keyboard
---------------------------
Use arrow keys to move the turtle. 'q' to quit.
将光标放在当前窗口中,使用键盘的上下左右能够控制小海龟移动:

< ctrl > + < C > 可退出键盘控制
/
/
二 _命令行控制小海龟移动
打开一个新的终端,输入:
[email protected]:~$ rostopic pub /turtle1/cmd_vel geometry_msgs/Twist "linear:
x: 1.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0"
其中linear就是线速度,angular就是角速度了
将linear下的 x 设为1.0,小海龟会沿 x 方向移动一小段,要使小海龟一直移动,在pub命令后加上-r 10 :即设置了一个发送的频率 10hz,这样小海龟就会沿一个方向一直移动了,同样按下< ctrl > + < C > 可退出控制,小海龟停止移动。
[email protected]:~$ rostopic pub -r 10 /turtle1/cmd_vel geometry_msgs/Twist "linear:
x: 1.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 0.0"
这样我们就可以想办法让小海龟画圆,输入:
[email protected]:~$ rostopic pub -r 10 /turtle1/cmd_vel geometry_msgs/Twist "linear:
x: 1.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 1.0"
让小海龟有 x 轴的线位移及 z 轴方向的角度位移,就出现一个完整的圆了:

/
/
/
三 _按照记忆路线控制小海龟移动
- 记忆路径生成
保留之前的终端窗口,再创建一个新窗口,输入:~$ rosbag record -a -O cmd_record 开始记录小海龟路径,出现:
[email protected]:~$ rosbag record -a -O cmd_record
[ INFO] [1655641849.095812339]: Recording to 'cmd_record.bag'.
[ INFO] [1655641849.096922059]: Subscribing to /turtle1/color_sensor
[ INFO] [1655641849.098730076]: Subscribing to /turtle1/cmd_vel
[ INFO] [1655641849.100702759]: Subscribing to /rosout
[ INFO] [1655641849.102427902]: Subscribing to /rosout_agg
[ INFO] [1655641849.105294212]: Subscribing to /turtle1/pose
将光标放在启动键盘控制的终端,控制小海龟移动,此时已经开始记录小海龟的路径信息,记录完成后将光标放在开启记录路径的终端 按下< ctrl > + < C > 停止记录,主文件夹会生成一个.bag文件就是我们的记录文件:
//
/
/
- 按照记忆路径移动
将之前的终端全部关掉,重新按照步骤打开小海龟控制窗口后,打开一个新的终端输入:
~$ rosbag play cmd_record.bag
小海龟就开始按照之前记录的路径开始移动了~~~
边栏推荐
- 故障安全移动面板KTP900F Mobile下载程序提示无法下载,目标设备正在运行或未处于传输模式的解决办法
- [QT] QT event handling
- Use of selector for NiO multiplexing
- The ktp900f mobile download program of the fail safe mobile panel prompts that the download cannot be performed, and the target device is running or not in the transmission mode
- Relationnet++: a representation of fusion of multiple detection targets based on transformer | neurips 2020
- Introduction to machine learning compilation course learning notes lesson 1 overview of machine learning compilation
- Common voting governance in Dao
- 电力系统| IEEE论文投稿流程
- Firewall working principle and detailed conversation table
- Learn more about the practical application of sentinel
猜你喜欢
See how sparksql supports enterprise level data warehouse
CA Zhouji - the first lesson in 2022 rust

NiO, bio, AIO

电力系统| IEEE论文投稿流程

ThreadLocal memory leak

The usage difference between isempty and isblank is so different that so many people can't answer it

糖豆人登录报错解决方案

Creating files, recursively creating directories

结构体的内存对齐

Idea global search replace shortcut key
随机推荐
AQS源码分析
AQS source code analysis
Zero code can apply data visualization to enterprise management
Visitor tweets tell you which groups are consuming blind boxes
详细了解关于sentinel的实际应用
Huada 04A operating mode / low power consumption mode
NIO 零拷贝
故障安全移动面板KTP900F Mobile下载程序提示无法下载,目标设备正在运行或未处于传输模式的解决办法
Redis-跳表
【Mongodb】READ_ME_TO_RECOVER_YOUR_DATA,数据库被恶意删除
结构体的内存对齐
img2pdf
Nuscenes -- remedies for missing image files or 0-size images encountered during dataset configuration
Can AI chat robots replace manual customer service?
Panorama of enterprise power in China SSD industry
The difference between get and post
MySQL + JSON = King fried!!
The usage difference between isempty and isblank is so different that so many people can't answer it
Genesis public chain and a group of encryption investors in the United States gathered in consensus 2022
Servlet details