ROS_Kinetic_06 ROS基础内容(三)
ROS_Kinetic_06 ROS基础内容(三)
先插入一段闲话,关于android的碎片化,无非集中于版本过多,型号各异,品牌杂乱等,似乎这是开源软件无法摆脱的宿命,ROS似乎也在这条路上越走越远,但真是如此吗?有专门的文章论述这类的问题,有兴趣了解ROS版本,点击查看,其实核心的东西一直在那里,从来没有改变,开源的核心是开放,开放的核心是包容,正因为如此才有了如此多的应用,如此丰富的可能,这可以理解为碎片化,也可以看作多样性的例证,更是开源活力的证明。这是一个异彩纷呈开源时代。退一步来讲,不论是微软,苹果也不都在不断升级更新自己的软硬件嘛,也有各种各样的版本号,这就不是碎片化。当初用微软的机器人仿真平台觉得非常不错,免费但不开源,几年前就已经OVER了。
1 ROS服务和参数
官网教程:http://wiki.ros.org/cn/ROS/Tutorials/UnderstandingServicesParams
服务(services)是节点之间通讯的另一种方式。
服务允许节点发送请求(request) 并获得一个响应(response)。
1 rosservice
常用命令与效果如下:
~$ rosrun turtlesim turtlesim_node
~$ rosrun turtlesim
draw_square mimic turtlesim_node turtle_teleop_key
~$ rosservice list
~$ rosservice type clear
~$ rosservice type turtle1/teleport_absolute
turtlesim/TeleportAbsolute
~$ rosservice call clear
~$ rosservice type spawn| rossrv show
float32 x
float32 y
float32 theta
string name
---
string name
~$ rosservice call spawn 2 2 0.2 "kinetic"
name: kinetic
2 rosparam
~$ rosparam list
/background_b
/background_g
/background_r
/rosdistro
/roslaunch/uris/host_relaybot_desktop__45411
/rosversion
/run_id
~$ rosparam set background_r 150
~$ rosservice call clear
~$ rosparam get background_g
86
~$ rosparam get /
background_b: 255
background_g: 86
background_r: 150
rosdistro: 'kinetic
'
roslaunch:
uris: {host_relaybot_desktop__45411: 'http://relaybot-desktop:45411/'}
rosversion: '1.12.0
'
run_id: 3e885be8-18bd-11e6-92a6-70f1a1ca7552
~$ rosparam dump params.yaml
~$ rosparam load params.yaml copy
~$ rosparam get copy/background_b
255
2 rqt_console rqt_logger_level 和 roslaunch
官方教程:http://wiki.ros.org/cn/ROS/Tutorials/UsingRqtconsoleRoslaunch
1 rqt_console和rqt_logger_level
~$ rosrun rqt_console rqt_console
~$ rosrun rqt_logger_level rqt_logger_level
~$ rostopic pub /turtle1/cmd_vel geometry_msgs/Twistr 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, 0.0]'
2 roslaunch
~$ roscd hello_kinetic
~/catkin_ws/src/hello_kinetic$ mkdir launch
~/catkin_ws/src/hello_kinetic$ cd launch
~/catkin_ws/src/hello_kinetic/launch$ gedit
----
1 <launch>
2
3 <group ns="turtlesim1">
4 <node pkg="turtlesim" name="sim" type="turtlesim_node"/>
5 </group>
6
7 <group ns="turtlesim2">
8 <node pkg="turtlesim" name="sim" type="turtlesim_node"/>
9 </group>
10
11 <node pkg="turtlesim" name="mimic" type="mimic">
12 <remap from="input" to="turtlesim1/turtle1"/>
13 <remap from="output" to="turtlesim2/turtle1"/>
14 </node>
15
16 </launch>
----
~$ roslaunch hello_kinetic turtlemimic.launch
~$ rostopic pub /turtlesim1/turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[3.0, 0.0, 0.0]' '[0.0, 0.0, -1.0]'
~$ rqt
~$ rqt_graph
-End-