Thank you for your time, we really appreciate your help.
We are not familiar with quaternions and we are trying to understand how to solve this problem:
we are trying to make a drone look forward by implementing a reward function that assigns a penalty based on the variation between the orientation of the camera and the direction we want the drone to look at.
Basically, we want to act on the yaw and penalize the drone if it changes it too much from the correct orientation.
We have:
- The drone z,x,y coordinates
- The attitude expressed as a quaternion
- The linear velocity
- The angular velocity
We have several ideas for the constraints and the penalties to apply, but we don't know how implement them.
For example:
- How can we calculate the yaw variation using quaternions?
- how can we identify a range for the yaw? In order to penalize the drone if its yaw value goes beyond this range
- is it feasable to create a region in the space (like a cone) which identifies the drone's legal movement? Like in this picture:

Vision from same ax perspective:
