Six crescent shaped legs

Dependencies:   mbed

EncoderMotor.hpp

Committer:
sim642
Date:
2016-04-14
Revision:
18:1437610bea8b
Parent:
17:cb8ad2fc76e5
Child:
22:bfc79c6ea2fd

File content as of revision 18:1437610bea8b:

#ifndef ENCODER_MOTOR_H
#define ENCODER_MOTOR_H

#include "Motor.hpp"
#include "SpeedEncoder.hpp"
#include "LerpSmoother.hpp"
#include "PIDController.hpp"
#include "SyncGroup.hpp"
#include <limits>

class EncoderMotor : public Motor
{
public:
    enum Mode
    {
        NoMode,
        SpeedMode,
        TurnMode
    };
    
    EncoderMotor(MotorData nData, EncoderData encData, PIDData speedPIDData, PIDData turnPIDData, SyncGroup *nSync = NULL);
    void setup();
    
    virtual void drive(float speed);
    virtual void rotate(float turn, float speedLimit = std::numeric_limits<float>::max());
    
private:
    void tick();

    Ticker ticker;
    
    SpeedEncoder encoder;
    LerpSmoother speedSmoother;
    
    Mode mode;
    
    PIDController speedPID;
    float setSpeed;
    
    PIDController turnPID;
    float setTurn;
    float turnSpeedLimit;
    
    SyncGroup *sync;
};

#endif // ENCODER_MOTOR_H