qaz9517532846 / gazebo_mecanum_plugins

Gazebo Plugin for the mobile robot using four mecanum wheel.
24 stars 6 forks source link

How to use this plugin for my own xacro file? #2

Open sm3304love opened 1 year ago

sm3304love commented 1 year ago

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>
qaz9517532846 commented 1 year ago

Sorry for the late reply, this plugin need each roller model and 6-axis parameter. you can reference zm_robot for creating model and xacro file.

zm_robot: https://github.com/qaz9517532846/zm_robot/tree/ros2

santosnathalia commented 11 months ago

Hello,

Sorry, i am new using Gazebo and ROS.

Do you know if we can use the PID drive for any 4-wheeled mecanum robot? I am trying to use the "gazebo_mecanum_pid_plugin" but every time I run the simulation my robot appears without the wheels. Consequently I can't use rostopic pub.

But this doesn't happens when a I use the "gazebo_ros_mecanum_diff_drive".

ROS Noetic Gazebo 11 Screenshot from 2023-07-18 16-13-17

qaz9517532846 commented 11 months ago

If you want to use the PID controller, Please use libgazebo_ros_mecanum_pid_drive.so, Please adjust PID parameter P: 1 I:0 D:0 when using the initial PID controller. It may be that the PID value is too large to exceed the physical limit and the wheel will not appear.

<gazebo>
  <plugin name="zm_robot_controller" filename="libgazebo_ros_mecanum_pid_drive.so">
    <commandTopic>cmd_vel</commandTopic>
    <odometryTopic>odom</odometryTopic>
    <odometryFrame>odom</odometryFrame>
    <robotBaseFrame>base_footprint</robotBaseFrame>
    <LeftRear>wheel_joint_1</LeftRear>
    <LeftFront>wheel_joint_2</LeftFront>
    <RightFront>wheel_joint_3</RightFront>
    <RightRear>wheel_joint_4</RightRear>
    <odometryRate>20</odometryRate>      
    <publishWheelTF>true</publishWheelTF>
    <publishWheelJointState>true</publishWheelJointState>
    <WheelTorque>30</WheelTorque>
    <WheelSeparationW>0.5</WheelSeparationW>
    <WheelSeparationL>0.6</WheelSeparationL>
    <wheelAccel>5</wheelAccel>
    <wheelDiameter>0.13</wheelDiameter>
    <publishOdom>false</publishOdom>
    <isRollerModel>true</isRollerModel>
    <dt>0.05</dt>
    <WheelInputVelTopic>zm_input_vel</WheelInputVelTopic>
    <WheelOutputVelTopic>zm_output_vel</WheelOutputVelTopic>
    <WheelPID>gazebo_mecanum_plugins_PID</WheelPID>
  </plugin>
</gazebo>
SebastianA14 commented 11 months ago

Hello, I have a problem when cloning gazebo_mecanum_plugins and doing catkin_make tells me the following Building CXX object ira_laser_tools/CMakeFiles/laserscan_virtualizer.dir/src/laserscan_virtualizer.cpp.o In file included from /home/seb/pp/src/gazebo_mecanum_plugins/src/gazebo_ros_mecanum_pid_drive.cpp:1: /home/seb/pp/src/gazebo_mecanum_plugins/include/gazebo_mecanum_plugins/gazebo_ros_mecanum_drive.h:23:10: fatal error: gazebo_mecanum_plugins/gazebo_mecanum_plugins_vel.h: No existe el archivo o el directorio 23 | #include <gazebo_mecanum_plugins/gazebo_mecanum_plugins_vel.h> | ^~~~~~~~~~~~~ compilation terminated. In file included from /home/seb/pp/src/gazebo_mecanum_plugins/src/gazebo_ros_mecanum_drive.cpp:1: /home/seb/pp/src/gazebo_mecanum_plugins/include/gazebo_mecanum_plugins/gazebo_ros_mecanum_drive.h:23:10: fatal error: gazebo_mecanum_plugins/gazebo_mecanum_plugins_vel.h: No existe el archivo o el directorio 23 | #include <gazebo_mecanum_plugins/gazebo_mecanum_plugins_vel.h> | ^~~~~~~~~~~~~ compilation terminated. make[2]: [gazebo_mecanum_plugins/CMakeFiles/gazebo_ros_mecanum_pid_drive.dir/build.make:63: gazebo_mecanum_plugins/CMakeFiles/gazebo_ros_mecanum_pid_drive.dir/src/gazebo_ros_mecanum_pid_drive.cpp.o] Error 1 make[1]: [CMakeFiles/Makefile2:2965: gazebo_mecanum_plugins/CMakeFiles/gazebo_ros_mecanum_pid_drive.dir/all] Error 2 make[1]: Se espera a que terminen otras tareas.... make[2]: [gazebo_mecanum_plugins/CMakeFiles/gazebo_ros_mecanum_drive.dir/build.make:63: gazebo_mecanum_plugins/CMakeFiles/gazebo_ros_mecanum_drive.dir/src/gazebo_ros_mecanum_drive.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:2992: gazebo_mecanum_plugins/CMakeFiles/gazebo_ros_mecanum_drive.dir/all] Error 2

