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 Passer {
|
||||||
namespace RoboidContol {
|
namespace RoboidContol {
|
||||||
|
|
||||||
class FeedbackServo : public ServoMotor {
|
class AbsoluteEncoder {
|
||||||
public:
|
public:
|
||||||
FeedbackServo();
|
AbsoluteEncoder() {}
|
||||||
|
|
||||||
virtual float GetActualAngle() = 0;
|
virtual float GetActualAngle() = 0;
|
||||||
|
virtual float GetActualVelocity() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RoboidContol
|
} // namespace RoboidContol
|
19
Encoder.cpp
19
Encoder.cpp
@ -1,18 +1,21 @@
|
|||||||
|
/*
|
||||||
#include "Encoder.h"
|
#include "Encoder.h"
|
||||||
|
|
||||||
Encoder::Encoder(unsigned char pulsesPerRevolution,
|
IncrementalEncoder::IncrementalEncoder(unsigned char pulsesPerRevolution,
|
||||||
unsigned char distancePerRotation) {
|
unsigned char distancePerRotation) {
|
||||||
//: Encoder::Encoder() {
|
|
||||||
this->pulsesPerRevolution = pulsesPerRevolution;
|
this->pulsesPerRevolution = pulsesPerRevolution;
|
||||||
this->distancePerRevolution = distancePerRotation;
|
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; }
|
||||||
|
*/
|
18
Encoder.h
18
Encoder.h
@ -1,19 +1,25 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "IncrementalEncoder.h"
|
||||||
|
|
||||||
namespace Passer {
|
namespace Passer {
|
||||||
namespace RoboidControl {
|
namespace RoboidControl {
|
||||||
|
|
||||||
/// @brief An Encoder measures the rotations of an axle using a rotary sensor
|
// Deprecated, use explicit IncrementalEncoder in the future
|
||||||
/// Some encoders are able to detect direction, while others can not.
|
using Encoder = IncrementalEncoder;
|
||||||
class Encoder {
|
|
||||||
|
/*
|
||||||
|
/// @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:
|
public:
|
||||||
/// @brief Creates a sensor which measures distance from pulses
|
/// @brief Creates a sensor which measures distance from pulses
|
||||||
/// @param pulsesPerRevolution The number of pulse edges which make a
|
/// @param pulsesPerRevolution The number of pulse edges which make a
|
||||||
/// full rotation
|
/// full rotation
|
||||||
/// @param distancePerRevolution The distance a wheel travels per full
|
/// @param distancePerRevolution The distance a wheel travels per full
|
||||||
/// rotation
|
/// rotation
|
||||||
Encoder(unsigned char pulsesPerRevolution = 1,
|
IncrementalEncoder(unsigned char pulsesPerRevolution = 1,
|
||||||
unsigned char distancePerRevolution = 1);
|
unsigned char distancePerRevolution = 1);
|
||||||
|
|
||||||
/// @brief Get the total number of pulses since the previous call
|
/// @brief Get the total number of pulses since the previous call
|
||||||
/// @return The number of pulses, is zero or greater
|
/// @return The number of pulses, is zero or greater
|
||||||
@ -45,7 +51,7 @@ public:
|
|||||||
/// meter
|
/// meter
|
||||||
unsigned char distancePerRevolution = 1;
|
unsigned char distancePerRevolution = 1;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
} // namespace RoboidControl
|
} // namespace RoboidControl
|
||||||
} // namespace Passer
|
} // 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