nilseuropa / gazebo_ros_motors

Motor simulation plugins for Gazebo - ROS
116 stars 27 forks source link

How to publish joint_states for two motors? #3

Closed snrdevs closed 4 years ago

snrdevs commented 4 years ago

Hi all, I'm building a mobile robot, and I want to use, "joint_motor" in my project. I prepared a URDF for my robot and launched it in Gazebo. I set up my left_wheel & right_wheel joints as mentioned in your Readme file, and it works properly.

My question is, I want to publish joint_states messages for my both wheels. When I look into code, I think it's only for one wheel (or motor). So, it publishes the state of last wheel in the URDF (in this case right_wheel). How can I publish joint_states messages for my both wheels?

Thanks in advance.

// joint state publisher gazebo_ros_->getParameterBoolean ( publish_motor_joint_state_, "publish_motor_joint_state", false ); if (this->publish_motor_joint_state_) { joint_state_publisher_ = gazebo_ros_->node()->advertise<sensor_msgs::JointState>("main_wheel_states", 1000); ROS_INFO_NAMED("motor_plugin", "%s: Advertise joint_state", gazebo_ros_->info()); } My URDF(Xacro): ....

....
nilseuropa commented 4 years ago

Hi,

I've double checked and it works just fine. Could you please share the relevant part of your URDF?

snrdevs commented 4 years ago

Hi, @nilseuropa , I've build a mobile robot. It has differential drive kinematics, driven by two wheels and 4 castor wheels. When I try to implement the DC motor plugin my wheels don't turn. So I implemented the joint motor plugin. My goal is implement any of the motors, then create a control algorithm for disturbance rejection simulation on motors (via disturbance observer - I'll use Simulink at this stage). Do you offer anything? Thanks in advance. Corresponding Xacro is below:

<inertial>
  <origin xyz="0 0 0" rpy="0 0 0" />
  <!-- <origin xyz="1.6917E-07 7.8236E-05 -4.0789E-06" rpy="0 0 0" /> -->
  <mass value="1.7331" />
  <inertia
    ixx="0.0096445"
    ixy="8.1545E-09"
    ixz="2.7339E-08"
    iyy="0.018393"
    iyz="-2.1331E-07"
    izz="0.0096438" />
</inertial>     

<visual>
  <origin xyz="0 0 0" rpy="0 0 0" />
  <geometry>
    <mesh filename="package://agv_description/meshes/left_wheel.STL" />
  </geometry>
  <material name="wheel_green" />
</visual>
<collision>
  <origin xyz="0 0 0" rpy="0 0 0" />
  <geometry>
    <mesh filename="package://agv_description/meshes/left_wheel.STL" />
  </geometry>
</collision>

nilseuropa commented 4 years ago

Thank you! I've found the cause of what you were experiencing. Please pull and see if it helped.

snrdevs commented 4 years ago

Dear @nilseuropa thanks for updating the package I can make simulation with 2 motors now. But I detected another problem I'm opening a new issue 👍