#include <chrono>
#include <thread>
#include <spdlog/spdlog.h>
void onServoAbort(uint16_t
id,
ServoId channel)
{
spdlog::info("Servo abort id:{} channel:{}", id, static_cast<uint8_t>(channel));
}
void onServoError(uint16_t
id,
ServoId channel)
{
spdlog::error("Servo error id:{} channel:{}", id, static_cast<uint8_t>(channel));
}
void onServoComplete(uint16_t
id,
ServoId channel)
{
spdlog::info("Servo completed id:{} channel:{}", id, static_cast<uint8_t>(channel));
}
int main()
{
spdlog::set_level(spdlog::level::info);
spdlog::flush_on(spdlog::level::trace);
spdlog::error("Doly service stop failed");
return -1;
}
{
spdlog::error("ServoControl init failed");
return -2;
}
std::this_thread::sleep_for(std::chrono::seconds(3));
return 0;
}
Shared helper utilities and common types used across the Doly SDK.
Public API for Doly servo control.
ServoId
Servo channel identifiers.
Definition ServoEventListener.h:25
@ SERVO_1
Definition ServoEventListener.h:27
@ SERVO_0
Definition ServoEventListener.h:26
int8_t stopDolyService()
Stop the background Doly service (if running).
int8_t setServo(uint16_t id, ServoId channel, float angle, uint8_t speed, bool invert)
Set a servo target angle.
int8_t release(ServoId channel)
Release servo hold (disable holding torque) for a channel.
float getVersion()
Get current library version.
int8_t dispose()
Dispose/stop the servo subsystem and release resources.
int8_t init()
Initialize the servo subsystem.
void RemoveListenerOnError(void(*onEvent)(uint16_t id, ServoId channel))
void AddListenerOnError(void(*onEvent)(uint16_t id, ServoId channel))
void AddListenerOnComplete(void(*onEvent)(uint16_t id, ServoId channel))
void RemoveListenerOnAbort(void(*onEvent)(uint16_t id, ServoId channel))
void RemoveListenerOnComplete(void(*onEvent)(uint16_t id, ServoId channel))
void AddListenerOnAbort(void(*onEvent)(uint16_t id, ServoId channel))