qboticslabs / mastering_ros

This repository contains exercise files of the book "Mastering ROS for Robotics Programming"
https://www.packtpub.com/hardware-and-creative/mastering-ros-robotics-programming
468 stars 282 forks source link

[Chapter 2] - RViz transform error #9

Closed marcoarruda closed 7 years ago

marcoarruda commented 7 years ago

Hello,

Following the book, on chapter 2, page 69. Running the command $ roslaunch mastering_ros_robot_description_pkg view_demo.launch

RViz starts like the image below rsz_screenshot_from_2016-09-02_204851

Would be this a RViz configuration file problem?

Thanks

qboticslabs commented 7 years ago

Hi @marcoarruda

Sorry for the trouble!! Can you send the terminal screenshot, or a screencast of the error.. Also ROS version and Ubuntu version. You can send to my mail id : qboticslabs@gmail.com

myyerrol commented 7 years ago

Hi @marcoarruda

I know your problem. Please open the view_demo.launch and observe whether there have a line about . If don't have, please add it, and it can solve your problem. Because robot_state_publisher publish joint's tf to rviz by receiving datas from joint_state_publisher, if you don't run robot_state_publisher node, rviz can display transform error.

Last, I think your codes are out of date. At least I don't find view_demo.launch in launch directory. In the latest code, you can use follow command to run rviz, and it has no error.

$> roslaunch mastering_ros_robot_description_pkg view_pan_tilt_urdf.launch

screenshot from 2016-09-04 21 01 04

marcoarruda commented 7 years ago

@qboticslabs, thank you for the attention. My linux version is 14.04.03, ROS distro is Indigo.

Thanks @myyerrol, but my launch file already had this line. I've found the view_demo.urdf file, but it is longer than page 65 of the book.

I've created the package from the scratch, so it was missing urdf.rviz and urdf.vcg files. And I've changed the pan_tilt.urdf file. I had to add tag for both joints. Now it works.

My pan_tilt.urdf file is as below:

<?xml version="1.0"?>
<robot name="pan_tilt">
  <link name="base_link">
    <visual>
      <geometry>
        <cylinder length="0.01" radius="0.2"/>
      </geometry>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <material name="yellow">
        <color rgba="1 1 0 1"/>
      </material>
    </visual>
  </link>
  <joint name="pan_joint" type="revolute">
    <parent link="base_link"/>
    <child link="pan_link"/>
    <origin xyz="0 0 0.1"/>
    <axis xyz="0 0 1" />
    <limit effort="300" velocity="0.1" lower="-3.14" upper="3.14"/>
  </joint>
  <link name="pan_link">
    <visual>
      <geometry>
        <cylinder length="0.4" radius="0.04"/>
      </geometry>
      <origin rpy="0 0 0" xyz="0 0 0.09"/>
      <material name="red">
        <color rgba="0 0 1 1"/>
      </material>
    </visual>
  </link>
  <joint name="tilt_joint" type="revolute">
    <parent link="pan_link"/>
    <child link="tilt_link"/>
    <origin xyz="0 0 0.2"/>
    <axis xyz="0 1 0" />
    <limit effort="300" velocity="0.1" lower="-3.14" upper="3.14"/>
  </joint>
  <link name="tilt_link">
    <visual>
      <geometry>
        <cylinder length="0.4" radius="0.04"/>
      </geometry>
      <origin rpy="0 1.5 0" xyz="0 0 0"/>
      <material name="green">
        <color rgba="1 0 0 1"/>
      </material>
    </visual>
  </link>
</robot>