robot

Dependencies:   FastPWM3 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ThrottleMapper.h Source File

ThrottleMapper.h

00001 #ifndef __THROTTLE_MAPPER_H
00002 #define __THROTTLE_MAPPER_H
00003 
00004 class ThrottleMapper {
00005 public:
00006     virtual float map(float throttle, float w) = 0;
00007 };
00008 
00009 class NullThrottleMapper : public ThrottleMapper {
00010 public:
00011     virtual float map(float throttle, float w) {if (throttle >= 0.0f) return throttle; return 0.0f;}
00012 };
00013 
00014 class InvertingThrottleMapper : public ThrottleMapper {
00015 public:
00016     InvertingThrottleMapper(ThrottleMapper *m) {mapper = m;}
00017     virtual float map(float throttle, float w) {return -mapper->map(throttle,w);}
00018 private:
00019     ThrottleMapper *mapper;
00020 };
00021 
00022 class DrivingThrottleMapper : public ThrottleMapper {
00023 public:
00024     virtual float map(float throttle, float w);
00025 private:
00026     float getMaxTqpctPlus(float w);
00027     float getMaxTqpctMinus(float w);
00028     float getZeroTqThrottle(float w);
00029 };
00030 
00031 class LimitingThrottleMapper : public ThrottleMapper {
00032 public:
00033     LimitingThrottleMapper(float wmax);
00034     virtual float map(float throttle, float w);
00035 private:
00036     float __wmax, __wlim;
00037 };
00038 
00039 class ConstantThrottleMapper : public ThrottleMapper {
00040 public:
00041     ConstantThrottleMapper(float out) {__out = out;}
00042     virtual float map(float throttle, float w) {if (throttle > 0.01f) return __out; return 0.0f;}
00043 private:
00044     float __out;
00045 };
00046 
00047 class AutoThrottleMapper : public ThrottleMapper {
00048 public:
00049     AutoThrottleMapper(float rate, float period) {_rate = rate; _period = period; val = 0.0f;}
00050     virtual float map(float throttle, float w);
00051 private:
00052     float _rate, _period;
00053     float val;
00054 };
00055 
00056 #endif