forked from logzhan/RobotHardware-UESTC
36 lines
745 B
C
36 lines
745 B
C
|
#ifndef PIBOT_ENCODER_IMP_H_
|
||
|
#define PIBOT_ENCODER_IMP_H_
|
||
|
|
||
|
#include "encoder.h"
|
||
|
|
||
|
//编码器实现 编码器原理具体可以参考https://www.jianshu.com/p/068fb9882655
|
||
|
class EncoderImp : public Encoder
|
||
|
{
|
||
|
public:
|
||
|
EncoderImp(unsigned char num, bool _reverse=0);
|
||
|
|
||
|
//初始化
|
||
|
virtual void init();
|
||
|
|
||
|
//清除编码器
|
||
|
virtual void clear();
|
||
|
|
||
|
//获取累计编码器值
|
||
|
virtual long get_total_count();
|
||
|
|
||
|
//获取编码器变化值, 用于pid计算
|
||
|
virtual long get_increment_count_for_dopid();
|
||
|
|
||
|
//获取编码器变化值, 用于odom计算
|
||
|
virtual long get_increment_count_for_odom();
|
||
|
|
||
|
unsigned char get_reverse(){return reverse;}
|
||
|
private:
|
||
|
bool reverse;
|
||
|
unsigned char num;
|
||
|
long pid_pos, odom_pos;
|
||
|
float total_count;
|
||
|
};
|
||
|
|
||
|
#endif
|