gazebo_mecanum_plugins icon indicating copy to clipboard operation
gazebo_mecanum_plugins copied to clipboard

How to use this plugin for my own xacro file?

Open sm3304love opened this issue 1 year ago • 5 comments

hello. I would like to use your plugin to use 4 mecanum wheeled robot in gazebo. However, ththat the odom topic is invisible. Are there any other works I should take?

  1. OS: ubuntu 20.04

  2. ros2 foxy

mecanum.urdf.xacro

<?xml version="1.0" ?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="mecanum">
<!-- <xacro:include filename="$(find mecanum_description)/urdf/materials.xacro" /> -->
<xacro:include filename="$(find mecanum_description)/urdf/mecanum_gazebo.xacro" />

<link name="base_footprint"></link>

  <joint name="base_link_joint" type="fixed">
    <origin xyz="0 0 0.05" rpy="0 0 0" />
    <parent link="base_footprint"/>
    <child link="base_link" />
  </joint>

<link name="base_link">
  <inertial>
    <origin xyz="-0.15000000000002084 -0.06797027234125849 0.0355880237291439" rpy="0 0 0"/>
    <mass value="8.777128082724442"/>
    <inertia ixx="0.030708" iyy="0.085311" izz="0.102783" ixy="0.0" iyz="-0.0" ixz="-0.0"/>
  </inertial>
  <visual>
    <origin xyz="0 0 0" rpy="0 0 0"/>
    <geometry>
      <mesh filename="file://$(find mecanum_description)/meshes/base_link.stl" scale="0.001 0.001 0.001"/>
    </geometry>
    <material name="steel_satin"/>
  </visual>
  <collision>
    <origin xyz="0 0 0" rpy="0 0 0"/>
    <geometry>
      <mesh filename="file://$(find mecanum_description)/meshes/base_link.stl" scale="0.001 0.001 0.001"/>
    </geometry>
  </collision>
</link>

<link name="Mecanum_Wheel_Assembly_Right-r4_1">
  <inertial>
    <origin xyz="-1.5129569133368048e-05 0.026870032144622125 5.42477174292344e-11" rpy="0 0 0"/>
    <mass value="0.9525240556329165"/>
    <inertia ixx="0.000492" iyy="0.000705" izz="0.000492" ixy="-0.0" iyz="0.0" ixz="0.0"/>
  </inertial>
  <visual>
    <origin xyz="0.045 -0.01003 -0.03" rpy="0 0 0"/>
    <geometry>
      <mesh filename="file://$(find mecanum_description)/meshes/Mecanum_Wheel_Assembly_Right-r4_1.stl" scale="0.001 0.001 0.001"/>
    </geometry>
    <material name="steel_satin"/>
  </visual>
  <collision>
    <origin xyz="0.045 -0.01003 -0.03" rpy="0 0 0"/>
    <geometry>
      <mesh filename="file://$(find mecanum_description)/meshes/Mecanum_Wheel_Assembly_Right-r4_1.stl" scale="0.001 0.001 0.001"/>
    </geometry>
  </collision>
</link>

<link name="Mecanum_Wheel_Assembly_Left-r4_2">
  <inertial>
    <origin xyz="-1.5036421291282631e-05 -0.026897988073681378 8.703700954404425e-11" rpy="0 0 0"/>
    <mass value="0.9584295019990953"/>
    <inertia ixx="0.000493" iyy="0.000706" izz="0.000493" ixy="0.0" iyz="-0.0" ixz="-0.0"/>
  </inertial>
  <visual>
    <origin xyz="0.045 0.14597 -0.03" rpy="0 0 0"/>
    <geometry>
      <mesh filename="file://$(find mecanum_description)/meshes/Mecanum_Wheel_Assembly_Left-r4_2.stl" scale="0.001 0.001 0.001"/>
    </geometry>
    <material name="steel_satin"/>
  </visual>
  <collision>
    <origin xyz="0.045 0.14597 -0.03" rpy="0 0 0"/>
    <geometry>
      <mesh filename="file://$(find mecanum_description)/meshes/Mecanum_Wheel_Assembly_Left-r4_2.stl" scale="0.001 0.001 0.001"/>
    </geometry>
  </collision>
</link>

