Hello, I hope you can help me with this problem.
I am looking at making a purpose build programmed robot which can fly. So like a Quadcopter but without the need to control it by a remote. It would be pre-programmed, or updated via Bluetooth/Wifi.
I have some code which allows me to see the Yaw, Pitch, and Roll, of the robot. But I need it to be stable while in the air. So using PMW pins on a nano I want to control each motor to keep the robot level.
I am guessing this would be achieved by some logic based on the Pitch/Roll combined, and it would adjust the speed of each motor. I am not sure how to go about this.
The second issue is even if I have the code required to keep it in the air level, I need to adjust the altitude using HM-04 sonic sensor, which would need to adjust all motors the correct speed to keep it at a constant/ish level.
I have looked at many examples for quadcopter codes dating back to 2011. But they all consist controllers which I am not really looking to do. So cannot replicate the math.
So, using PWM of pins 2,4,5,6 of the motors, and the constant data from the MPU how do I control the speed of each.
Here is the example of the data:
YAW: 74.2 Pitch: 8.2 Roll: 0.5 -- Flat
YAW: 74.2 Pitch: 29 Roll: -28 -- \ <--->Pointing Down
YAW: 74.2 Pitch: -17 Roll: -32 -- / <--->Pointing Down
YAW: 74.2 Pitch: 22 Roll: 30 -- \ <--->Pointing Up
YAW: 74.2 Pitch: -23 Roll: 26 -- / <--->Pointing Up
These figures change each time I move the angle of the base of the robot.
1 2
\ / <---- Motor 1 to 4
/
3 4
So to keep this level the speed of each motor would need to keep the Pitch / Roll as close to 0 all the time.
I will need the robot to move, but at this point, I just want to make it so it will hover level at a height specified.
Is this possible using PWM as I have read ?