1
$\begingroup$

im trying to control my robot using the ros navigation stack in gazebo, i know that i need a plugin to be able to send velocity commands to the robot,

i tried using the diff_drive_plugin i was never able to get it to work, when ever i start gazebo and inspect topics using "rostopic list" i never found the cmd_vel and odom topics being listed,

so i gave up and tried to use the gazebo_ros_control the plugin works i can see the cmd_vel topic being listed the problem is that the robot starts randomly moving by itself view video

i noticed when i set the d value of the "pid" to 0 in the controller config file the robot stops moving by itself but it also dosent respond to velocity messages published on joint/command

here is the config file

robot_vacuum:
  joint_state_controller:
    type: joint_state_controller/JointStateController
    publish_rate: 50  
  joint1_position_controller:
    type: effort_controllers/JointPositionController
    joint: left_wheel_link_joint
    pid: {p: 100.0, i: 0.01, d: 10.0}
  joint2_position_controller:
    type: effort_controllers/JointPositionController
    joint: right_wheel_link_joint
    pid: {p: 100.0, i: 0.01, d: 10.0}

here is the urdf file

<robot name="vacuum_robot" version="1.0">

  <joint name="left_wheel_link_joint" type="continuous">
    <limit lower="0" upper="0" effort="1.00000" velocity="40.00000"/>
    <origin rpy="0.00000 -1.57080 0.00000" xyz="0.10119 0.00179 0.03505"/>
    <parent link="main_body_link"/>
    <child link="left_wheel_link"/>
    <axis xyz="0.00000 0.00000 1.00000"/>
  </joint>

  <joint name="front_wheel_link_joint" type="fixed">
    <origin rpy="0 0 0" xyz="0 0 0"/>
    <parent link="main_body_link"/>
    <child link="front_wheel_link"/>
  </joint>

  <joint name="right_wheel_link_joint" type="continuous">
    <limit lower="0" upper="0" effort="1.00000" velocity="40.00000"/>
    <origin rpy="0.00000 1.57077 0.00000" xyz="-0.10079 0.00217 0.03420"/>
    <parent link="main_body_link"/>
    <child link="right_wheel_link"/>
    <axis xyz="0.00000 0.00000 1.00000"/>
  </joint>
  <link name="left_wheel_link">
    <collision name="left_wheel_collision">
      <origin rpy="0.00397 0.00000 -1.57080" xyz="-0.00008 -0.00062 0.00014"/>
      <geometry>
        <cylinder radius="0.03540" length="0.02351"/>
      </geometry>
    </collision>
    <inertial>
      <inertia ixx="0.00030" ixy="0.00000" ixz="0.00000" iyy="0.00017" iyz="0.00000" izz="0.00017"/>
      <origin rpy="0.00000 0.00000 0.00000" xyz="-0.00008 -0.00062 0.00014"/>
      <mass value="0.42100"/>
    </inertial>
    <visual name="left_wheel">
      <origin rpy="0.00000 1.56683 0.00000" xyz="-0.00210 -0.01370 -0.00374"/>
      <material name="mat_1"/>
      <geometry>
        <!--<cylinder radius="0.02750" length="0.07335"/>-->
        <mesh filename="/home/ahmed/catkin_ws/src/vacuum_sim/meshes/left_wheel.dae" scale="1.00000 1.00000 1.00000"/>
      </geometry>
    </visual>
  </link>
  <link name="main_body_link">
    <collision name="main_body_collision">
      <origin rpy="0.00000 0.00000 0.00000" xyz="0.00000 0.00000 0.04474"/>
      <geometry>
        <cylinder radius="0.14774" length="0.06896"/>
      </geometry>
    </collision>
    <inertial>
      <inertia ixx="0.01038" ixy="0.00000" ixz="0.00000" iyy="0.01038" iyz="0.00000" izz="0.01936"/>
      <origin rpy="0.00000 0.00000 0.00000" xyz="0.00000 0.00000 0.04474"/>
      <mass value="1.80100"/>
    </inertial>    
    <visual name="main_body">
      <origin rpy="0.00000 0.00000 0.00000" xyz="0.00000 0.00000 0.00000"/>
      <material name="mat_3"/>
      <geometry>
        <!--<cylinder radius="0.15000" length="0.07001"/>-->
        <mesh filename="/home/ahmed/catkin_ws/src/vacuum_sim/meshes/robot_body.dae" scale="1.00000 1.00000 1.00000"/>
      </geometry>
    </visual>

  </link>
  <link name="front_wheel_link">
    <collision name="Sphere_collision">
      <origin rpy="0.00000 0.00000 0.00000" xyz="0.00001 -0.11394 0.008107"/>
      <geometry>
        <sphere radius="0.00800"/>
      </geometry>
    </collision>
    <inertial>
      <inertia ixx="0.00001" ixy="0.00000" ixz="0.00000" iyy="0.00001" iyz="0.00000" izz="0.00001"/>
      <origin rpy="0.00000 0.00000 0.00000" xyz="0.00001 -0.00002 -0.00005"/>
      <mass value="0.21100"/>
    </inertial>
    <visual name="Sphere">
      <origin rpy="0.00000 0.00000 0.00000" xyz="0.00004 -0.11394 0.008107"/>
      <material name="mat_1"/>
      <geometry>
         <sphere radius="0.00800"/>
      </geometry>
    </visual>
  </link>
  <link name="right_wheel_link">
    <collision name="right_wheel_collision">
      <origin rpy="0.00003 0.00000 1.57080" xyz="-0.00003 -0.00067 0.00012"/>
      <geometry>
        <cylinder radius="0.03540" length="0.02351"/>
      </geometry>
    </collision>
    <inertial>
      <inertia ixx="0.00026" ixy="0.00000" ixz="0.00000" iyy="0.00015" iyz="0.00000" izz="0.00015"/>
      <origin rpy="0.00000 0.00000 0.00000" xyz="-0.00003 -0.00067 0.00012"/>
      <mass value="0.42100"/>
    </inertial>
    <visual name="right_wheel">
      <origin rpy="0.00000 -1.57077 0.00000" xyz="-0.00080 -0.01592 -0.00421"/>
      <material name="mat_0"/>
      <geometry>
        <!--<cylinder radius="0.02750" length="0.07335"/>-->
        <mesh filename="/home/ahmed/catkin_ws/src/vacuum_sim/meshes/right_wheel.dae" scale="1.00000 1.00000 1.00000"/>
      </geometry>
    </visual>
  </link>
  <material name="mat_0">
    <color rgba="0.80000 0.80000 0.80000 1.00000"/>
  </material>
  <material name="mat_1">
    <color rgba="0.04314 0.04314 0.04314 1.00000"/>
  </material>
  <material name="mat_3">
    <color rgba="1.00000 0.10588 0.00000 1.00000"/>
  </material>


