当前位置:网站首页>【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
小海龟就开始按照之前记录的路径开始移动了~~~
边栏推荐
- Cache control of HTTP
- Description of software version selection of kt6368a Bluetooth dual-mode transparent chip
- ACL (access control list) basic chapter - Super interesting learning network
- HTTP的缓存控制
- See how sparksql supports enterprise data warehouse
- Use of selector for NiO multiplexing
- Valueerror: cannot take a larger sample than population when 'replace=false‘
- Code farmers should also understand the IPv4 subnet division of point networks
- Envoy obtain the real IP address of the client
- 证件照处理
猜你喜欢

Nuscenes -- remedies for missing image files or 0-size images encountered during dataset configuration

机器学习编译入门课程学习笔记第一讲 机器学习编译概述

How to automatically remove all . orig files in Mercurial working tree?

【Mongodb】READ_ME_TO_RECOVER_YOUR_DATA,数据库被恶意删除

Chapter 10 project stakeholder management

CDN principle

AQS source code analysis

Win10 or win11 printer cannot print

故障安全移动面板KTP900F Mobile下载程序提示无法下载,目标设备正在运行或未处于传输模式的解决办法

Cross border e-commerce, early entry and early benefit
随机推荐
CDN principle
结合源码剖析Oauth2分布式认证与授权的实现流程
Disk structure
机器学习编译入门课程学习笔记第一讲 机器学习编译概述
Nuscenes -- remedies for missing image files or 0-size images encountered during dataset configuration
NIO、BIO、AIO
seven
开发规范~参数校验异常、异常返回提示切面
中国SSD行业企业势力全景图
Data communication foundation - Ethernet port mirroring and link aggregation
Redis hop table
Web攻击之CSRF和SSRF
Concurrency of heap memory allocation
Common voting governance in Dao
Database transaction Transanction
The usage difference between isempty and isblank is so different that so many people can't answer it
Cross border e-commerce, early entry and early benefit
MySQL + JSON = King fried!!
Principles of Ethernet port mirroring, link aggregation and VLAN Technology
AQS源码分析