当前位置:网站首页>【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
小海龟就开始按照之前记录的路径开始移动了~~~
边栏推荐
猜你喜欢

Idea close global search box

AQS source code analysis

Technology Review: what is the evolution route of container technology? What imagination space is there in the future?

Learn more about the practical application of sentinel

win10或win11打印机无法打印

In the era of full programming, should I give up this road?

2022-06-16 工作记录--JS-判断字符串型数字有几位 + 判断数值型数字有几位 + 限制文本长度(最多展示n个字,超出...)

双亲委派机制

Data center basic network platform

Common voting governance in Dao
随机推荐
电力系统| IEEE论文投稿流程
Based on the codeless platform, users deeply participated in the construction, and digital data + Nanjing Fiberglass Institute jointly built a national smart laboratory solution
软件设计的七大原则
Use of selector for NiO multiplexing
Disk structure
find your present (2)
Feign project construction
Extend your kubernetes API with aggregated apiserver
DX 的 HLSL 和 GL 的 GLSL的 矩阵构建的行列区别
JWT(Json Web Token)
Basic principles of spanning tree protocol
NiO, bio, AIO
OA system -- save the verification code to session
Huada 4a0gpio settings
Heavyweight! Fada is listed as a "specialized and new" enterprise
ACL (access control list) basic chapter - Super interesting learning network
Chapter 10 project stakeholder management
Introduction, installation and use of postman tool
网上立案流程
Power system | IEEE paper submission process