since the file gazebo_mecanum_plugins_vel.h does not exist in gazebo_mecanum_plugins folder and is called in other scripts like gazebo_ros_mecanum_drive.h

qaz9517532846 commented 11 months ago

Hello, I have a problem when cloning gazebo_mecanum_plugins and doing catkin_make tells me the following Building CXX object ira_laser_tools/CMakeFiles/laserscan_virtualizer.dir/src/laserscan_virtualizer.cpp.o In file included from /home/seb/pp/src/gazebo_mecanum_plugins/src/gazebo_ros_mecanum_pid_drive.cpp:1: /home/seb/pp/src/gazebo_mecanum_plugins/include/gazebo_mecanum_plugins/gazebo_ros_mecanum_drive.h:23:10: fatal error: gazebo_mecanum_plugins/gazebo_mecanum_plugins_vel.h: No existe el archivo o el directorio 23 | #include <gazebo_mecanum_plugins/gazebo_mecanum_plugins_vel.h> | ^~~~~~~~~~~~~ compilation terminated. In file included from /home/seb/pp/src/gazebo_mecanum_plugins/src/gazebo_ros_mecanum_drive.cpp:1: /home/seb/pp/src/gazebo_mecanum_plugins/include/gazebo_mecanum_plugins/gazebo_ros_mecanum_drive.h:23:10: fatal error: gazebo_mecanum_plugins/gazebo_mecanum_plugins_vel.h: No existe el archivo o el directorio 23 | #include <gazebo_mecanum_plugins/gazebo_mecanum_plugins_vel.h> | ^~~~~~~~~~~~~ compilation terminated. make[2]: [gazebo_mecanum_plugins/CMakeFiles/gazebo_ros_mecanum_pid_drive.dir/build.make:63: gazebo_mecanum_plugins/CMakeFiles/gazebo_ros_mecanum_pid_drive.dir/src/gazebo_ros_mecanum_pid_drive.cpp.o] Error 1 make[1]: [CMakeFiles/Makefile2:2965: gazebo_mecanum_plugins/CMakeFiles/gazebo_ros_mecanum_pid_drive.dir/all] Error 2 make[1]: Se espera a que terminen otras tareas.... make[2]: [gazebo_mecanum_plugins/CMakeFiles/gazebo_ros_mecanum_drive.dir/build.make:63: gazebo_mecanum_plugins/CMakeFiles/gazebo_ros_mecanum_drive.dir/src/gazebo_ros_mecanum_drive.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:2992: gazebo_mecanum_plugins/CMakeFiles/gazebo_ros_mecanum_drive.dir/all] Error 2

since the file gazebo_mecanum_plugins_vel.h does not exist in gazebo_mecanum_plugins folder and is called in other scripts like gazebo_ros_mecanum_drive.h

CmakeList.txt not added dependencies message and service cause too compiler error, I updated CmakeList.txt, you comfirm it please.