根据同一urdf加载多个模型到rviz

问题描述

根据单个urdf模型加载多个相同的模型到rviz中

主要利用launch的group标签和robot_state_publisher的tf_prefix标签。

基础

joint_state_publisher_gui发布joint_states话题,该话题被robot_state_publisher进行订阅(该订阅的话题名可以通过remap标签进行重映射),然后计算出模型各个关节之间的坐标变换,即tf

launch的group ns标签会将所有在该group内的结点及其话题(收发)封装在对应的ns(命名空间)中

robot_state_publisher的tf_prefix标签会在robot_state_publisher发布的tf坐标信息之前加上相应的tf_prefix

实现

<launch>
  <group ns="jaka1">
    <param name="robot_description" textfile="urdf/jaka_zu7_1200.xml" />
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" >
        <param name="tf_prefix" value="jaka1" />
<!--        <remap from="/joint_states" to="/robot_driver/joint_states"/>-->
    </node>
      <node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" />
  </group>

  <group ns="jaka2">
    <param name="robot_description" textfile="urdf/jaka_zu7_1200.xml" />
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" >
        <param name="tf_prefix" value="jaka2" />
    </node>
      <node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" />
  </group>

  <node pkg="tf" type="static_transform_publisher" name="T_world_jaka1"
    args="0 0 0 0  0  0 /world /jaka1/base_link 100" />

  <node pkg="tf" type="static_transform_publisher" name="T_world_jaka2"
    args="0 1.0 0 0  0  0 /world /jaka2/base_link 100" />

  <node name="rviz" pkg="rviz" type="rviz" args="-d dual_jaka.rviz" />
</launch>

上述launch执行后上传的参数及启动的结点如下

PARAMETERS
 * /jaka1/robot_description: <?xml version="1....
 * /jaka1/robot_state_publisher/tf_prefix: jaka1
 * /jaka2/robot_description: <?xml version="1....
 * /jaka2/robot_state_publisher/tf_prefix: jaka2
 * /rosdistro: melodic
 * /rosversion: 1.14.13

NODES
  /
    T_world_jaka1 (tf/static_transform_publisher)
    T_world_jaka2 (tf/static_transform_publisher)
    rviz (rviz/rviz)
  /jaka1/
    joint_state_publisher_gui (joint_state_publisher_gui/joint_state_publisher_gui)
    robot_state_publisher (robot_state_publisher/robot_state_publisher)
  /jaka2/
    joint_state_publisher_gui (joint_state_publisher_gui/joint_state_publisher_gui)
    robot_state_publisher (robot_state_publisher/robot_state_publisher)

根据上述的参数及结点信息,很容易判断group ns标签的作用

rviz配置

添加RobotModel,修改对应的Robot description和tf prefix
结果如下图
rviz result

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值