forward twist rotates robot gazebo ros control

asked 2021-11-04 01:26:20 -0500

dinesh gravatar image

updated 2021-11-04 02:23:05 -0500

I have made a urdf for diff drive robot. here i am using gazebo_ros_contol plugin to control this motor similary like turtlebot3. But when i send the forward twist command the robot is rotating instead of moving forward. Here is my xacro file:

    <?xml version="1.0"?>
    <!-- Revolute-Revolute Manipulator -->
    <robot name="bini" xmlns:xacro="http://www.ros.org/wiki/xacro">



     <!-- Constants for robot dimensions -->
      <xacro:property name="PI" value="3.1415926535897931"/>
      <xacro:property name="mass" value="1" /> <!-- arbitrary value for mass -->
      <xacro:property name="width" value="0.1" /> <!-- Square dimensions (widthxwidth) of beams -->
      <xacro:property name="height1" value="2" /> <!-- Link 1 -->
      <xacro:property name="height2" value="1" /> <!-- Link 2 -->
      <xacro:property name="height3" value="1" /> <!-- Link 3 -->
      <xacro:property name="camera_link" value="0.05" /> <!-- Size of square 'camera' box -->
      <xacro:property name="axel_offset" value="0.05" /> <!-- Space btw top of beam and the each joint -->

  <!-- Modify this content if robots joint and link names are different -->
  <xacro:arg name="left_wheel_joint_name" default="left_wheel_joint"/>
  <xacro:arg name="right_wheel_joint_name" default="right_wheel_joint"/>
  <xacro:arg name="right_wheel_link_name" default="right_wheel"/>
  <xacro:arg name="left_wheel_link_name" default="left_wheel"/>
  <xacro:arg name="front_wheel_link_name" default="front_wheel"/>
  <xacro:arg name="back_wheel_link_name" default="back_wheel"/>
  <xacro:arg name="imu_link_name" default="imu_link"/>
  <xacro:arg name="lidar_link_name" default="base_scan"/>
  <xacro:arg name="camera_link_name" default="camera_link"/>

  <!-- Import all Gazebo-customization elements, including Gazebo colors -->
  <xacro:include filename="$(find bini_simulation)/urdf/bini.gazebo" />
  <!-- Import Rviz colors -->
  <xacro:include filename="$(find bini_simulation)/urdf/materials.xacro" />

  <!-- Import robot urdf which was directly exported from Solidwork-->
  <xacro:include filename="$(find bini_description)/urdf/bini_description.urdf" />

  <link name="base_footprint"/>

  <joint name="base_joint" type="fixed">
    <parent link="base_footprint"/>
    <child link="base_link" />
    <origin xyz="0.0167666250730711 -0.00206087262344925 0.0155567321901691" rpy="0 0 0"/>
  </joint>


      <!-- Transmission element segment for each moving joint in robot according to their type of control -->
      <transmission name="tran1">

    <type>transmission_interface/SimpleTransmission</type>
    <joint name="$(arg left_wheel_joint_name)">
      <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
    </joint>

    <actuator name="motor1">
      <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
      <mechanicalReduction>1</mechanicalReduction>
    </actuator>
      </transmission>

      <transmission name="tran2">
        <type>transmission_interface/SimpleTransmission</type>
        <joint name="$(arg right_wheel_joint_name)">
          <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
        </joint>
        <actuator name="motor2">
          <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
          <mechanicalReduction>1</mechanicalReduction>
        </actuator>
      </transmission>

    </robot>

The xacro file for gazebo plugin is:

    <?xml version="1.0"?>
    <robot>

      <!-- simulation parameters segment for given joint -->
      <gazebo reference="base_link">
        <material>Gazebo/DarkGrey</material>
      </gazebo>

      <gazebo reference="$(arg left_wheel_link_name)">
        <mu1>0.1</mu1>
        <mu2>0.1</mu2>
        <kp>500000.0</kp>
        <kd>10.0</kd>
        <minDepth>0.001</minDepth>
        <maxVel>0.1</maxVel>
        <fdir1>1 0 0</fdir1>
        <material>Gazebo/FlatBlack</material>
      </gazebo>

      <gazebo reference="$(arg right_wheel_link_name)">
    <mu1>0.1</mu1>
    <mu2>0.1</mu2>
    <kp>500000.0</kp>
    <kd>10.0</kd>
    <minDepth>0.001</minDepth>
    <maxVel>0.1</maxVel>
    <fdir1>1 ...
(more)
edit retag flag offensive close merge delete

Comments

suggestion: please improve the title of your question. "ros control plugin issue" doesn't really mean anything.

Simply describing the main symptom you observe is typically a good starting point for a title, and you already did that yourself in the question text:

when i send the forward twist command the robot is rotating instead of moving forward.

if you shorten that a bit it would be a much better title than the current one.

gvdhoorn gravatar image gvdhoorn  ( 2021-11-04 01:47:55 -0500 )edit