0
$\begingroup$

Rosanswers logo

hi, i'm trying to add wheels to base link on rviz, but i can't solve that error RobotModel/StatusError/No transform from [front_left_wheel] to [base_link]

In terminal there is an error too: [ERROR] [1650399488.022787755]: length [{wheel_height}] is not a valid float [ERROR] [1650399488.022818574]: Could not parse visual element for Link [front_right_wheel] [ERROR] [1650399488.022856764]: length [{wheel_height}] is not a valid float [ERROR] [1650399488.022870671]: Could not parse visual element for Link [front_left_wheel]

i wrote codes from github/qboticslabs/qboticslabs_website (In my launch, state_publisher is written)

dif_robot.xacro

<xacro:include filename="$(find pan_tilt)/urdf/wheel.xacro" />


<!-- renk tanımlama -->
<material name="Black">
    <color rgba="0.0 0.0 0.0 1.0"/>
</material>   
<material name="White">
    <color rgba="1.0 1.0 1.0 1.0"/>
</material> 
<material name="Red">
    <color rgba="0.8 0.0 0.0 1.0"/>
</material> 
<material name="Blue">
    <color rgba="0.0 0.0 1.0 1.0"/>
</material> 

<property name="M_PI" value="3.1415926535897931" />
<property name="M_PI_2" value="1.570796327" />
<property name="DEG_TO_RAD" value="0.017453293" />

<property name="base_height" value="0.02" />
<property name="base_radius" value="0.15" />
<property name="base_mass" value="5" />

<property name="caster_f_height" value="0.04" />
<property name="caster_f_radius" value="0.025" />
<property name="caster_f_mass" value="0.5" />

<property name="caster_b_height" value="0.04" />
<property name="caster_b_radius" value="0.025" />
<property name="caster_b_mass" value="0.5" />

<property name="wheel_mass" value="2.5" />

<property name="base_x_origin_to_wheel_origin" value="0.25" />
<property name="base_y_origin_to_wheel_origin" value="0.3" />
<property name="base_z_origin_to_wheel_origin" value="0.0" />

<property name="hokuyo_size" value="0.05" />

<macro name="cylinder_inertia" params="m r h">
<inertia ixx="${m*(3*r*r+h*h)/12}" ixy="0.0" ixz="0.0" 
iyy="${m*(3*r*r+h*h)/12}" iyz="0.0"
izz="${m*r*r/2}"/>
</macro>

<!--base_footprint-->
<link name="base_footprint">
    <inertial>
        <origin xyz="0.0 0.0 0.0"/>
        <mass value="0.0001"/>
        <inertia ixx="0.0001" ixy="0.0" ixz="0.0"
        iyy="0.0001" iyz="0.0" 
        izz="0.0001"/>
    </inertial>
    <visual>
        <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
        <geometry>
            <box size="0.001 0.001 0.001"/>
        </geometry>
    </visual>
</link>

<gazebo reference="base_footprint">
    <turnGravityOff>false</turnGravityOff>
</gazebo>

<joint name="base_footprint_joint" type="fixed">
    <origin xyz="0.0 0.0 ${wheel_radius - base_z_origin_to_wheel_origin}" rpy="0.0 0.0 0.0"/>
    <parent link="base_footprint"/>
    <child link="base_link"/>
</joint>

<!-- base link -->
<link name="base_link">
    <inertial>
        <origin xyz="0.0 0.0 0.0"/>
        <mass value="${base_mass}"/>
        <cylinder_inertia m="${base_mass}" r="${base_radius}" h="${base_height}"/>
    </inertial>

    <visual>
        <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
        <geometry>
            <cylinder length="${base_height}" radius="${base_radius}"/>
        </geometry>
        <material name="White"/>
    </visual>
    
    <collision>
        <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
        <geometry>
            <cylinder length="${base_height}" radius="${base_radius}"/>
        </geometry>
    </collision>
</link>

<gazebo reference="base_link">
    <material> Gazebo/White</material>
    <turnGravityOff>false</turnGravityOff>
</gazebo>

<!--caster front-->
<link name="caster_front_link">
    <inertial>
        <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
        <mass value="${caster_f_mass}"/>
        <inertia 
            ixx="0.001" ixy="0.0" ixz="0.0"
            iyy="0.001" iyz="0.0" 
            izz="0.001"/>
    </inertial>
    <visual>
        <origin xyz="0.0 0.02 0.0" rpy="${M_PI/2} 0.0 0.0"/>
        <geometry>
            <sphere radius="${caster_f_radius}"/>
        </geometry>
        <material name="Black"/>
    </visual>
    <collision>
        <origin xyz="0.0 0.02 0.0" rpy="${M_PI/2} 0.0 0.0"/>
        <geometry>
            <sphere radius="${caster_f_radius}"/>
        </geometry>
    </collision>
</link>

<joint name="caster_front_joint" type="fixed">
    <origin xyz="0.115 0.0 0.007" rpy="${-M_PI/2} 0.0 0.0"/>
    <parent link="base_link"/>
    <child link="caster_front_link"/>
</joint>

<gazebo reference="caster_front_joint">
    <turnGravityOff>false</turnGravityOff>
</gazebo>

