RoboidControl-cpp/ServoMotor.h
2024-05-31 09:53:21 +02:00

45 lines
936 B
C++

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