Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
encoderBase.cpp
- Committer:
- Weranest
- Date:
- 2018-04-18
- Revision:
- 0:5ffcaef3e603
File content as of revision 0:5ffcaef3e603:
/*#include "mbed.h"
#include "QEI.h"
#include "pins.cpp"
#define ENCODER_PULSE 256 //per manual
#define GEAR_RATIO
#define SAMPLE_TIME 1.0f //user defined
#define WHEEL_DISTANCE //need to measure that
//these lines setup the encoders for both wheels
QEI encoderRight(channelARight, channelBRight, channelIRight, ENCODER_PULSE);
QEI encoderLeft(channelALeft, channelBLeft, channelILeft, ENCODER_PULSE);
//main wheel class, the subclasses should follow later
class Wheel{
int currentPulses, previousPulses;
public:
float wheelVelocity(float, int){
}
private:
float sampleTime= SAMPLE_TIME;
int gearRatio = GEAR_RATIO;
float encoderVelocity(){
return (currentEncoderTicks-previousEncoderTicks)/sampleTime;
}
} wheelRight, wheelLeft;
class WheelLeft
//call this for speed, linear and angular
class Buggy{
public:
float speedLinear(float wheelVelocityRight, float wheelVelocityLeft){
return (wheelVelocityRight+wheelVelocityLeft)/2;
}
float speedAngular(float wheelVelocityRight, float wheelVelocityLeft){
return (wheelVelocityRight-wheelVelocityLeft)/WHEEL_DISTANCE;
}
}
int encoderTicks(){
previousEncoderTicks=currentEncoderTicks;
currentEncoderTicks=
}
*/
