rviz中添加kinect2的模型

1 编译报错

Not enough blocks
XacroException('Not enough blocks',)
when instantiating macro: kinect2_xacro (/home/cbc/catkin_ws/src/iai_robots/iai_kinect2_description/urdf/kinect2.urdf.xacro)
in file: /home/cbc/catkin_ws/src/iai_robots/iai_kinect2_description/urdf/kinect2_camera.urdf.xacro
Invalid <param> tag: Cannot load command parameter [robot_descriptio]: command [/opt/ros/kinetic/lib/xacro/xacro '--inorder' '/home/cbc/catkin_ws/src/iai_robots/iai_kinect2_description/urdf/kinect2_camera.urdf.xacro'] returned with code [2]. 

Param xml is <param command="$(find xacro)/xacro '--inorder' '$(find iai_kinect2_description)/urdf/kinect2_camera.urdf.xacro'" name="robot_descriptio"/>
The traceback for the exception was written to the log file

解决方法:

<xacro:macro name="kinect2_xacro" params="prefix parent *origin">
<joint name="${prefix}_kinect2_in_joint" type="fixed">
      <xacro:insert_block name="origin"/>      
      <parent link="${parent}"/>
      <child link="${prefix}_kinect2_rgb_optical_frame"/>      
joint>

变成

<xacro:macro name="kinect2_xacro" params="prefix parent">
<joint name="${prefix}_kinect2_in_joint" type="fixed">
            
      <parent link="${parent}"/>
      <child link="${prefix}_kinect2_rgb_optical_frame"/>
      <origin xyz="0 0 0" rpy="0 0 0"/>
joint>

2 rviz报错

No transform from [camera_link] to [world]
No transform from [simple_kinect2_rgb_optical_frame] to [world]

发现rviz能识别自定义的camera_link,world以及kinect2_rgb_frmae(urdf里面定义的),但是不能获取frame与frame之间的变换关系(TF显示不出frame的信息),我在想应该少了一个joint_states发布器,于是在launch中包含下面的节点:

"robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />

出现新的报错

[ERROR] [1515745229.530419356]: Could not find parameter robot_description on parameter server

解决方法:

<param name="robot_description" command="$(find xacro)/xacro '--inorder' '$(find iai_kinect2_description)/urdf/kinect2_camera.urdf.xacro'" />//param name一定要命名为robot_description

3添加ir与rgb的相机外参

<joint name="kinect2_rgb_joint" type="fixed">
      <origin xyz="-0.0520171521241 -0.000240451181123 0.000294544694029" rpy="0.00178209349915 -0.000222819786098 -0.00114226514527"/>
      <parent link="${prefix}_kinect2_rgb_optical_frame"/>
      <child link="${prefix}_kinect2_ir_optical_frame"/>
    joint>

4 参考

1iai_kinect2_description
2Add a convert script from calib_pose.yaml to urdf format
3Frame Transforms
4kinect2_link Location on Device

你可能感兴趣的:(机器视觉)