Hello everyone, I have recently tried making a drone using an Arduino Uno as the brain. So far I have programmed an AltIMU-10 v5 to give me Quaternion values using an AHRS program I found online. At this stage in my drone development, I need to be able to input quaternion values into a PID loop to control the motors. Unfortunately, I have no idea how to do this. I know that it is possible, it's just the know-how I'm lacking. Any advice, code, or examples would be most appreciated.
What is the "PID loop" in your drone supposed to do?
For keeping the drone level, one popular approach to calculate pitch and roll angles from the quaternion, constraining those to be zero using two nested PID loops.
A web search for "drone PID control" turns up a lot of reading material.
Thanks for responding.
The PID loop will be used for keeping the drone level as well hold the yaw position. I want to be able to use quaternions because they take care of gimbal lock and the roll and pitch compensation for the compass (yaw). On the web, it seems like there are only examples of PID loops with one input value whereas a quaternion is composed of four values (Q=[w,x,y,z]). What I'm trying to find is how I implement a PID loop/loops to take in the quaternion value input and give back an ESC output for the motors.
Did you not notice the second sentence in post #2?
One PID loop controls one variable.
PS: there are three sentences in post #2.
are you expecting a singular PID implementation that operates on the 4 quaternion values and outputs 2 corrections for roll and pitch?
wouldn't you determine the pitch from the quaternion and use that as an input to one PID loop that outputs a pitch correction and simillary a 2nd PID loop that operates on the roll value determined from the quaternion?
Hello, sorry for the late response. I needed to think the situation out further. I have concluded that I will use a PID loop for each axis (roll, pitch, and yaw) after converting the quaternion to Euler angles. I was making things messy by trying to keep the quaternion value. Thank you for helping me see the obvious.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.