Six crescent shaped legs

Dependencies:   mbed

Committer:
sim642
Date:
Tue Apr 12 13:05:12 2016 +0000
Revision:
11:a0976d3b33c5
Parent:
9:31e850271c4a
Child:
12:8de7f5d56fe4
Make EncodeMotor create its own encoder

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phairero 0:0b7259fdb68a 1 #include "mbed.h"
sim642 3:2235787e78c4 2 #include "EncoderMotor.hpp"
sim642 3:2235787e78c4 3 #include "PIDController.hpp"
sim642 7:8dcdb39efc0e 4 #include "LerpSmoother.hpp"
phairero 0:0b7259fdb68a 5
phairero 0:0b7259fdb68a 6 InterruptIn bt(USER_BUTTON);
sim642 2:cf0147952fb9 7 Serial pc(USBTX, USBRX);
sim642 2:cf0147952fb9 8
sim642 9:31e850271c4a 9 MotorData mData = {PB_0, PC_1, PC_0};
sim642 8:c3af2a1c206c 10 EncoderData encData = {PA_0, PA_1, 600};
sim642 8:c3af2a1c206c 11
sim642 7:8dcdb39efc0e 12 LerpSmoother speedSmoother(0.3f);
sim642 4:4d54794b99a5 13 //PIDController ec(0.2, 0.1, 0.01);
sim642 5:7f800f61cb13 14 PIDController ec(0.3, 2.0, 0.02);
sim642 4:4d54794b99a5 15 //PIDController ec(0.75, 2.0, 0.015);
sim642 5:7f800f61cb13 16 //PIDController ec(0.8, 1.5, 0.017);
sim642 5:7f800f61cb13 17 PIDController ecRot(5.0, 0.1, 0.04);
sim642 11:a0976d3b33c5 18 EncoderMotor m(mData, encData, speedSmoother, ec, ecRot);
sim642 4:4d54794b99a5 19 //Motor m(PB_0, PC_1, PC_0);
phairero 0:0b7259fdb68a 20
sim642 2:cf0147952fb9 21 void rise()
sim642 2:cf0147952fb9 22 {
sim642 2:cf0147952fb9 23 pc.printf("rise\n");
sim642 3:2235787e78c4 24 m.drive(0);
sim642 2:cf0147952fb9 25 }
phairero 0:0b7259fdb68a 26
sim642 2:cf0147952fb9 27 void fall()
sim642 2:cf0147952fb9 28 {
sim642 2:cf0147952fb9 29 pc.printf("fall\n");
sim642 4:4d54794b99a5 30 m.drive(0.5);
sim642 2:cf0147952fb9 31 }
phairero 1:8b0322a353f4 32
sim642 2:cf0147952fb9 33 int main()
sim642 3:2235787e78c4 34 {
sim642 3:2235787e78c4 35 bt.rise(&rise);
sim642 3:2235787e78c4 36 bt.fall(&fall);
sim642 3:2235787e78c4 37
sim642 8:c3af2a1c206c 38 //m.setup();
sim642 3:2235787e78c4 39
sim642 5:7f800f61cb13 40 float rot;
sim642 5:7f800f61cb13 41
sim642 2:cf0147952fb9 42 while(1)
sim642 2:cf0147952fb9 43 {
sim642 11:a0976d3b33c5 44 //pc.printf("%d\n", e.getCount());
sim642 8:c3af2a1c206c 45 wait(0.1);
sim642 5:7f800f61cb13 46 //pc.scanf("%f %f %f", &ec.Kp, &ec.Ki, &ec.Kd);
sim642 5:7f800f61cb13 47 //pc.scanf("%f %f %f %f", &ecRot.Kp, &ecRot.Ki, &ecRot.Kd, &rot);
sim642 8:c3af2a1c206c 48
sim642 8:c3af2a1c206c 49 //pc.scanf("%f", &rot);
sim642 8:c3af2a1c206c 50 //m.rotate(rot);
phairero 0:0b7259fdb68a 51 }
sim642 2:cf0147952fb9 52 }