ROS1云课→14可视化交互
之前介绍中所涉及的二维三维可视化和交互,如果对应实际传感器,那么需要更多信息。
- 传感器发布频率
- 传感器时延
- 传感器固定在机器人上的位置和姿态
- ……
其中,第三点和坐标系密切相关了。
主题与坐标系的关系
如果数据从真实世界中一个物理位置的特定传感器数据发布,主题必须有一个坐标系。例如,相对于机器人底盘的位置上有一个激光传感器(通常在轮式机器人两个轮子的轮轴中间)。如果需要用激光扫描数据去检测环境中障碍物或者构建地图,就必须对激光传感器和底盘所在的位置进行坐标转换。在ROS系统中,带有报文头的消息除了具有时间戳(在不同的消息间进行数据同步非常重要)之外,还要附上frame_id(坐标系标签)。坐标系标签用于区分消息所属的坐标系。
坐标系自身并没有意义,需要的是它们之间的坐标变换。实际上,机器人的tf坐标变换树都会有一个base_link作为根坐标系(或是地图,如果运行导航包的话)。这样,就能够在rqt_tf_tree中通过对比根坐标系和其他坐标系查看机器人相对于真实世界坐标系的运动。
启动如下stdr环境:
roslaunch stdr_launchers server_with_map_and_gui_plus_robot.launch
机器人特写:
rosrun rqt_tf_tree rqt_tf_tree
对应:
而对于现在的示例,只需要知道它们能够在某个坐标系内进行计算从一个坐标系变换到另外一个坐标系,而且包含时间延迟即可。还需要了解tf在系统中会以某个特定的频率进行发布,这样它就会像子系统一样允许遍历坐标变换树以获取其中任意两个坐标系之间的转换,并且可以在系统的任意节点中通过调用tf进行变换。
在rviz中查看一下:
代码语言:javascript复制 roslaunch stdr_launchers server_with_map_and_gui_plus_robot.launch
... logging to /home/shiyanlou/.ros/log/dac41a72-29f7-11ed-9d7c-0242ac110007/roslaunch-6310afb5667ca969528f210f-301.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://6310afb5667ca969528f210f:44463/
SUMMARY
========
PARAMETERS
* /rosdistro: kinetic
* /rosversion: 1.12.14
NODES
/
robot_manager (nodelet/nodelet)
robot_spawn_6310afb5667ca969528f210f_301_673361009853165653 (stdr_robot/robot_handler)
stdr_gui_node_6310afb5667ca969528f210f_301_6214498739113013351 (stdr_gui/stdr_gui_node)
stdr_server (stdr_server/stdr_server_node)
world2map (tf/static_transform_publisher)
auto-starting new master
process[master]: started with pid [311]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to dac41a72-29f7-11ed-9d7c-0242ac110007
process[rosout-1]: started with pid [324]
started core service [/rosout]
process[robot_manager-2]: started with pid [327]
process[stdr_server-3]: started with pid [328]
process[world2map-4]: started with pid [329]
process[stdr_gui_node_6310afb5667ca969528f210f_301_6214498739113013351-5]: started with pid [330]
process[robot_spawn_6310afb5667ca969528f210f_301_673361009853165653-6]: started with pid [340]
[ INFO] [1662038003.277267214]: Loading map from image "/opt/ros/kinetic/share/stdr_resources/maps/sparse_obstacles.png"
[ INFO] [1662038003.365821274]: Read a 775 X 746 map @ 0.020 m/cell
[robot_spawn_6310afb5667ca969528f210f_301_673361009853165653-6] process has finished cleanly
log file: /home/shiyanlou/.ros/log/dac41a72-29f7-11ed-9d7c-0242ac110007/robot_spawn_6310afb5667ca969528f210f_301_673361009853165653-6*.log
[ WARN] [1662040231.980856267]: Map already loaded!
[ERROR] [1662040231.981109167]: Could not load map, maybe already loaded...
查看sonar数据:
<launch> <include file=" <node pkg="tf" type="static_transform_publisher" name="world2map" args="0 0 0 0 0 0 world map 100" /> <include file=" </launch>