Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MPU6050 PID Quadcopter Servo mbed
Revision 0:894ba50f267c, committed 2015-02-18
- Comitter:
- moklumbys
- Date:
- Wed Feb 18 23:44:09 2015 +0000
- Child:
- 1:40ade596b1e3
- Commit message:
- First attempt, still did not include MPU6050, but started including something...
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Quadcopter.lib Wed Feb 18 23:44:09 2015 +0000 @@ -0,0 +1,1 @@ +Quadcopter#341a08dbf9ba
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Wed Feb 18 23:44:09 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/Servo/#36b69a7ced07
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Feb 18 23:44:09 2015 +0000
@@ -0,0 +1,62 @@
+#include "mbed.h"
+#include "Quadcopter.h"
+
+#define MAX_CALIBRATE 1.0
+#define MIN_CALIBRATE 0.35
+
+#define FL 0 // Front left
+#define FR 1 // Front right
+#define BL 2 // back left
+#define BR 3 // back right
+//--------------------------------ALL THE FUNCTION HEADERS-----------------------
+float map(float x, float in_min, float in_max, float out_min, float out_max);
+//---------------------------------------END-------------------------------------
+
+Quadcopter quad (p21, p22, p23, p24);
+Serial pc(USBTX, USBRX); // tx, rx
+
+int main() {
+ float pitchDiff;
+ float rollDiff;
+ float speed[4];
+ float actSpeed[4];
+
+ quad.calibrate(MIN_CALIBRATE, MAX_CALIBRATE);
+ while(1) {
+ for (float height = 0.0; height < 0.5; height+=0.05){
+ for (int i = 0; i < 4; i++){
+ speed[i] = height;
+ }
+ quad.run (speed);
+ wait(0.1);
+ }
+ for (uint16_t i = 0; i < 600; i++)
+ {
+ rollPID.setProcessValue (imu.roll);
+ rollPID.setProcessValue (imu.pitch);
+
+ pitchDif = pitchPID.compute();
+ rollDif = rollPID.compute();
+
+ quad.stabilise(speed, actSpeed, rollDiff, pitchDiff);
+ quad.run(actSpeed);
+
+ wait (0.01);
+ }
+
+ for (float height = 0.5; height > 0.0; height-=0.05){
+ for (int i = 0; i < 4; i++){
+ speed[i] = height;
+ }
+ quad.run (speed);
+ wait(0.1);
+ }
+ wait(1);
+ }
+}
+
+//-----------------------------Mapping function-----------------------------
+float map(float x, float in_min, float in_max, float out_min, float out_max)
+{
+ return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Feb 18 23:44:09 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac \ No newline at end of file