#include <chrono>
#include <thread>
#include <spdlog/spdlog.h>
void onDriveComplete(uint16_t id) {
spdlog::info("Drive complete id={}", id);
}
spdlog::error("Drive error id={} side={} type={}",
id, (int)side, (int)type);
}
spdlog::info("Drive state type={} state={}", (int)driveType, (int)state);
}
int main() {
spdlog::set_level(spdlog::level::info);
spdlog::flush_on(spdlog::level::trace);
spdlog::error("Doly service stop failed");
return -1;
}
spdlog::error("DriveControl init failed");
return -2;
}
uint8_t speed = 50;
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
spdlog::info("Robot pos x={} y={} head={}", pos.x, pos.y, pos.head);
return 0;
}
Public API for Doly drive motion control.
Event dispatcher API for the Doly DriveControl subsystem.
DriveErrorType
Classification of a drive error.
Definition DriveEventListener.h:28
DriveType
Type/category of a drive operation.
Definition DriveEventListener.h:76
DriveState
High-level state of a drive operation.
Definition DriveEventListener.h:61
DriveMotorSide
Which motor side is associated with an error/event.
Definition DriveEventListener.h:46
@ RUNNING
Definition DriveEventListener.h:63
int8_t dispose(bool dispose_IMU)
Dispose/shutdown drive module and release resources.
Position getPosition()
Get current estimated position.
DriveState getState()
Get current drive state.
float getVersion()
Get current library version.
int8_t init(int16_t imu_off_gx=0, int16_t imu_off_gy=0, int16_t imu_off_gz=0, int16_t imu_off_ax=0, int16_t imu_off_ay=0, int16_t imu_off_az=0)
Initialize the drive control module.
bool goDistance(uint16_t id, uint16_t mm, uint8_t speed, bool toForward, bool with_brake=false, uint8_t acceleration_interval=0, bool control_speed=false, bool control_force=true)
Autonomous drive for a fixed distance (high-level).
void RemoveListenerOnError(void(*onError)(uint16_t id, DriveMotorSide side, DriveErrorType type))
Remove a previously registered error callback.
void AddListenerOnComplete(void(*onComplete)(uint16_t id))
Register a C-style callback for “command complete” events.
void RemoveListenerOnStateChange(void(*onChange)(DriveType drive_type, DriveState state))
Remove a previously registered state-change callback.
void AddListenerOnError(void(*onError)(uint16_t id, DriveMotorSide side, DriveErrorType type))
Register a C-style callback for error events.
void RemoveListenerOnComplete(void(*onComplete)(uint16_t id))
Remove a previously registered “command complete” callback.
void AddListenerOnStateChange(void(*onChange)(DriveType drive_type, DriveState state))
Register a C-style callback for drive state changes.
int8_t stopDolyService()
Stop the background Doly service (if running).