Control program for a four-legged 12 axis robot.

Dependencies:   CircularBuffer Servo Terminal mbed Radio

RobotLeg.h

Committer:
pclary
Date:
2012-11-03
Revision:
3:6fa07ceb897f
Child:
5:475f67175510

File content as of revision 3:6fa07ceb897f:

#ifndef ROBOTLEG_H
#define ROBOTLEG_H

#include "mbed.h"
#include "Servo.h"
#include "Matrix.h"



class RobotLeg
{
public:
    RobotLeg(PinName thetaPin, PinName phiPin, PinName psiPin);
    void setDimensions(float a, float b, float c, float d);
    void setAngleOffsets(float oth, float oph, float ops);
    vector3 getPosition();
    bool move(vector3 dest);
    void step(vector3 dest);
    void update(const matrix4& deltaTransform);

    Servo theta, phi, psi;
    float thetaAngle, phiAngle, psiAngle;

protected:
    float a, b, c, d;
    float oth, oph, ops;
    float stepDelta, stepPeriod, stepHeight;
    vector3 position;
    vector3 stepA;
    vector3 stepB;
    
    enum LegState
    {
        neutral,
        stepping
    };
    
    LegState state;

    Timer stepTimer;
    
};

#endif // ROBOTLEG_H