Gazebo | Ignition | Community
Ask Your Question
0

Why can't my UDFR be like my SDF in rviz? (REALLY LONG POST)

asked 2021-08-13 14:35:42 -0500

kakcalu13 gravatar image

So, basically...I learned that ROS2 foxy does not support SDF with plugins and ROS2. So, I had to re-update one for URDF instead of SDF. I made SDF enitrely from Gazebo11.

So, the question is why can't I put wheels on the box? Take a look at this URDF code:

<?xml version="1.0"?>
<robot name="my_robot" xmlns:xacro="http://ros.org/wiki/xacro">

  <!-- Define robot constants -->
  <xacro:property name="base_width" value="0.2159"/>
  <xacro:property name="base_length" value="0.1524"/>
  <xacro:property name="base_height" value="0.10795"/>

  <xacro:property name="wheel_radius" value="0.0325"/>
  <xacro:property name="wheel_width" value="0.02"/>
  <xacro:property name="wheel_ygap" value="0.088"/>
  <xacro:property name="wheel_zoff" value="0.05"/>
  <xacro:property name="wheel_xoff" value="0.1"/>

  <xacro:property name="caster_xoff" value="0.14"/>

 <!-- Robot Base -->
  <link name="base_link">
    <visual>
      <geometry>
    <box size="0.2159 0.1524 0.10795"/>
      </geometry>
      <material name="Cyan">
    <color rgba="0 1.0 1.0 1.0"/>
      </material>
    </visual>
  </link>

  <!-- Robot Footprint -->
  <link name="base_footprint"/>

  <joint name="base_joint" type="fixed">
    <parent link="base_link"/>
    <child link="base_footprint"/>
    <origin xyz="0.0 0.0 ${-(wheel_radius+wheel_zoff)}" rpy="0 0 0"/>
  </joint>

    <!-- Wheels -->
  <xacro:macro name="wheel" params="prefix x_reflect y_reflect">
    <link name="${prefix}_link">
      <visual>
    <origin xyz="0 0 0" rpy="${pi/2} 0 0"/>
    <geometry>
        <cylinder radius="${wheel_radius}" length="${wheel_width}"/>
    </geometry>
    <material name="Gray">
      <color rgba="0.5 0.5 0.5 1.0"/>
    </material>
      </visual>
    </link>


    <joint name="${prefix}_joint" type="continuous">
      <parent link="base_link"/>
      <child link="${prefix}_link"/>
      <origin xyz="${x_reflect*wheel_xoff} ${y_reflect*(base_width/6+wheel_ygap)} ${-wheel_zoff}" rpy="0 0 0"/>
      <axis xyz="0 1 0"/>
    </joint>
  </xacro:macro>

  <xacro:wheel prefix="drivewhl_rl" x_reflect="-1" y_reflect="1" />
  <xacro:wheel prefix="drivewhl_rr" x_reflect="-1" y_reflect="-1" />
  <xacro:wheel prefix="drivewhl_fl" x_reflect="1" y_reflect="1" />
  <xacro:wheel prefix="drivewhl_fr" x_reflect="1" y_reflect="-1" /> 



</robot>

The model look like this

As for my SDF code and picture like this:

        <link name='chassis'>
        <pose>0 0 .1 0 0 0</pose>
        <inertial>
        <inertia>
        <ixx>1.000000</ixx>
        <ixy>0.000000</ixy>
        <ixz>0.000000</ixz>
        <iyy>1.000000</iyy>
        <iyz>0.000000</iyz>
        <izz>1.000000</izz>
        </inertia>
        <mass>1</mass>
        </inertial>
        <collision name='collision'>
          <geometry>
            <box>
              <size>0.2159 0.1524 0.10795</size>
            </box>
          </geometry>
        </collision>

        <visual name='visual'>
          <geometry>
            <box>
              <size>0.2159 0.1524 0.10795</size>
            </box>
          </geometry>
        </visual>
      </link>

    <link name="front_left_wheel">
    <pose>0.1 0.088 0.05 0 1.5707 1.5707</pose>
    <mass>0.75</mass>
    <collision name="collision">
      <geometry>
        <cylinder>
          <radius>0.0325</radius>
          <length>.02</length>
        </cylinder>
      </geometry>
    </collision>
    <visual name="visual">
      <geometry>
        <cylinder>
          <radius>0.0325</radius>
          <length>.02</length>
        </cylinder>
      </geometry>
    <surface>
          <friction>
            <ode>
              <mu>10</mu>
              <mu2>10</mu2>
            <slip1>0.000000</slip1>
            <slip2>0.000000</slip2>
            </ode>
          </friction>
        </surface>
    </visual>
      </link>

    <link name="front_right_wheel">
    <pose>0.1 -0.088 0.05 0 1.5707 1.5707</pose>
    <mass>0.75</mass>
    <collision name="collision">
      <geometry>
        <cylinder>
          <radius>0.0325</radius>
          <length>.02</length>
        </cylinder>
      </geometry ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-08-17 18:38:26 -0500

kakcalu13 gravatar image

y_wheel = y_reflect * (base_length/2 + wheel_width/2)

solved the problem.

It was wrong formula due to y_reflect*(base_width/6+wheel_ygap)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2021-08-13 14:35:42 -0500

Seen: 33 times

Last updated: Aug 17