RoboidControl-cpp/ServoMotor.h
2024-08-30 16:28:15 +02:00

49 lines
1.0 KiB
C++

#pragma once
#include "ControlledMotor.h"
#include "LinearAlgebra/Angle16.h"
namespace Passer {
namespace RoboidContol {
class ServoMotor : public Thing {
public:
ServoMotor();
Vector3 rotationAxis = Vector3::up;
Angle minAngle = -90.0F;
Angle maxAngle = 90.0F;
enum ControlMode { Position, Velocity };
ControlMode controlMode = ControlMode::Position;
Thing* target = nullptr;
virtual void SetTargetAngle(Angle16 angle);
virtual Angle16 GetTargetAngle();
virtual void SetMaximumVelocity(float maxVelocity);
virtual void SetTargetVelocity(float velocity);
virtual float GetTargetVelocity();
virtual void Update(unsigned long currentTimeMs) override;
protected:
bool hasTargetAngle = false;
Angle16 targetAngle = 0.0F;
Angle16 actualAngle = 0.0F;
float maxVelocity = 0.0F;
float targetVelocity = 0.0F;
Angle16 limitedTargetAngle = 0.0F;
float lastUpdateTimeMs = 0.0F;
virtual void SetAngle(Angle16 angle);
};
} // namespace RoboidContol
} // namespace Passer
using namespace Passer::RoboidContol;