libstp
Robotics library for Botball
Loading...
Searching...
No Matches
Servo.hpp
Go to the documentation of this file.
1#pragma once
2
4
6{
13 class Servo
14 {
15 float storedPosition = 0.0f;
16
17#ifdef SAFETY_CHECKS_ENABLED
18 static inline detail::PortRegistry registry_{};
19
20 static void registerServoPort(int port);
21
22 static void unregisterServoPort(const int port);
23#endif
24
25 public:
26 int port;
27
29 explicit Servo(int port);
30
32
34 void setPosition(float position);
36 float getPosition() const;
38 void setSmoothPosition(float targetDeg, float speedDegPerSec, int easing);
39
41 void enable() const;
43 void disable() const;
44
46 static void fullyDisableAll();
47 };
48}
void disable() const
Disable output while preserving the last commanded position.
void enable() const
Enable output while preserving the last commanded position.
void setSmoothPosition(float targetDeg, float speedDegPerSec, int easing)
Command a smooth move to targetDeg at the given speed; interpolation runs in the C++ reader.
Servo(int port)
Create a servo bound to a platform-defined port index.
void setPosition(float position)
Command a new servo position in degrees (0-180).
float getPosition() const
Return the last commanded position in degrees.
static void fullyDisableAll()
Force every servo into the platform's fully disabled state.