Extend Angle type usage
This commit is contained in:
parent
00f40fea98
commit
4b362fffa8
@ -6,12 +6,12 @@ namespace Passer {
|
||||
namespace RoboidContol {
|
||||
|
||||
class AbsoluteEncoder {
|
||||
public:
|
||||
public:
|
||||
AbsoluteEncoder() {}
|
||||
|
||||
virtual float GetActualAngle() = 0;
|
||||
virtual Angle GetActualAngle() = 0;
|
||||
virtual float GetActualVelocity() = 0;
|
||||
};
|
||||
|
||||
} // namespace RoboidContol
|
||||
} // namespace Passer
|
||||
} // namespace RoboidContol
|
||||
} // namespace Passer
|
@ -10,7 +10,7 @@ ServoMotor::ServoMotor()
|
||||
this->hasTargetAngle = false;
|
||||
}
|
||||
|
||||
void ServoMotor::SetTargetAngle(float angle) {
|
||||
void ServoMotor::SetTargetAngle(Angle angle) {
|
||||
angle = Float::Clamp(angle, minAngle, maxAngle);
|
||||
|
||||
if (maxVelocity == 0.0F || hasTargetAngle == false) {
|
||||
@ -23,7 +23,7 @@ void ServoMotor::SetTargetAngle(float angle) {
|
||||
this->hasTargetAngle = true;
|
||||
}
|
||||
|
||||
float ServoMotor::GetTargetAngle() {
|
||||
Angle ServoMotor::GetTargetAngle() {
|
||||
return this->targetAngle;
|
||||
}
|
||||
|
||||
@ -76,9 +76,9 @@ void ServoMotor::Update(unsigned long currentTimeMs) {
|
||||
SetAngle(targetAngle);
|
||||
} else {
|
||||
if (deltaAngle < 0)
|
||||
limitedTargetAngle -= angleStep;
|
||||
limitedTargetAngle = limitedTargetAngle - angleStep;
|
||||
else
|
||||
limitedTargetAngle += angleStep;
|
||||
limitedTargetAngle = limitedTargetAngle + angleStep;
|
||||
}
|
||||
SetAngle(limitedTargetAngle);
|
||||
|
||||
|
22
ServoMotor.h
22
ServoMotor.h
@ -6,18 +6,18 @@ namespace Passer {
|
||||
namespace RoboidContol {
|
||||
|
||||
class ServoMotor : public Thing {
|
||||
public:
|
||||
public:
|
||||
ServoMotor();
|
||||
|
||||
Vector3 rotationAxis = Vector3::up;
|
||||
float minAngle = -90.0F;
|
||||
float maxAngle = 90.0F;
|
||||
Angle minAngle = -90.0F;
|
||||
Angle maxAngle = 90.0F;
|
||||
|
||||
enum ControlMode { Position, Velocity };
|
||||
ControlMode controlMode = ControlMode::Position;
|
||||
|
||||
virtual void SetTargetAngle(float angle);
|
||||
virtual float GetTargetAngle();
|
||||
virtual void SetTargetAngle(Angle angle);
|
||||
virtual Angle GetTargetAngle();
|
||||
|
||||
virtual void SetMaximumVelocity(float maxVelocity);
|
||||
|
||||
@ -26,20 +26,20 @@ public:
|
||||
|
||||
virtual void Update(unsigned long currentTimeMs) override;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
bool hasTargetAngle = false;
|
||||
float targetAngle = 0.0F;
|
||||
Angle targetAngle = 0.0F;
|
||||
|
||||
float maxVelocity = 0.0F;
|
||||
|
||||
float targetVelocity = 0.0F;
|
||||
float limitedTargetAngle = 0.0F;
|
||||
Angle limitedTargetAngle = 0.0F;
|
||||
|
||||
float lastUpdateTimeMs = 0.0F;
|
||||
|
||||
virtual void SetAngle(float angle) = 0;
|
||||
virtual void SetAngle(Angle angle) = 0;
|
||||
};
|
||||
|
||||
} // namespace RoboidContol
|
||||
} // namespace Passer
|
||||
} // namespace RoboidContol
|
||||
} // namespace Passer
|
||||
using namespace Passer::RoboidContol;
|
Loading…
x
Reference in New Issue
Block a user