Search code examples
ros

Skid_steer_drive_controller don't move joints


Hello I have found a problem when I try to use gazebo skid_steer_drive_controller. The controller did not publish wheel tf and will not respond when I try to send cmd_vel. Rviz says error where no transform from [link_left_wheel_front] to [odom]. But what is most important that the robot in Gazebo isn't moving. I don't know where it could be problem. Maybe in the plugin setting, but when I was looking and comparing with different codes, it looks ok to me.

Main URDF

The trabot.sensors.urdf.xacro are only cameras and lidar.

<?xml version="1.0"?>
<!-- link has always reference on [0,0,0] you can define visual to it-->
<!-- the joint will move child from parent with entered origin-->


<robot name="my_robot" xmlns:xacro="http://ros.org/wiki/xacro">
    <xacro:include filename="$(find trabot_description)/urdf/trabot.sensors.urdf.xacro"/>
    <xacro:property name="width" value="0.25"/>
    <xacro:property name="bodylen" value="0.38"/>
    <xacro:property name="hight" value="0.09"/>
    <xacro:property name="wheel_pitch" value="0.175"/>
    <xacro:property name="wheel_length" value="0.053975"/>
    <xacro:property name="wheel_radius" value="0.0575"/>
    <xacro:property name="wheel_separation" value="0.175"/>

    <link name="base_link">
        <visual>
            <geometry>
                <mesh filename="package://trabot_description/meshes/base.dae" scale="0.001 0.001 0.001"/>
            </geometry>
            <origin rpy="0 0 0" xyz="-${width/2} -${bodylen/2} -${hight/2}"/>
        </visual>
        <collision>
            <geometry>
                <box size="${width} ${bodylen} ${hight}"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="1.204"/>
            <inertia ixx="0.01768" ixy="0.0" ixz="-0.0" iyy="0.00949" iyz="-0.0" izz="0.02069"/>
        </inertial>
    </link>

    <xacro:macro name="wheel" params="prefix postfix frontback reflect">
        <link name="link_${prefix}_wheel_${postfix}">
            <visual>
                <geometry>
                    <mesh filename="package://trabot_description/meshes/wheel.dae" scale="0.001 0.001 0.001"/>
                </geometry>
                <origin rpy="0 0 ${reflect*pi/2}" xyz="0 0 0"/>
            </visual>
            <collision>
                <geometry>
                    <cylinder length="${wheel_length}" radius="${wheel_radius}"/>
                </geometry>
                <origin rpy="0 ${pi/2} 0" xyz="${reflect*(wheel_radius/2)} 0 0"/>
            </collision>
            <inertial>
                <mass value="0.254"/>
                <inertia ixx="0.000427228" ixy="0.0" ixz="0.0" iyy="0.0002708487" iyz="0.0" izz="0.0002708487"/>
                <origin rpy="0 0 0" xyz="0 0 0"/>
            </inertial>
        </link>

        <joint name="joint_${prefix}_${postfix}_wheel" type="continuous">
            <parent link="base_link"/>
            <child link="link_${prefix}_wheel_${postfix}"/>
            <origin xyz="${(width/2+0.0001)*reflect} ${(wheel_pitch/2)*frontback} -0.0175"/>
            <axis xyz="1 0 0"/>
                <limit effort="10000" velocity="1000"/>
                <joint_properties damping="1.0" friction="1.0"/>
        </joint>

        <!-- This block provides the simulator (Gazebo) with information on a few additional
        physical properties. See http://gazebosim.org/tutorials/?tut=ros_urdf for more-->
        <gazebo reference="link_${prefix}_wheel_${postfix}">
            <mu1>0.1</mu1>
            <mu2>0.1</mu2>
            <kp>1000000.0</kp>
            <kd>100.0</kd>
            <minDepth>0.00</minDepth>
        </gazebo>

        <transmission name="tran_${prefix}_${postfix}_wheel">
            <type>transmission_interface/SimpleTransmission</type>
            <actuator name="actuator_${prefix}_${postfix}_wheel">
                <mechanicalReduction>1</mechanicalReduction>
                <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
            </actuator>
            <joint name="joint_${prefix}_${postfix}_wheel">
                <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
            </joint>
        </transmission>

    </xacro:macro>

    <xacro:wheel prefix="left" postfix="front" frontback="1" reflect="1"/>
    <xacro:wheel prefix="left" postfix="rear" frontback="-1" reflect="1"/>
    <xacro:wheel prefix="right" postfix="front" frontback="1" reflect="-1"/>
    <xacro:wheel prefix="right" postfix="rear" frontback="-1" reflect="-1"/>

    <gazebo>
        <plugin name="skid_steer_drive_controller" filename="libgazebo_ros_skid_steer_drive.so">
            <updateRate>100.0</updateRate>
            <robotNamespace>/</robotNamespace>
            <leftFrontJoint>joint_left_front_wheel</leftFrontJoint>
            <rightFrontJoint>joint_right_front_wheel</rightFrontJoint>
            <leftRearJoint>joint_left_rear_wheel</leftRearJoint>
            <rightRearJoint>joint_right_rear_wheel</rightRearJoint>
            <wheelSeparation>0.175</wheelSeparation>
            <wheelDiameter>0.115</wheelDiameter>
            <robotBaseFrame>base_link</robotBaseFrame>
            <torque>200</torque>
            <MaxForce>5.0</MaxForce>
            <topicName>trabot/cmd_vel</topicName>
            <odometryTopic>trabot/odom</odometryTopic>
            <odometryFrame>odom</odometryFrame>
            <broadcastTF>true</broadcastTF>
        </plugin>
    </gazebo>

    <!-- Gazebo plugin for ROS Control -->
    <gazebo>
        <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
            <robotNamespace>/</robotNamespace>
        </plugin>
    </gazebo>
</robot>

Launch file

<?xml version="1.0" encoding="UTF-8" ?>
<launch>
    <arg name="gui" default="true"/>
    <arg name="pause" default="false"/>
    <arg name="world" default="$(find trabot_gazebo)/world/default.world"/>

    <arg name="robot_urdf" default="$(find trabot_description)/urdf/trabot.urdf.xacro"/>
    <arg name="rviz_config" default="$(find trabot_gazebo)/config/rviz_v.0.2.rviz"/>
    <param name="robot_description" command="xacro '$(arg robot_urdf)'" />


    <!-- world launch -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="$(arg world)"/> <!-- Note: the world_name is with respect to GAZEBO_RESOURCE_PATH environmental variable -->
        <arg name="paused" value="$(arg pause)"/>
        <arg name="use_sim_time" value="true"/>
        <arg name="gui" value="$(arg gui)"/>
        <arg name="recording" value="false"/>
        <arg name="debug" value="false"/>
    </include>

     <!-- Spawn my robot -->
    <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-param robot_description -urdf -z 1 -model trabot"/>

    <!-- Start tf of robot -->
    <!-- Manual control of joints - joint state pub-->
    <!--<node pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" name="joint_state_publisher_gui"/>
    -->

    <!--creates transformation tree from robot_description param-->
    <node pkg="robot_state_publisher" type="robot_state_publisher" name="rob_st_pub" />
   
    
    <!-- rviz -->
    <node pkg="rviz" type="rviz" name="rob_rviz" args="-d $(arg rviz_config)" required="true"/>
    <node name="rqt_robot_steering" pkg="rqt_robot_steering" type="rqt_robot_steering">
        <param name="default_topic" value="/trabot/cmd_vel"/>
    </node>

</launch>

Solution

  • So definitely the problem, was in my not understanding in what I was doing. After few days and teaching myself ROS Control properly I found out the problem was in launch file.