Ask Your Question
0

URDF + RVIZ , RobotModel Not showing correctly

asked 2018-02-03 13:52:46 -0500

MechLc gravatar image

Hi, I am trying to simulate a car on RVIZ only using URDF and Launch file and seems to not be working. The wheels are in the middle of robot which makes no sense because when I view on on a URDF online view it displays it correctly. Been struggling for awhile now. Any help will be much appreciated. Thanks!

Online URDF viewer: image description

RVIZ:

image description

URDF Code:

<?xml version='1.0'?>
<robot name="fourwheelrobot">
  <!-- Base link -->
  <link name="base_link">
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
          <box size="1 0.5 0.25"/>
      </geometry>
      <material name="yellow">
        <color rgba="0.8 0.8 0 1"/>
      </material>
    </visual>
  </link>
  <!-- Front Right Wheel -->
  <link name="f_r_wheel">
    <visual>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
      <material name="black">
        <color rgba="0.05 0.05 0.05 1"/>
      </material>
    </visual>
  </link>
  <joint name="joint_f_r_wheel" type="continuous">
    <parent link="base_link"/>
    <child link="f_r_wheel"/>
    <origin xyz="0.25 -0.30 0" rpy="0 0 0" /> 
    <axis xyz="0 1 0" rpy="0 0 0" />
  </joint>  
  <!-- Back Right Wheel -->
  <link name="b_r_wheel">
    <visual>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
      <material name="black"/>
    </visual>
  </link>
  <joint name="joint_b_r_wheel" type="continuous">
    <parent link="base_link"/>
    <child link="b_r_wheel"/>
    <origin xyz="-0.25 -0.30 0" rpy="0 0 0" /> 
    <axis xyz="0 1 0" rpy="0 0 0" />
  </joint>  
  <!-- Front Left Wheel -->
  <link name="f_l_wheel">
    <visual>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
      <material name="black"/>
    </visual>
  </link>
  <joint name="joint_f_l_wheel" type="continuous">
    <parent link="base_link"/>
    <child link="f_l_wheel"/>
    <origin xyz="0.25 0.30 0" rpy="0 0 0" /> 
    <axis xyz="0 1 0" rpy="0 0 0" />
  </joint>
  <!-- Back Left Wheel -->
  <link name="b_l_wheel">
    <visual>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
      <material name="black"/>
    </visual>
  </link>
  <joint name="joint_b_l_wheel" type="continuous">
    <parent link="base_link"/>
    <child link="b_l_wheel"/>
    <origin xyz="-0.25 0.30 0" rpy="0 0 0" /> 
    <axis xyz="0 1 0" rpy="0 0 0" />
  </joint>

Launch File:

<launch>
  <param name="robot_description" textfile="$(find ros_robotics)/urdf/lauroRobot.urdf" />

   <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
   <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
   <node name="rviz" pkg="rviz" type="rviz" required="true" />
</launch>
</robot>
edit retag flag offensive close merge delete

Comments

Works fine on my computer (once I moved the end robot tag from the launch file to the urdf). Is there any terminal output?

David Lu gravatar image David Lu  ( 2018-02-05 07:55:22 -0500 )edit

were you able to solve your problem? how?

shiraz_baig gravatar image shiraz_baig  ( 2020-11-13 07:41:35 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2020-11-18 23:50:06 -0500

shiraz_baig gravatar image

This is how I, successfully, displayed your model on my computer(using rosdistro melodic).
a. I copy-pasted your urdf file in a file named "fourwheel.urdf" and placed it in a folder catkin_ws/src/own_urdf/urdf. I also added a tag "< /robot>" in the end.
b. I also copy-pasted your launch file in the launch folder of under "own_urdf" folder. I made following changes in your launch file.
   1) In first line changed pkgname and filename to as per my pkgname and urdf-file
   2) In 2nd line changed type and pkg to "joint_state_publisher_gui" (If you do not have this pkg, u can install it.)
   3) In third line changed type to "robot_state_publisher" instead of "state_publisher".
c. I ran the command "roslaunch own_urdf <yourlaunchfile>". A blank rviz window and a GUI for joint_state_publisher appeared.
d. In rviz window I changed the fixed_frame to "base_link" through drop-down arrow.
e. In the rviz window, I clicked "Add" to add the RobotModel and TF.
The robot model is now displaying correctly. If I move sliders on GUI window, the wheels in model in rviz window will appear to be turning. Since joint_f_l_wheel and joint_b_l_wheel are in front, you can see them better. You can zoom-in the model to see this movement more clearly. However, your robot will not move. Perhaps you need to add "transmission" to move the robot as a whole.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-02-03 13:52:46 -0500

Seen: 709 times

Last updated: Nov 18 '20