custom robot not moving diff drive plugin
Hello,
I am trying to simulate a custom robot. I am using ROS Noetic. Please find my gazebo file where I have added the plugin and my urdf file as well
<?xml version="1.0"?>
<robot name="rseries_bot" xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:include filename="$(find multibot_simulation)/urdf/rseries_bot.gazebo.xacro"/>
<!-- ****************** ROBOT CONSTANTS ******************************* -->
<xacro:property name="base_width" value="0.42"/>
<xacro:property name="base_length" value="0.40"/>
<xacro:property name="base_height" value="0.20"/>
<xacro:property name="wheel_radius" value="0.0825"/>
<xacro:property name="wheel_width" value="0.05"/>
<xacro:property name="wheel_ygap" value="0.15"/>
<xacro:property name="wheel_zoff" value="0.0"/>
<xacro:property name="wheel_xoff" value="0.0"/>
<xacro:property name="caster_xoff" value="0.217"/>
<xacro:macro name="box_inertia" params="m w h d">
<inertial>
<origin xyz="0 0 0" rpy="${pi/2} 0 ${pi/2}"/>
<mass value="${m}"/>
<inertia ixx="${(m/12) * (h*h + d*d)}" ixy="0.0" ixz="0.0" iyy="${(m/12) * (w*w + d*d)}" iyz="0.0" izz="${(m/12) * (w*w +h*h)}"/>
</inertial>
</xacro:macro>
<xacro:macro name="cylinder_inertia" params="m r h">
<inertial>
<origin xyz="0 0 0" rpy="${pi/2} 0 0" />
<mass value="${m}"/>
<inertia ixx="${(m/12) * (3*r*r + h*h)}" ixy = "0" ixz = "0" iyy="${(m/12) * (3*r*r + h*h)}" iyz = "0" izz="${(m/2) * (r*r)}"/>
</inertial>
</xacro:macro>
<xacro:macro name="sphere_inertia" params="m r">
<inertial>
<mass value="${m}"/>
<inertia ixx="${(2/5) * m * (r*r)}" ixy="0.0" ixz="0.0" iyy="${(2/5) * m * (r*r)}" iyz="0.0" izz="${(2/5) * m * (r*r)}"/>
</inertial>
</xacro:macro>
<!-- ********************** ROBOT BASE ********************************* -->
<link name="base_link">
<visual>
<origin xyz="0.0 0.0 0.08" rpy="0 0 0"/>
<geometry>
<mesh filename="package://multibot_simulation/mesh/robochef_body_final.stl" scale="0.0015 0.0015 0.0015"/>
</geometry>
<color rgba="${0/255} ${0/255} ${255/255} 1.0"/>
</visual>
<collision>
<geometry>
<box size="${base_length} ${base_width} ${base_height}"/>
</geometry>
</collision>
<xacro:box_inertia m="20.0" w="${base_width}" d="${base_length}" h="${base_height}"/>
</link>
<!-- *********************** DRIVE WHEELS ****************************** -->
<link name="left_wheel_link">
<visual>
<origin xyz="0 0 0" rpy="1.5707963267949 0 0"/>
<geometry>
<mesh filename="package://multibot_simulation/mesh/wheel.stl" scale="0.0013 0.0013 0.0013"/>
</geometry>
<material name="White">
<color rgba="${255/255} ${255/255} ${255/255} 1.0"/>
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="${pi/2} 0 0"/>
<geometry>
<cylinder radius="${wheel_radius}" length="${wheel_width}"/>
</geometry>
</collision>
<xacro:cylinder_inertia m="5.5" r="${wheel_radius}" h="${wheel_width}"/>
</link>
<joint name="left_wheel_joint" type="revolute">
<parent link="base_link"/>
<child link="left_wheel_link"/>
<origin xyz="0.0 0.19 0.0" rpy="0 0 0"/>
<limit upper="3.1415" lower="-3.1415" effort="30" velocity="5.0"/>
<axis xyz="1 0 0"/>
</joint>
<link name="right_wheel_link">
<visual>
<origin xyz="0 0 0" rpy="1.5707963267949 0 3.1457"/>
<geometry>
<mesh filename="package://multibot_simulation/mesh/wheel.stl" scale="0.0013 0.0013 0.0013"/>
</geometry>
<material name="White">
<color rgba="${255/255} ${255/255} ${255/255} 1.0"/>
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="${pi/2} 0 0"/>
<geometry>
<cylinder radius="${wheel_radius}" length="${wheel_width}"/>
</geometry>
</collision>
<xacro:cylinder_inertia m="5.5" r="${wheel_radius}" h="${wheel_width}"/>
</link>
<joint name="right_wheel_joint" type="revolute">
<parent link="base_link"/>
<child link="right_wheel_link"/>
<origin xyz="0.0 -0.19 0.0" rpy="0 0 0"/>
<limit upper="3.1415" lower="-3.1415" effort="30" velocity="5.0"/>
<axis xyz="1 0 0"/>
</joint>
<!-- *********************** CASTER WHEEL ****************************** -->
<link name="front_caster">
<visual>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<sphere radius="${(wheel_radius+wheel_zoff-(base_height/2))}"/>
</geometry>
<material name="White">
<color rgba="${255/255} ${255/255} ${255/255} 1.0"/>
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<sphere radius="${(wheel_radius+wheel_zoff-(base_height/2))}"/>
</geometry>
</collision>
<xacro:sphere_inertia m="0.5" r="${(wheel_radius+wheel_zoff-(base_height/2))}"/>
</link>
<joint name="front_caster_joint" type="fixed">
<parent link="base_link"/>
<child link="front_caster"/>
<origin xyz="${caster_xoff} 0.0 ${-(base_height/2)}" rpy="0 0 0"/>
</joint>
<link name="back_caster">
<visual>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<sphere radius="${(wheel_radius+wheel_zoff-(base_height/2))}"/>
</geometry>
<material name="White">
<color rgba="${255/255} ${255/255} ${255/255} 1.0"/>
</material>
</visual>
<collision>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<sphere radius="${(wheel_radius+wheel_zoff-(base_height/2))}"/>
</geometry>
</collision>
<xacro:sphere_inertia m="0.5" r="${(wheel_radius+wheel_zoff-(base_height/2))}"/>
</link>
<joint name="back_caster_joint" type="fixed">
<parent link="base_link"/>
<child link="back_caster"/>
<origin xyz="${-caster_xoff} 0.0 -0.08" rpy="0 0 0"/>
</joint>
<!-- *********************** IMU SETUP ********************************* -->
<joint name="imu_joint" type="fixed">
<parent link="base_link" />
<child link="base_imu" />
<origin rpy="0 0 0" xyz="0 0 0.152" />
</joint>
<link name="base_imu">
<visual>
<origin xyz="0.0 0 0.015" />
<geometry>
<mesh filename="package://multibot_simulation/mesh/imu.stl" scale="0.0015 0.0015 0.0015"/>
</geometry>
</visual>
</link>
<!-- *********************** Lidar SETUP ********************************** -->
<joint name="laser_joint" type="fixed">
<parent link="base_link" />
<child link="base_laser" />
<origin rpy="0 0 0" xyz="0 0 0" />
</joint>
<link name="base_laser">
<visual>
<origin xyz="0 0 0.23" rpy="0 0 0" />
<geometry>
<mesh filename="package://multibot_simulation/mesh/rplidar.stl" scale="0.0015 0.0015 0.0015"/>
</geometry>
</visual>
</link>
</robot>
Here is my .gazebo file:
<?xml version="1.0"?>
<gazebo reference="base_link">
<material>Gazebo/Blue</material>
</gazebo>
<gazebo reference="right_wheel_link">
<mu1>0.9</mu1>
<mu2>0.9</mu2>
<kp>1000.0</kp>
<kd>1000.0</kd>
<minDepth>0.001</minDepth>
<maxVel>10.0</maxVel>
<fdir1>1 1 0</fdir1>
<material>Gazebo/FlatBlack</material>
</gazebo>
<gazebo reference="left_wheel_link">
<mu1>0.9</mu1>
<mu2>0.9</mu2>
<kp>1000.0</kp>
<kd>1000.0</kd>
<minDepth>0.001</minDepth>
<maxVel>10.0</maxVel>
<fdir1>1 1 0</fdir1>
<material>Gazebo/FlatBlack</material>
</gazebo>
<gazebo reference="front_caster">
<mu1>0.1</mu1>
<mu2>0.1</mu2>
<kp>1000000.0</kp>
<kd>100.0</kd>
<minDepth>0.001</minDepth>
<maxVel>10.0</maxVel>
<material>Gazebo/FlatBlack</material>
</gazebo>
<gazebo reference="back_caster">
<mu1>0.1</mu1>
<mu2>0.1</mu2>
<kp>1000000.0</kp>
<kd>100.0</kd>
<minDepth>0.001</minDepth>
<maxVel>10.0</maxVel>
<material>Gazebo/FlatBlack</material>
</gazebo>
<gazebo>
<plugin name="rseries_controller" filename="libgazebo_ros_diff_drive.so">
<commandTopic>cmd_vel</commandTopic>
<odometryTopic>odom</odometryTopic>
<odometryFrame>odom</odometryFrame>
<odometrySource>world</odometrySource>
<publishOdomTF>true</publishOdomTF>
<robotBaseFrame>$(arg prefix)/base_link</robotBaseFrame>
<publishWheelTF>false</publishWheelTF>
<publishTf>true</publishTf>
<publishWheelJointState>true</publishWheelJointState>
<legacyMode>false</legacyMode>
<updateRate>30</updateRate>
<leftJoint>left_wheel_joint</leftJoint>
<rightJoint>right_wheel_joint</rightJoint>
<wheelSeparation>0.27</wheelSeparation>
<wheelDiameter>0.165</wheelDiameter>
<wheelAcceleration>1</wheelAcceleration>
<wheelTorque>10</wheelTorque>
<rosDebugLevel>na</rosDebugLevel>
<tf_prefix>$(arg prefix)</tf_prefix>
</plugin>
</gazebo>
</robot>
I have played around with the mu1, mu2, Kp and Kd parameters but the robot just won't move. Please help me
Thank you.
Asked by cjoshi17 on 2022-01-17 01:11:42 UTC
Answers
Try changing both the left and right wheel joint's effort and velocity values to 10 or 100, doing this should solve your problem. I had encountered a similar problem and doing this had solved it for me.
Asked by Robo_guy on 2022-01-18 06:51:52 UTC
Comments
@cjoshi17 did you try doing this ? Did it solve your problem ?
Asked by Robo_guy on 2022-01-24 08:27:15 UTC
Comments
I have changed motor joints from revolute to continuous but it still didn't work. I followed the URDF from mastering ROS and it somehow worked
Asked by cjoshi17 on 2022-01-17 07:43:21 UTC
Sorry it should work we both, that's why I deleted the comment.
Asked by osilva on 2022-01-17 09:31:00 UTC
There isn't really any information here to help answer your question. Is there any specific error you're seeing? Any tutorial you're following? Any configuration file you're using?
Asked by cst0 on 2022-01-17 22:06:41 UTC