<!--caster back-->
<link name="caster_back_link">
    <inertial>
        <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
        <mass value="${caster_b_mass}"/>
        <inertia 
            ixx="0.001" ixy="0.0" ixz="0.0"
            iyy="0.001" iyz="0.0" 
            izz="0.001"/>
    </inertial>
    <visual>
        <origin xyz="0.02 0.02 0.0" rpy="${M_PI/2} 0.0 0.0"/>
        <geometry>
            <sphere radius="${caster_b_radius}"/>
        </geometry>
        <material name="Black"/>
    </visual>
    <collision>
        <origin xyz="0.0 0.02 0.0" rpy="${M_PI/2} 0.0 0.0"/>
        <geometry>
            <sphere radius="${caster_b_radius}"/>
        </geometry>
    </collision>
</link>

<joint name="caster_back_joint" type="fixed">
    <origin xyz="-0.135 0.0 0.009" rpy="${-M_PI/2} 0.0 0.0"/>
    <parent link="base_link"/>
    <child link="caster_back_link"/>
</joint>

<gazebo reference="caster_back_link">
    <turnGravityOff>false</turnGravityOff>
</gazebo>

<wheel fb="front" lr="right" parent="base_link" translateX="0.0" translateY="0.5" flipY="1" />
<wheel fb="front" lr="left" parent="base_link" translateX="0.0" translateY="-0.5" flipY="1" />

##wheel.xacro##

<property name="wheel_height" value="0.02" />
<property name="wheel_radius" value="0.04" />
<property name="wheel_mass" value="2.5" />

<property name="base_x_origin_to_wheel_origin" value="0.25" />
<property name="base_y_origin_to_wheel_origin" value="0.3" />
<property name="base_z_origin_to_wheel_origin" value="0.0" />

<macro name="cylinder_inertia" params="m r h">
<inertia ixx="${m*(3*r*r+h*h)/12}" ixy="0.0" ixz="0.0" 
iyy="${m*(3*r*r+h*h)/12}" iyz="0.0"
izz="${m*r*r/2}"/>
</macro>

<xacro:macro name="wheel" params="fb lr parent translateX translateY flipY"> <!-- fb: front back  lr: left right-->
    <link name ="${fb}_${lr}_wheel">
        <visual> 
            <origin xyz="0.0 0.0 0.0" rpy="${flipY*M_PI/2} 0.0 0.0" />
            <geometry>
                <cylinder length="{wheel_height}" radius="${wheel_radius}" />   
            </geometry>
            <material name="Black" />
        </visual>

        <collision>
            <origin xyz="0.0 0.0 0.0" rpy="${flipY*M_PI/2} 0.0 0.0"/>
            <geometry>
                <cylinder length="{wheel_height}" radius="${wheel_radius}" />   
            </geometry>
        </collision>

        <inertial>
            <origin xyz="0.0 0.0 0.0"/>
            <mass value="${wheel_mass}" />
            <cylinder_inertia m="${wheel_mass}" r="${wheel_radius}" h="${wheel_height}"/>
        </inertial>
    </link>

    <gazebo reference="${fb}_${lr}_wheel">
        <mu1 value="1.0"/>
        <mu2 value="1.0"/>
        <kp  value="10000000.0" />
        <kd  value="1.0" />
        <fdir1 value="1 0 0"/>  <!--x ekseni boyunca gideceği için-->
        <material>Gazebo/Red</material>
        <turnGravityOff>false</turnGravityOff>
    </gazebo>

    <joint name="${fb}_${lr}_wheel_joint" type="continuous">
        <origin xyz="${translateX * base_x_origin_to_wheel_origin} ${translateY * base_y_origin_to_wheel_origin} ${base_z_origin_to_wheel_origin}" rpy="0.0 0.0 0.0"/>
        <parent link="${parent}"/>
        <child link="${fb}_${lr}_wheel"/>
        <axis xyz="0.0 1.0 0.0" rpy="0  0"/> <!-- y'de döeneceği için sadece y'yi serbest bıraktık-->
        <limit effort="100.0" velocity="100.0"/>
        <joint_properties damping="0.0" friction="0.0" /> <!--damping:sönümleme katsayısı   friction:sürtünme-->
    </joint>

    <transmission name="${fb}_${lr}_wheel_joint_trans">
        <type>transmission_interface/SimpleTransmission</type>
        <joint name="${fb}_${lr}_wheel_joint" />
        <actuator name="${fb}_${lr}_wheel_joint_motor">
            <hardwareInterface>EffortJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
        </actuator>
    </transmission>
    
</xacro:macro>

###launch# <!--


Originally posted by elif on ROS Answers with karma: 1 on 2022-04-19

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

Hi, I think the error could be coming because of missing gazebo plugin. Adding this should solve your issue -

<gazebo>
        <plugin name="joint_state_publisher" filename="libgazebo_ros_joint_state_publisher.so">
            <jointName>left_wheel,right_wheel</jointName>
        </plugin>
</gazebo>

Originally posted by Robo_guy with karma: 115 on 2022-04-22

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

Basically, robot_state_publisher only broadcasts static joints. The joint for the wheels is dynamic, so RSP will skip that one.

As to how you can get the TF for your wheels. There are several options.

The first one is adding the joint_state_publisher as suggested by @Robo_guy. This is a gazebo_ros plugin that gets the position of the join in Gazebo and broadcasts it to the TF tree.

You can also do it using the differential drive plugin from gazebo_ros. This is a plugin that allows you to drive the robot around (using teleop for instance). It has the option to broadcast the odom and wheel TFs.

You could also use ros_control, but it's a bit tricky to do in ROS 1 in simulations (at least in my opinion).


Originally posted by Joe28965 with karma: 1124 on 2022-04-22

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.