Control program for a four-legged 12 axis robot.

Dependencies:   CircularBuffer Servo Terminal mbed Radio

Committer:
pclary
Date:
Tue Sep 30 07:31:07 2014 +0000
Revision:
22:9cf770fb12f8
Parent:
17:4ec59e8b52a6
Hacked together a better demonstration

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pclary 3:6fa07ceb897f 1 #ifndef ROBOTLEG_H
pclary 3:6fa07ceb897f 2 #define ROBOTLEG_H
pclary 3:6fa07ceb897f 3
pclary 3:6fa07ceb897f 4 #include "mbed.h"
pclary 3:6fa07ceb897f 5 #include "Servo.h"
pclary 3:6fa07ceb897f 6 #include "Matrix.h"
pclary 3:6fa07ceb897f 7
pclary 3:6fa07ceb897f 8
pclary 3:6fa07ceb897f 9
pclary 3:6fa07ceb897f 10 class RobotLeg
pclary 3:6fa07ceb897f 11 {
pclary 3:6fa07ceb897f 12 public:
pclary 8:db453051f3f4 13 RobotLeg(PinName thetaPin, PinName phiPin, PinName psiPin, bool start = true);
pclary 3:6fa07ceb897f 14 void setDimensions(float a, float b, float c, float d);
pclary 3:6fa07ceb897f 15 void setAngleOffsets(float oth, float oph, float ops);
pclary 5:475f67175510 16 void setStepCircle(float xc, float yc, float zc, float rc);
pclary 3:6fa07ceb897f 17 vector3 getPosition();
pclary 17:4ec59e8b52a6 18 float getStepDistance();
pclary 3:6fa07ceb897f 19 bool move(vector3 dest);
pclary 3:6fa07ceb897f 20 void step(vector3 dest);
pclary 9:a6d1502f0f20 21 vector3 reset(float f);
pclary 5:475f67175510 22 bool update(const matrix4& deltaTransform);
pclary 11:9ee0214bd410 23 void apply();
pclary 11:9ee0214bd410 24 bool getStepping();
pclary 3:6fa07ceb897f 25
pclary 3:6fa07ceb897f 26 Servo theta, phi, psi;
pclary 6:0163f2737cc6 27 vector3 nDeltaPosition;
pclary 3:6fa07ceb897f 28
pclary 3:6fa07ceb897f 29 protected:
pclary 5:475f67175510 30 float thetaAngle, phiAngle, psiAngle;
pclary 5:475f67175510 31 float circleRadius;
pclary 3:6fa07ceb897f 32 float a, b, c, d;
pclary 3:6fa07ceb897f 33 float oth, oph, ops;
pclary 6:0163f2737cc6 34 float stepDelta, stepTime, stepHeight;
pclary 5:475f67175510 35 vector3 circleCenter;
pclary 3:6fa07ceb897f 36 vector3 position;
pclary 3:6fa07ceb897f 37 vector3 stepA;
pclary 3:6fa07ceb897f 38 vector3 stepB;
pclary 11:9ee0214bd410 39 vector3 newPosition;
pclary 3:6fa07ceb897f 40
pclary 5:475f67175510 41 enum state_t
pclary 3:6fa07ceb897f 42 {
pclary 3:6fa07ceb897f 43 neutral,
pclary 3:6fa07ceb897f 44 stepping
pclary 3:6fa07ceb897f 45 };
pclary 3:6fa07ceb897f 46
pclary 5:475f67175510 47 state_t state;
pclary 3:6fa07ceb897f 48
pclary 3:6fa07ceb897f 49 Timer stepTimer;
pclary 3:6fa07ceb897f 50
pclary 3:6fa07ceb897f 51 };
pclary 3:6fa07ceb897f 52
pclary 3:6fa07ceb897f 53 #endif // ROBOTLEG_H