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

Revision history [back]

If I understand your problem correctly you're trying to generate an error between two angles and use than in a controller. Generally you need to wrap the result of the error calculation to be between -pi and pi as well. The easiest way to do this is using the mod function in whatever language you are using. The following will result in an error that is always between -pi and pi:

error=mod(slope-yaw+2pi,2pi)-pi

If I understand your problem correctly you're trying to generate using an error between two angles and use than in an angle to feed a controller. Generally controller you generally need to wrap the result of the error calculation to be between -pi and pi as well. The easiest way to I normally do this is using with the mod function in whatever language you are you're using. The For example, the following will result in give an error that is always between -pi and pi:pi

error=mod(slope-yaw+2pi,2pi)-pi

error=mod(slope-yaw+2*PI,2*PI)-PI