Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can easily convert to Euler angle from quaternion value using something like this:

geometry_msgs::Vector3 rpy_data;
tf::Quaternion tmp_quat;
tf::quaternionMsgToTF(imu_msg.orientation, tmp_quat);
tf::Matrix3x3(tmp_quat).getRPY(rpy_data.x, rpy_data.y, rpy_data.z);

Then you can have some logic to detect when roll or pitch value exceeds some threshold to consider "turn over"

If you are familiar with tf, there is another way. You might want to detect whether the z-vector of your robot is negative. If so, you can rotate a unit vector in z axis (0,0,1) using the quaternion you have (function transformVector should to the job) and check the resulted vector if z value is negative.