ROS学习笔记七:使用rqt_console和roslaunch
来源:互联网 发布:.xyz域名查询 编辑:程序博客网 时间:2024/04/30 02:52
ROS学习笔记七:使用rqt_console和roslaunch
本节主要介绍在调试时使用的rqt_console和rqt_logger_level,以及一次性打开多个节点的工具roslaunch。
使用rqt_console和rqt_logger_level
- rqt_console:主要显示节点的输出信息。
- rqt_logger_level:用于设置输出信息的重要性等级。
还是利用turtlesim例程,看一下其不同等级的输出。在打开turtlesim之前,首先要运行roscore,然后在两个不同的终端中输入以下命令:
rosrun rqt_console rqt_console
rosrun rqt_logger_level rqt_logger_level
可以看到如下弹出的窗口
然后在一个新的终端中输入以下命令打开turtlesim
rosrun turtlesim turtlesim_node
然后发现rqt_console窗口中就有了一个生成的信息
现在可以更改rqt_logger_level中的信息等级,更改为warn,则只会显示warn、error和fatal类的信息。通过rostopic pub
命令向小海龟发送命令让其撞墙,产生警告信息:
rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0,0.0,0.0]' '[0.0,0.0,0.0]'
然后在rqt_console窗口中就会显示撞墙的警告信息:
roslaunch
roslaunch一次性打开在一个launch文件中定义的所有节点。
roslaunch基本语法
roslaunch [package] [launch.file] [args]roslaunch <launch-file-paths...> [args]
虽然说launch file放在哪里都可以,只要在运行的时候指明其位置即可。但是一般来说,都会在软件包目录下创建一个文件夹launch,以用来存放所创建的launch文件。
指明launch file文件位置的方式有两种:
第一种是直接指明launch file的绝对路径位置
第二种是指明软件包名称和放在软件包目录中的launch file,这种情况下roslaunch会在软件包目录中寻找和指定文件匹配的launch file
roslaunch beginner-tutorials turtlemimic.launchroslaunch ~/ros-tutorial/src/beginner-tutorials/turtlemimic.launchWARNING: Package name "beginner-tutorials" does not follow the naming conventions. It should start with a lower case letter and only contain lower case letters, digits and underscores.... logging to /home/mountzf/.ros/log/9f76d9e2-6b34-11e6-a83d-000c29521e21/roslaunch-ubuntu-4381.logChecking log directory for disk usage. This may take awhile.Press Ctrl-C to interruptDone checking log file disk usage. Usage is <1GB.started roslaunch server http://ubuntu:44397/SUMMARY========PARAMETERS * /rosdistro: indigo * /rosversion: 1.11.20NODES / mimic (turtlesim/mimic) /turtlesim1/ sim (turtlesim/turtlesim_node) /turtlesim2/ sim (turtlesim/turtlesim_node)ROS_MASTER_URI=http://localhost:11311core service [/rosout] foundWARNING: Package name "beginner-tutorials" does not follow the naming conventions. It should start with a lower case letter and only contain lower case letters, digits and underscores.process[turtlesim1/sim-1]: started with pid [4399]process[turtlesim2/sim-2]: started with pid [4400]process[mimic-3]: started with pid [4401]
rostopic pub /turtlesim1/turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2,0,0]' '[0,0,1.8]'
其中turtlemimic.launch文件的内容为:
<launch> <group ns="turtlesim1"> <node pkg="turtlesim" name="sim" type="turtlesim_node"/> </group> <group ns="turtlesim2"> <node pkg="turtlesim" name="sim" type="turtlesim_node"/> </group> <node pkg="turtlesim" name="mimic" type="mimic"> <remap from="input" to="turtlesim1/turtle1"/> <remap from="output" to="turtlesim2/turtle1"/> </node></launch>
也可使使用rqt_graph画出节点之间的关系图,更加清楚了解后roslaunch做了些什么。
mimic是一个起模仿作用的节点,实现将turtlesim1的数据信息传送给turtlesim2。
一个node element包含三个必须的属性:pkg, type, name.
pkg和type属性指出ROS应该运行哪个pkg中的哪个node,注意:此处的type是可执行文件的名称,而name则是可以任意给出的,它覆盖了原有文件中ros::init指定的node name。
在独立的窗口运行各nodes
我们在各自的termin运行rosrun node_name;但是运行roslaunch时,所有的nodes共用一个相同的terminal,这对于那些需要从控制台输入的nodes很不方便。可以使用launch-prefix属性。
launch-prefix=”command-prefix”Eg:launch-prefix=”xterm -e”等价于 xterm -e rosrun turtlesim turtle_teleop_key
xterm 命令表示新建一个terminal; -e参数告诉xterm执行剩下的命令行。
当然,launch-prefix属性不仅仅限于xterm。它可用于调试(通过gdb或valgrind),或用于降低进程的执行顺序(通过nice).
重映射names(remapping names)
除了解析relative names和private names,ROS也支持重映射,用于修改nodes当前使用的名称。
重映射相当于换名,每次重映射需提供一个original name和一个new name。每次node使用它的original name, ROS client library都会将其替换为remapping name。
创建remapping name两种方法:
单个node
对于单个node,在命令行进行remapping(remap对象可以是node,topic等)。
original-name:=new-name
Eg: $ rosrun turtlesim turtlesim_node turtle1/pose:=tim
在launch文件中
在launch文件内remap names,使用remap element
<remap from=”original_name” to “new_name”>
如果remap出现在launch文件开头,作为launch文件的子元素,则该remapping将被用于随后所有的nodes。如果remap作为某个node的子元素,则只用于该节点。
Eg:<node pkg=”turtlesim” type=”turtlesim_node” name=”turtle1”> <remap from =”turtle1/pose” to “tim”></node>
注意:在ROS进行remapping之前,remaping的所有name,包括original和new names,都将被解析为global names。所以,remapping之后所有的名字通常都是relative names。
总结
- rqt_console:主要显示节点的输出信息。
- rqt_logger_level:用于设置输出信息的重要性等级。
- roslaunch:一次性打开在一个launch文件中定义的所有节点。
祝枫
2016年8月26日于哈尔滨
- ROS学习笔记七:使用rqt_console和roslaunch
- ros笔记:(5)使用 rqt_console 和 roslaunch
- 使用 rqt_console 和 roslaunch
- ROS的学习(十)rqt_console和roslaunch
- ROS入门_1.11 使用 rqt_console 和 roslaunch
- ROS教程(八):使用 rqt_console 和 roslaunch
- ROS总结—— rqt_console 和 roslaunch
- ROS学习手记 - 6 使用ROS中的工具:rqt_console & roslaunch & rosed
- 机器人操作系统ROS Indigo 入门学习(9)——理解ROS rqt_console和 roslaunch
- 机器人操作系统ROS Indigo 入门学习(9)——理解ROS rqt_console和 roslaunch
- 机器人操作系统ROS Indigo 入门学习(9)——理解ROS rqt_console和 roslaunch
- 机器人操作系统ROS Indigo 入门学习(9)——理解ROS rqt_console和 roslaunch
- (七)ROS rxconsole和roslaunch学习
- 使用 rqt_console 和 roslaunch(八)
- ROS学习第三弹(Services/Parameters rqt_console/rqt_logger_level/roslaunch)
- [跟我学ROS]8.rqt_console和roslaunch的用法
- rqt_console和roslaunch
- 6、rqt_console和roslaunch
- jQuery概述
- jquery uploadify 火狐 406问题
- C#内置的几种委托详解,lambda表达式的演变
- Java中abstract与interface的区别
- [SCOI2007]蜥蜴
- ROS学习笔记七:使用rqt_console和roslaunch
- Android逆向实例笔记—那些搜不到的中文怎么办?
- 使用Objective-C开发AppleWatch(一)关于Complication
- 无法将 匿名方法 转换为类型“System.Delegate”,因为它不是委托类型:解决方法
- 看我
- TortoiseSVN安装后右键无svn选项
- 静态库.a的制作,或framework的制作
- HTTP状态码(HTTP Status Code)
- 【转载】MySQL数据库迁移详细步骤