feat: create RangedMotor base class
This commit is contained in:
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
// Abstract class
|
||||
class RangedMotor
|
||||
{
|
||||
public:
|
||||
RangedMotor(
|
||||
const float gearboxRatio,
|
||||
const float scaleCalibration,
|
||||
const float zeroOffset,
|
||||
const float minSafeAngle,
|
||||
const float maxSafeAngle
|
||||
) noexcept;
|
||||
|
||||
virtual bool moveTo(float target) noexcept;
|
||||
virtual float getPosition() const noexcept;
|
||||
|
||||
float getGearboxRatio() const noexcept;
|
||||
float getScaleCalibration() const noexcept;
|
||||
float getZeroOffset() const noexcept;
|
||||
float getSafeMinAngle() const noexcept;
|
||||
float getSafeMaxAngle() const noexcept;
|
||||
float getSafeHardwareMinAngle() const noexcept;
|
||||
float getSafeHardwareMaxAngle() const noexcept;
|
||||
|
||||
void setGearboxRatio(float gearboxRatio) noexcept;
|
||||
void setScaleCalibration(float scaleCalibration) noexcept;
|
||||
void setZeroOffset(float zeroOffset) noexcept;
|
||||
void setSafeMinAngle(float safeMinAngle) noexcept;
|
||||
void setSafeMaxAngle(float safeMaxAngle) noexcept;
|
||||
void setSafeHardwareMinAngle(float safeHardwareMinAngle) noexcept;
|
||||
void setSafeHardwareMaxAngle(float safeHardwareMaxAngle) noexcept;
|
||||
|
||||
|
||||
// Will translate virtual-space-angles to hardware-space-angles
|
||||
float virtualAngleToHardwareAngle(float virtualAngle) const noexcept;
|
||||
// Will translate hardware-space-angles to virtual-space-angles
|
||||
float hardwareAngleToVirtualAngle(float hardwareAngle) const noexcept;
|
||||
|
||||
protected:
|
||||
// Calculates a command-space scale compensation factor.
|
||||
// The returned value is multiplied with virtual angle so that
|
||||
// the motors actual movement matches the intended movement.
|
||||
static float calculateScaleCalibration(const float virtualRange, const float hardwareRange);
|
||||
|
||||
float gearboxRatio; // Gearbox ratio
|
||||
float scaleCalibration; // Scale calibration
|
||||
float zeroOffset; // Zero offset calibration
|
||||
float safeHardwareMinAngle; // Absolute hardware space minimum
|
||||
float safeHardwareMaxAngle; // Absolute hardware space maximum
|
||||
};
|
||||
Reference in New Issue
Block a user