2025-12-14 13:21:36 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
// Abstract class
|
|
|
|
|
class RangedMotor
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
RangedMotor(
|
|
|
|
|
const float gearboxRatio,
|
|
|
|
|
const float scaleCalibration,
|
|
|
|
|
const float zeroOffset,
|
|
|
|
|
const float minSafeAngle,
|
|
|
|
|
const float maxSafeAngle
|
|
|
|
|
) noexcept;
|
|
|
|
|
|
2025-12-14 15:02:55 +01:00
|
|
|
virtual bool moveTo(const float target) noexcept;
|
2025-12-14 13:21:36 +01:00
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
2025-12-14 18:57:28 +01:00
|
|
|
protected:
|
2025-12-14 13:21:36 +01:00
|
|
|
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
|
|
|
|
|
};
|