ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The link to the motor says it is 312RPM which would have a no-load max RPM of 32rad/sec. Your encoder however is likely on the motor end of the gear box and not on the wheel end, so you need to add in the gearing conversion before you try to convert encoder values to wheel rotation.

Then after you sort out how the gearing will impact encoder speed to wheel speed, you should take another look at this:

 if(joint_velocity_command_[0] < -1) 
      joint_velocity_command_[0] = -1;
  if(joint_velocity_command_[0] > 1)
      joint_velocity_command_[0] = 1;
  if(joint_velocity_command_[1] < -1)
          joint_velocity_command_[1] = -1;
  if(joint_velocity_command_[1] > 1)
      joint_velocity_command_[1] = 1;



float myMap(float x, float in_min, float in_max, float out_min, float out_max) {
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

 float joint1_vel = myMap(joint_velocity_command_[0],-1,1,-255,255);

This limits inputs to -1 through +1, but you're attempting to input 10. By my accounting then the output from the equation should be 255 to the PWM <-- just as fast as it can go - so as far as I can tell, everything seems to be working correctly. Or rather, it's doing just what you told it to.

BTW: Regarding you're question about why ROS is not limiting speed to the max and min you set in the YAML file, it doesn't work the way you're thinking. It will limit the the path planning velocities(CMD_VEL) to the max and min in the YAML file but it is up to the HW driver to respond properly to the CMD_VEL. The path planner will not actively scale CMD_VEL if the HW is out of control.