RoboidControl-cpp/ServoMotor.h

45 lines
957 B
C++

#pragma once
#include "ControlledMotor.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;
virtual void SetTargetAngle(Angle angle);
virtual Angle 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;
Angle targetAngle = 0.0F;
float maxVelocity = 0.0F;
float targetVelocity = 0.0F;
Angle limitedTargetAngle = 0.0F;
float lastUpdateTimeMs = 0.0F;
virtual void SetAngle(Angle angle) = 0;
};
} // namespace RoboidContol
} // namespace Passer
using namespace Passer::RoboidContol;