<transmission name="right_wheel_transmission">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="right_wheel_link_joint">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="right_wheel_motor">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </actuator>
  </transmission>

  <transmission name="left_wheel_transmission">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="left_wheel_link_joint">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="left_wheel_motor">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </actuator>
  </transmission>
  <gazebo>
    <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
      <robotNamespace>/robot_vacuum</robotNamespace>
    </plugin>
  </gazebo>


  <gazebo reference="front_wheel_link_joint">
    <preserveFixedJoint>true</preserveFixedJoint>
  </gazebo>
</robot>

and the launch file

<launch>

  <rosparam file="$(find vacuum_sim)/config/robot_controllers.yaml" command="load"/>

  <!-- load the controllers -->
  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
    output="screen" ns="/robot_vacuum" args="joint1_position_controller joint2_position_controller joint_state_controller"/>

  
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"
    respawn="false" output="screen">
    <!-- <remap from="/joint_states" to="/rrbot/joint_states" /> -->
  </node>
  
    <include file="$(find gazebo_ros)/launch/empty_world.launch"/>


    <param name="robot_description" textfile="$(find vacuum_sim)/urdf/vacuum_robot.urdf" />
    
    <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
          args="-urdf -file $(find vacuum_sim)/urdf/vacuum_robot.urdf -model vacuum_robot"/>

</launch>

any help is appreciated!

edit: i noticed that the collision of the wheels are overlapping with the collision of the body, im not sure if this is a problem i tried to remove the body collision and that didnt fix it ,im guessing if the visual body shouldnt be overlapping with another visual body either? but the problem didnt occur before i added the controllers and both the collision and visual were overlapping as well, is there a way i can debug this from gazebo?

$\endgroup$

0

Your Answer

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

Browse other questions tagged or ask your own question.