ROS基础入门(一)创建指令工作空间和功能包的新建

更新时间:2023-06-27 19:49:22 阅读: 评论:0

ROS基础⼊门(⼀)创建指令⼯作空间和功能包的新建
⽬录
1.常见命令汇总
⼩海龟的⾃由运动仿真
1.⼀个终端打开ros管理器
roscore
2.另⼀个终端打开ros的海龟节点,run⼀个新节点
rosrun turtlesim turtulesim_node
3添加⼀个控制命令输⼊
rosrun turtlesim turtle_teleop_key
4 查看总体运⾏的节点情况
rqt_graph
姹紫嫣红是什么意思可以看到由2个node组成,由键盘的控制端teleop_turtle 通过topic 即/turtle/cmd_vel 发送先关控制指令到 turtlesim来控制显⽰画⾯⾥⾯乌龟的游动.(左右控制专项,上下控制前进后退)
同时也记录⼀下常⽤的其他命令:
(1)rosnode
rosnode is a command-line tool for printing information about ROS Nodes.打印节点信息
Commands:手机充电线有几种
rosnode ping test connectivity to node
rosnode list list active nodes
rosnode info print information about node
rosnode machine list nodes running on a particular machine or list machines  rosnode kill kill a running node
rosnode cleanup purge registration information of unreachable nodes
例如查看turtlesim这个节点的相关信息:
ztfmars@GL503:~$ rosnode info /turtlesim
保兑仓--------------------------------------------------------------------------------
Node [/turtlesim]
Publications:
* /rosout [rosgraph_msgs/Log]
* /turtle1/color_nsor [turtlesim/Color]
* /turtle1/po [turtlesim/Po]
Subscriptions:
* /turtle1/cmd_vel [geometry_msgs/Twist]
Services:
* /clear腹式呼吸训练
* /kill
* /ret
* /spawn
* /turtle1/t_pen
* /turtle1/teleport_absolute
* /turtle1/teleport_relative
* /turtlesim/get_loggers
* /turtlesim/t_logger_level
contacting node GL503:36561/ ...
一个田一个各Pid: 15418
Connections:
* topic: /rosout
* to: /rosout
* direction: outbound
* transport: TCPROS
* topic: /turtle1/cmd_vel
* to: /teleop_turtle (GL503:33687/)
* direction: inbound
* transport: TCPROS
(2)rostopic
rostopic is a command-line tool for printing information about ROS Topics.
可以⽤来打印和发布相关话题内容
Commands:
母鸡的简笔画rostopic bw display bandwidth ud by topic
rostopic delay display delay of topic from timestamp in header
rostopic echo print messages to screen
rostopic find find topics by type
rostopic hz display publishing rate of topic
拼音字母儿歌
rostopic info print information about active topic
rostopic list list active topics
rostopic pub publish data to topic
rostopic type print topic or field type
例如发布⼀条让海龟运动的指令(其实输⼊完了 …cmd_vel按下连续2次tab可以⾃动不全):
rostopic pub /turtle1/cmd_vel -r 10 geometry_msgs/Twist "linear:
x:0.0
y:0.0
z:0.0
angular:
x:0.0
y:0.0
z:0.0"
其中linear表⽰线速度,angular表⽰转动⾓度,-r表⽰⼀直发布(不加的话,就是只发布⼀次)后⾯是频率即 10次/s. ros⾥⾯默认的速度都是 m/s, ⾓度都是 rad/s
(3) rosrvice
ros启动的相关服务的显⽰和控制
Commands:
rosrvice args print rvice arguments
rosrvice call call the rvice with the provided args
rosrvice find find rvices by rvice type
rosrvice info print information about rvice
rosrvice list list active rvices
rosrvice type print rvice type
rosrvice uri print rvice ROSRPC uri
Type rosrvice <command> -h for more detailed usage, e.g. 'rosrvice call -h'例如在指定位置⽣成新海龟
rosrvice call /spawn "x:10.0
y:8.0
theta:0.0
name:'turtule_new'"
(4)rosbag
Usage: rosbag <subcommand> [options] [args]
主要是⽤来储存和记录信息和操作数据
A bag is a file format in ROS for storing ROS message data. The rosbag command can record, replay and manipulate bags.
Available subcommands:
check  Determine whether a bag is playable in the current system, or if it can be migrated.
compress  Compress one or more bag files.
decompress  Decompress one or more bag files.
filter  Filter the contents of the bag.
fix  Repair the messages in a bag file so that it can be played in the current system.
help
info  Summarize the contents of one or more bag files.
play  Play back the contents of one or more bag files in a time-synchronized fashion.
record  Record a bag file with the contents of specified topics.
假说
reindex  Reindexes one or more bag files.
For additional information, s/rosbag
( 5 ) rosrun
Usage: rosrun [–prefix cmd] [–debug] PACKAGE EXECUTABLE [ARGS]
rosrun will locate PACKAGE and try to find
an executable named EXECUTABLE in the PACKAGE tree.
If it finds it, it will run it with ARGS.
⽤来启动⼀个安装包下⾯可执⾏⽂件的命令,如果找到的话,就会送⼊ARGS参数.
2.⼯作空间
结构:
src -> c++源码所在位置;
build-> 编译过程的中间⽂件所在位置;
devel-> 开发过程中的中间⽂件或者可执⾏⽂件所在位置;
install -> 最终发⾏的可执⾏⽂件所在的位置,可能会devel有重叠;
- 创建⼯作空间
注意:
catkin_init_workspace :
初始化⼯作空间,是在src之中执⾏的,执⾏后会⽣成源⽂件的; 
catkin_make :
编译命令是在根⽬录⽂件下执⾏的,即~/catkin_ws, 执⾏后会在根⽬录⽣成build,devel⽂件夹及其内部的编译⽂件;

本文发布于:2023-06-27 19:49:22,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1053562.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:控制   节点   海龟   命令   相关
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图