I am working on an application, a simulator, where the quadrotor flies from point to point. In my code, I implemented a function to compute yaw using the atan2 function. But when the quadrotor rotates 360 °, it does not move along the shortest path, but it moves around 360 ° to reach a new direction.
Here I posted a video. Take a look at his behavior when it is 360 °.
Ok guys now the full function:
geometry_msgs::Pose getYaw( double x1, double x2, double y1, double y2 ) { geometry_msgs::Pose output_trajectory; double yaw = atan2( ( y2 - y1 ), ( x2 - x1 ) ); if( yaw < 0.0f )
where tf :: createQuaternionMsgFromYaw is the library from the ROS structure. Here's the job: link . geometry_msgs :: A pose is just a container: a link .
*: here I read related topics and questions here on stackoverflow, and this function displays the returned atan2 output at 0 ° -360 °
UPDATE: here is an excerpt from the yaw value:
... Yaw: 131.3678 Yaw: 133.3495 Yaw: 135.6426 Yaw: 138.3442 Yaw: 141.5859 Yaw: 145.5487 Yaw: 150.4813 Yaw: 156.7167 Yaw: 164.6657 Yaw: 174.7288 Goal reached Moving to the 3 waypoint Yaw: 174.7288 Yaw: 186.4225 Yaw: 196.3789 Yaw: 204.1349 Yaw: 210.1296 Yaw: 214.7946 Yaw: 218.4716 Yaw: 221.4110 Yaw: 223.7921 Yaw: 225.7431 Yaw: 227.3565 ...
As you can see, the intersection is “continuity”, but it does not turn right from 174 ° to 186 ° (the smallest).
What I expect is that the quadrotor moves with small settings and rotates around 360 ° several degrees.
How can I get rid of this problem? I need a smooth yaw motion in my application. Relations