Robot
Embed:
(wiki syntax)
Show/hide line numbers
Sensor.cpp
00001 #include "Sensor.h" 00002 using namespace std; 00003 00004 Sensor::Sensor(PinName channelA,PinName channelB,float _rank, float _sFactor,float _offset, int _pulsesPerRev):Encoder(channelA,channelB, NC, _pulsesPerRev){ 00005 rank = _rank; 00006 scale_factor = _sFactor; 00007 offset = _offset; 00008 } 00009 00010 float Sensor::readSensor(){ 00011 return (Encoder.getRevolutions()); 00012 } 00013 float Sensor::computevalue(int value){ 00014 return (value*scale_factor-offset); 00015 } 00016 00017 float Sensor::estimatevelocity (float prevValue,float sampling){ 00018 return ((Encoder.getRevolutions()-prevValue)/sampling); 00019 }
Generated on Sun Jul 31 2022 05:13:07 by
1.7.2