robot

Dependencies:   FastPWM3 mbed

ThrottleMapper/ThrottleMapper.h

Committer:
bwang
Date:
2017-05-04
Revision:
155:7c6005933d4c
Parent:
110:c66f359b6932
Child:
160:6948bb7bcabd

File content as of revision 155:7c6005933d4c:

#ifndef __THROTTLE_MAPPER_H
#define __THROTTLE_MAPPER_H

class ThrottleMapper {
public:
    virtual float map(float throttle, float w) = 0;
};

class NullThrottleMapper : public ThrottleMapper {
public:
    virtual float map(float throttle, float w) {if (throttle >= 0.0f) return throttle; return 0.0f;}
};

class DrivingThrottleMapper : public ThrottleMapper {
public:
    virtual float map(float throttle, float w);
private:
    float getMaxTqpctPlus(float w);
    float getMaxTqpctMinus(float w);
    float getZeroTqThrottle(float w);
};

class LimitingThrottleMapper : public ThrottleMapper {
public:
    LimitingThrottleMapper(float wmax);
    virtual float map(float throttle, float w);
private:
    float __wmax, __wlim;
};

class ConstantThrottleMapper : public ThrottleMapper {
public:
    ConstantThrottleMapper(float out) {__out = out;}
    virtual float map(float throttle, float w) {if (throttle > 0.01f) return __out; return 0.0f;}
private:
    float __out;
};
#endif