<link name="Mecanum_Wheel_Assembly_Left-r4_1">
  <inertial>
    <origin xyz="-8.703737730542116e-11 0.02689744339116402 1.5036421291140384e-05" rpy="0 0 0"/>
    <mass value="0.9584295019990953"/>
    <inertia ixx="0.000493" iyy="0.000706" izz="0.000493" ixy="-0.0" iyz="0.0" ixz="-0.0"/>
  </inertial>
  <visual>
    <origin xyz="0.255 -0.01003 -0.03" rpy="0 0 0"/>
    <geometry>
      <mesh filename="file://$(find mecanum_description)/meshes/Mecanum_Wheel_Assembly_Left-r4_1.stl" scale="0.001 0.001 0.001"/>
    </geometry>
    <material name="steel_satin"/>
  </visual>
  <collision>
    <origin xyz="0.255 -0.01003 -0.03" rpy="0 0 0"/>
    <geometry>
      <mesh filename="file://$(find mecanum_description)/meshes/Mecanum_Wheel_Assembly_Left-r4_1.stl" scale="0.001 0.001 0.001"/>
    </geometry>
  </collision>
</link>

<link name="Mecanum_Wheel_Assembly_Right-r4_2">
  <inertial>
    <origin xyz="-1.5129572465022445e-05 -0.026870576827139225 -5.3343097300428965e-11" rpy="0 0 0"/>
    <mass value="0.9525240556329165"/>
    <inertia ixx="0.000492" iyy="0.000705" izz="0.000492" ixy="0.0" iyz="0.0" ixz="-0.0"/>
  </inertial>
  <visual>
    <origin xyz="0.255 0.14597 -0.03" rpy="0 0 0"/>
    <geometry>
      <mesh filename="file://$(find mecanum_description)/meshes/Mecanum_Wheel_Assembly_Right-r4_2.stl" scale="0.001 0.001 0.001"/>
    </geometry>
    <material name="steel_satin"/>
  </visual>
  <collision>
    <origin xyz="0.255 0.14597 -0.03" rpy="0 0 0"/>
    <geometry>
      <mesh filename="file://$(find mecanum_description)/meshes/Mecanum_Wheel_Assembly_Right-r4_2.stl" scale="0.001 0.001 0.001"/>
    </geometry>
  </collision>
</link>


<joint name="wheel_fl" type="continuous">
  <origin xyz="-0.045 0.01003 0.03" rpy="0 0 0"/>
  <parent link="base_link"/>
  <child link="Mecanum_Wheel_Assembly_Right-r4_1"/>
  <axis xyz="0.0 1.0 0.0"/>
</joint>

<joint name="wheel_fr" type="continuous">
  <origin xyz="-0.045 -0.14597 0.03" rpy="0 0 0"/>
  <parent link="base_link"/>
  <child link="Mecanum_Wheel_Assembly_Left-r4_2"/>
  <axis xyz="0.0 1.0 0.0"/>
</joint>

<joint name="wheel_bl" type="continuous">
  <origin xyz="-0.255 0.01003 0.03" rpy="0 0 0"/>
  <parent link="base_link"/>
  <child link="Mecanum_Wheel_Assembly_Left-r4_1"/>
  <axis xyz="0.0 1.0 0.0"/>
</joint>

<joint name="wheel_br" type="continuous">
  <origin xyz="-0.255 -0.14597 0.03" rpy="0 0 0"/>
  <parent link="base_link"/>
  <child link="Mecanum_Wheel_Assembly_Right-r4_2"/>
  <axis xyz="0.0 1.0 0.0"/>
</joint>



</robot>

'mecanum_gazebo.xacro

<?xml version="1.0" ?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="mecanum">
  
  <gazebo>
    <plugin name="gazebo_ros_mecanum_diff_drive" filename="libgazebo_ros_mecanum_diff_drive.so">
      <commandTopic>cmd_vel</commandTopic>
      <odometryTopic>odom</odometryTopic>
      <odometryFrame>odom</odometryFrame>
      <robotBaseFrame>base_footprint</robotBaseFrame>
      <LeftRear>wheel_bl</LeftRear>
      <LeftFront>wheel_fl</LeftFront>
      <RightFront>wheel_fr</RightFront>
      <RightRear>wheel_br</RightRear>
      <odometryRate>20</odometryRate>      
      <publishWheelTF>true</publishWheelTF>
      <publishWheelJointState>true</publishWheelJointState>
      <WheelTorque>1</WheelTorque>
      <WheelSeparationW>0.5</WheelSeparationW>
      <WheelSeparationL>0.6</WheelSeparationL>
      <wheelAccel>5</wheelAccel>
      <wheelDiameter>0.13</wheelDiameter>
      <publishOdom>true</publishOdom>
      <isRollerModel>true</isRollerModel>
    </plugin>
</gazebo>

</robot>

sm3304love avatar Sep 25 '22 04:09 sm3304love