robot

Dependencies:   FastPWM3 mbed

DQMapper/DQMapper.h

Committer:
bwang
Date:
2017-02-28
Revision:
79:d0b1bb3dcf68
Parent:
45:cf8ad81fb0f0
Child:
98:1051c4103900

File content as of revision 79:d0b1bb3dcf68:

#ifndef __DQ_MAPPER_H
#define __DQ_MAPPER_H

class DQMapper {
public:
    virtual void map(float torque_percent, float w, float *d, float *q) = 0;
};

class QOnlyMapper : public DQMapper {
public:
    QOnlyMapper(float kt, float tmax) {_kt = kt; _tmax = tmax;}
    virtual void map(float torque_percent, float w, float *d, float *q) {*d = 0; *q = torque_percent * _tmax / _kt;}
private:
    float _kt;
    float _tmax;
};

class LinearNoFWMapper : public DQMapper {
public:
    LinearNoFWMapper(float kt, float tmax, float lambda) {_kt = kt; _tmax = tmax; _lambda = lambda;}
    virtual void map(float torque_percent, float w, float *d, float *q);
private:
    float _kt;
    float _tmax;
    float _lambda;
};

class LutMapper : public DQMapper {
public:
    virtual void map(float torque_percent, float w, float *d, float *q);
};

#endif