ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

# cmd_vel linear and angular relationship

Hi All,

I'm using rqt robot steering to output cmd_vel message which I subscribe to and they control the power of the motors.

Linear is fine and +/-100% is controlling the motors fed and reverse okay. How should I combine that with the rotational input such that the effect is to increase or decrease the rate of turn? Just something simple is fine, this is a 2 wheeled robot.

The examples I keep finding on the internet seem to be simple key based designs. i.e. F=Fwd/L=Left etc...

Many Thanks

Mark

edit retag close merge delete

Sort by » oldest newest most voted

I think the following is what you're looking for. I'm not familiar with rqt's robot steering, so I'm assuming you're using geometry_msgs/Twist messages. If so, and assuming a differential drive robot, the usual method requires knowledge of the wheel separation (i.e., axle length) and wheel diameters.

void twistCb(geometry_msgs::TwistConstPtr &msg) {
transVelocity = msg->linear.x;
rotVelocity = msg->angular.z;
double velDiff = (wheelSep * rotVelocity) / 2.0;
double leftPower = (transVelocity + velDiff) / wheelRadius;
double rightPower = (transVelocity - velDiff) / wheelRadius;
}

more

Thanks Kramer - steering passes through rad/s so I can convert that m/s (v = ωr)

( 2014-11-18 03:51:40 -0600 )edit

Actually if I add of subtract (left or right) cos of the angle that should work yes?

more