How to get instantaneous velocity value when using gazebo ros_diff_drive plugin

asked 2018-11-29 23:31:41 -0600

I am using the following gazebo plugin to model a diff drive mobile robot in gazebo and then doing a PID for velocity control of the mobile robot.

I understand that in order to do a PID controller for the movement, i need to sense the current velocity of the robot. and get the error between that and the reference velocity.

Problem is then how do I get the current velocity?

<gazebo>
    <plugin name="next_controller" filename="libgazebo_ros_diff_drive.so">
      <commandTopic>cmd_vel</commandTopic>
      <odometryTopic>odom</odometryTopic>
      <odometryFrame>odom</odometryFrame>
      <robotBaseFrame>base_link</robotBaseFrame>
      <publishWheelTF>false</publishWheelTF>
      <publishWheelJointState>true</publishWheelJointState>
      <legacyMode>false</legacyMode>
      <updateRate>100</updateRate>
      <leftJoint>wheel_left_joint</leftJoint>
      <rightJoint>wheel_right_joint</rightJoint>
      <wheelSeparation>0.343</wheelSeparation>
      <wheelDiameter>0.164</wheelDiameter>
      <wheelAcceleration>1</wheelAcceleration>
      <wheelTorque>10</wheelTorque>
    </plugin>
</gazebo>
edit retag flag offensive close merge delete