Bayley Wang
/
foc-ed_in_the_bot_compact
robot
PositionSensor/PositionSensor.h@252:38644631ed97, 2018-11-13 (annotated)
- Committer:
- bwang
- Date:
- Tue Nov 13 17:46:23 2018 +0000
- Revision:
- 252:38644631ed97
- Parent:
- 219:1cfd651eb2b2
11/13/2018 12:45 - hitting <return> on empty line prints "\r>", so that hitting enter after intially connecting to the controller generates a prompt
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bwang | 15:b583cd30b063 | 1 | #ifndef __POSITIONSENSOR_H |
bwang | 15:b583cd30b063 | 2 | #define __POSITIONSENSOR_H |
bwang | 0:bac9c3a3a6ca | 3 | |
bwang | 0:bac9c3a3a6ca | 4 | class PositionSensor { |
bwang | 0:bac9c3a3a6ca | 5 | public: |
bwang | 0:bac9c3a3a6ca | 6 | virtual float GetMechPosition() {return 0.0f;} |
bwang | 0:bac9c3a3a6ca | 7 | virtual float GetElecPosition() {return 0.0f;} |
bwang | 28:ed9c1ca386fd | 8 | virtual bool IsValid() {return false;} |
bwang | 0:bac9c3a3a6ca | 9 | }; |
bwang | 0:bac9c3a3a6ca | 10 | |
bwang | 0:bac9c3a3a6ca | 11 | class PositionSensorEncoder: public PositionSensor { |
bwang | 0:bac9c3a3a6ca | 12 | public: |
bwang | 9:074575151e4b | 13 | PositionSensorEncoder(int cpr, float offset); |
bwang | 0:bac9c3a3a6ca | 14 | virtual float GetMechPosition(); |
bwang | 0:bac9c3a3a6ca | 15 | virtual float GetElecPosition(); |
bwang | 28:ed9c1ca386fd | 16 | virtual bool IsValid(); |
bwang | 0:bac9c3a3a6ca | 17 | private: |
bwang | 0:bac9c3a3a6ca | 18 | InterruptIn *ZPulse; |
bwang | 0:bac9c3a3a6ca | 19 | DigitalIn *ZSense; |
bwang | 0:bac9c3a3a6ca | 20 | void ZeroEncoderCount(void); |
bwang | 219:1cfd651eb2b2 | 21 | virtual float GetUnlimitedElecPosition(); |
bwang | 119:ad7a6af6fba3 | 22 | private: |
bwang | 9:074575151e4b | 23 | int _cpr; |
bwang | 119:ad7a6af6fba3 | 24 | int _lobes; |
bwang | 119:ad7a6af6fba3 | 25 | float _offset; |
bwang | 119:ad7a6af6fba3 | 26 | |
bwang | 28:ed9c1ca386fd | 27 | bool _valid; |
bwang | 119:ad7a6af6fba3 | 28 | float _rotations; |
bwang | 0:bac9c3a3a6ca | 29 | }; |
bwang | 0:bac9c3a3a6ca | 30 | |
bwang | 0:bac9c3a3a6ca | 31 | #endif |