rbx1下的一些实现探索
启动仿真机器人节点
启动文件fake_turtlebot.launch内容如下
<launch>
<param name="/use_sim_time" value="false" />
<!-- Load the URDF/Xacro model of our robot -->
<arg name="urdf_file" default="$(find xacro)/xacro.py '$(find rbx1_description)/urdf/turtlebot.urdf.xacro'" />
<param name="robot_description" command="$(arg urdf_file)" />
<node name="arbotix" pkg="arbotix_python" type="arbotix_driver" output="screen" clear_params="true">
<rosparam file="$(find rbx1_bringup)/config/fake_turtlebot_arbotix.yaml" command="load" />
<param name="sim" value="true"/>
</node>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher">
<param name="publish_frequency" type="double" value="20.0" />
</node>
</launch>
工作总结:
一、在参数服务器内记录一条能够找到机器人结构描述的命令,并存储在参数服务器当中的/robot_description参数下面。该命令基于xacro包下的xacro.py实现,会读入我们定义好的一个xacro文件。
参数服务器的命令:
rosparam list 查看所有参数
rosparam get some_param 获取参数值
rosparam set some_param 设置参数值
xacro是什么:
Xacro (XML Macros) Xacro is an XML macro language. With xacro, you can construct shorter and more readable XML files by using macros that expand to larger XML expressions.
总而言之,就是读取一个扩展的XML文件,获取机器人描述信息。
二、启动arbotix_python包下的arbotix_driver节点,它的作用是:
The arbotix_python package provides a basic ROS interface to an ArbotiX RoboController over a USB serial connection, or XBEE wireless radios.This package consists of three tools: the driver, a GUI for interacting with the driver, and a terminal tool for setting up your servos.
也就是说,这个包是用来驱动机器人的。。。好像比较底层的样子。
它需要的参数是一个.yaml的配置文件,配置文件的内容是比较底层的东西,包括波特率、使用的串口、控制器等等,具体参考http://wiki.ros.org/arbotix_python
同时,这里还配置了一个sim=true的参数,应该是为了设置仿真,就不和实际的串口进行交互,开启自娱自乐的模式,话说上面的链接居然找不到这个参数的信息==
三、最后启动一个叫作robot_state_publisher的东西,它就是用来发布tf的,描述如下:
robot_state_publisher uses the URDF specified by the parameter robot_description and the joint positions from the topic joint_states to calculate the forward kinematics of the robot and publish the results via tf.
也就是说,第一部读的东西不是放着好康的,是用于发布机器人各个部件间的tf用的!利用的就是在第一步中读取的.xarco文件。
具体参考http://wiki.ros.org/robot_state_publisher
所以这个launch文件就是,假装有一个Arbotix,然后发布它的tf变换出来。
启动路径规划move_base
源文件是fake_move_base.launch,其内容很简单:
<launch>
<node pkg="move_base" type="move_base" respawn="false" name="move_base" output="screen" clear_params="true">
<rosparam file="$(find rbx1_nav)/config/fake/costmap_common_params.yaml" command="load" ns="global_costmap" />
<rosparam file="$(find rbx1_nav)/config/fake/costmap_common_params.yaml" command="load" ns="local_costmap" />
<rosparam file="$(find rbx1_nav)/config/fake/local_costmap_params.yaml" command="load" />
<rosparam file="$(find rbx1_nav)/config/fake/global_costmap_params.yaml" command="load" />
<rosparam file="$(find rbx1_nav)/config/fake/base_local_planner_params.yaml" command="load" />
</node>
</launch>
就是自己配好了一些参数,然后启动move_base节点就是了。
不过参数有点多,保存了足足4个yaml文件。
这里有一些move_base参数的学习,以及api的应用:https://blog.csdn.net/u010925447/article/details/81294401
仿真下的定位
源文件是-没有,虽然带了一个fake的名字,但其实是官方自带的ros pkg,介绍如下:
The fake_localization package provides a single node, fake_localization, which substitutes for a localization system, providing a subset of the ROS API used by amcl. This node is most frequently used during simulation as a method to provide perfect localization in a computationally inexpensive manner. Specifically, fake_localization converts odometry data into pose, particle cloud, and transform data of the form published by amcl.
在rbx1包下fake_nav_test.launch下的使用是:
<!-- Run fake localization compatible with AMCL output -->
<node pkg="fake_localization" type="fake_localization" name="fake_localization" clear_params="true" output="screen">
<remap from="base_pose_ground_truth" to="odom" />
<param name="global_frame_id" value="map" />
<param name="base_frame_id" value="base_footprint" />
</node>
就是调用这个包,然后:
- 将base_pose_ground_truth话题映射到odom下面。
- 将世界坐标系改成map
- 将机器人坐标系改成base_footprint
它订阅的节点是:base_pose_ground_truth(The position of the robot as published by a simulator), initialpose
它发布的节点是:amcl_pose(但其实没有做amcl,后面的说明是Just passes through the pose reported by a simulator.)和particlecloud(用于可是化的)
简单来说,就是一个用于仿真玩的定位,实际上根本没有定位,就是直接传递仿真给的数据。
更多内容参考http://wiki.ros.org/fake_localization
RVIZ结尾文件
.rviz就是rviz下的配置文件,可能涉及到要订阅哪些话题之类的,以便做相应的可视化,随便找个读读然后自己配也行,和具体的Coding关联不大。

浙公网安备 33010602011771号