# GIMBAL LOCK: How to solve via DCM/ quaternion ?

Hi People,

This is a simple question I am having for some experts out there. I am getting a GIMBAL LOCK problem when I pitch my APM-1 board 90 degrees (downwards), the roll and yaw values becomes crazy.

My current implementation uses ahrs.pitch_sensor (euler angle) values.

Can anyone tell me how to prevent this problem using  ahrs.get_dcm_matrix() or using the Quaternions (in this case I am not sure how to call update, as this class does not have one).

I am looking for a solution to this problem with logic and\or code. HELP is really appreciated!

Views: 1620

### Replies to This Discussion

As I understand it, there is a fundamental problem with converting the dcm rotation matrix to roll, pitch, yaw.  If you stay with with the DCM rotation matrix then you don't have this problem.

Hi @Matthew,

Thanks for your reply. But in my case I need the pitch and yaw angles to move the corresponding servo(s) of the camera gimbal. How do I achieve this with the DCM rotation matrix?

Could you please help me to deal with this. I will be too happy if I get this to work. Thank you!

Hi Shyam,

In case anyone who read this thread is still interested, you and I figured out that you were running into a gimbal lock problem with Euler angles. There were a couple of possible solutions, including using direction cosines instead of Euler angles. However, you and I came up with a simple solution that allowed you to use Euler angles, which you posted here.

Best regards,

Bill Premerlani

1

2

3

4

5

6

7

8

9

10

## Groups

280 members

1123 members

3163 members

1 member

• ### ArduBoat User Group

258 members

Season Two of the Trust Time Trial (T3) Contest
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here