Improved encoder support
This commit is contained in:
parent
b86484d59d
commit
d22fc8e244
2
AbsoluteEncoder.cpp
Normal file
2
AbsoluteEncoder.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#include "AbsoluteEncoder.h"
|
||||
|
@ -5,11 +5,12 @@
|
||||
namespace Passer {
|
||||
namespace RoboidContol {
|
||||
|
||||
class FeedbackServo : public ServoMotor {
|
||||
class AbsoluteEncoder {
|
||||
public:
|
||||
FeedbackServo();
|
||||
AbsoluteEncoder() {}
|
||||
|
||||
virtual float GetActualAngle() = 0;
|
||||
virtual float GetActualVelocity() = 0;
|
||||
};
|
||||
|
||||
} // namespace RoboidContol
|
19
Encoder.cpp
19
Encoder.cpp
@ -1,18 +1,21 @@
|
||||
/*
|
||||
#include "Encoder.h"
|
||||
|
||||
Encoder::Encoder(unsigned char pulsesPerRevolution,
|
||||
unsigned char distancePerRotation) {
|
||||
//: Encoder::Encoder() {
|
||||
IncrementalEncoder::IncrementalEncoder(unsigned char pulsesPerRevolution,
|
||||
unsigned char distancePerRotation) {
|
||||
this->pulsesPerRevolution = pulsesPerRevolution;
|
||||
this->distancePerRevolution = distancePerRotation;
|
||||
}
|
||||
|
||||
int Encoder::GetPulseCount() { return 0; }
|
||||
int IncrementalEncoder::GetPulseCount() { return 0; }
|
||||
|
||||
float Encoder::GetDistance() { return 0; }
|
||||
float IncrementalEncoder::GetDistance() { return 0; }
|
||||
|
||||
float Encoder::GetPulsesPerSecond(float currentTimeMs) { return 0; }
|
||||
float IncrementalEncoder::GetPulsesPerSecond(float currentTimeMs) { return 0; }
|
||||
|
||||
float Encoder::GetRevolutionsPerSecond(float currentTimeMs) { return 0; }
|
||||
float IncrementalEncoder::GetRevolutionsPerSecond(float currentTimeMs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Encoder::GetSpeed(float currentTimeMs) { return 0; }
|
||||
float IncrementalEncoder::GetSpeed(float currentTimeMs) { return 0; }
|
||||
*/
|
20
Encoder.h
20
Encoder.h
@ -1,19 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "IncrementalEncoder.h"
|
||||
|
||||
namespace Passer {
|
||||
namespace RoboidControl {
|
||||
|
||||
/// @brief An Encoder measures the rotations of an axle using a rotary sensor
|
||||
/// Some encoders are able to detect direction, while others can not.
|
||||
class Encoder {
|
||||
// Deprecated, use explicit IncrementalEncoder in the future
|
||||
using Encoder = IncrementalEncoder;
|
||||
|
||||
/*
|
||||
/// @brief An Encoder measures the rotations of an axle using a rotary
|
||||
/// sensor Some encoders are able to detect direction, while others can not.
|
||||
class IncrementalEncoder {
|
||||
public:
|
||||
/// @brief Creates a sensor which measures distance from pulses
|
||||
/// @param pulsesPerRevolution The number of pulse edges which make a
|
||||
/// full rotation
|
||||
/// @param distancePerRevolution The distance a wheel travels per full
|
||||
/// rotation
|
||||
Encoder(unsigned char pulsesPerRevolution = 1,
|
||||
unsigned char distancePerRevolution = 1);
|
||||
IncrementalEncoder(unsigned char pulsesPerRevolution = 1,
|
||||
unsigned char distancePerRevolution = 1);
|
||||
|
||||
/// @brief Get the total number of pulses since the previous call
|
||||
/// @return The number of pulses, is zero or greater
|
||||
@ -45,7 +51,7 @@ public:
|
||||
/// meter
|
||||
unsigned char distancePerRevolution = 1;
|
||||
};
|
||||
|
||||
*/
|
||||
} // namespace RoboidControl
|
||||
} // namespace Passer
|
||||
using namespace Passer::RoboidControl;
|
||||
using namespace Passer::RoboidControl;
|
||||
|
@ -1,3 +0,0 @@
|
||||
#include "FeedbackServo.h"
|
||||
|
||||
FeedbackServo::FeedbackServo() {}
|
19
IncrementalEncoder.cpp
Normal file
19
IncrementalEncoder.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "Encoder.h"
|
||||
|
||||
IncrementalEncoder::IncrementalEncoder(unsigned char pulsesPerRevolution,
|
||||
unsigned char distancePerRotation) {
|
||||
this->pulsesPerRevolution = pulsesPerRevolution;
|
||||
this->distancePerRevolution = distancePerRotation;
|
||||
}
|
||||
|
||||
int IncrementalEncoder::GetPulseCount() { return 0; }
|
||||
|
||||
float IncrementalEncoder::GetDistance() { return 0; }
|
||||
|
||||
float IncrementalEncoder::GetPulsesPerSecond(float currentTimeMs) { return 0; }
|
||||
|
||||
float IncrementalEncoder::GetRevolutionsPerSecond(float currentTimeMs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
float IncrementalEncoder::GetSpeed(float currentTimeMs) { return 0; }
|
Loading…
x
Reference in New Issue
Block a user