Doly C++ SDK v1.00
Loading...
Searching...
No Matches
DriveControl Namespace Reference

Functions

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.
int8_t dispose (bool dispose_IMU)
 Dispose/shutdown drive module and release resources.
bool isActive ()
 Check whether the module is initialized and active.
void Abort ()
 Abort current drive operation immediately.
bool freeDrive (uint8_t speed, bool isLeft, bool toForward)
 Manual motor drive (low-level).
bool goXY (uint16_t id, int16_t x, int16_t y, uint8_t speed, bool toForward, bool with_brake=false, uint8_t acceleration_interval=0, bool control_speed=false, bool control_force=true)
 Autonomous drive to an (x, y) target (high-level).
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).
bool goRotate (uint16_t id, float rotateAngle, bool from_center, uint8_t speed, bool toForward, bool with_brake=false, uint8_t acceleration_interval=0, bool control_speed=false, bool control_force=true)
 Autonomous rotate (high-level).
Position getPosition ()
 Get current estimated position.
void resetPosition ()
 Reset current position estimate to (0, 0, 0) (implementation-defined fields).
DriveState getState ()
 Get current drive state.
float getRPM (bool isLeft)
 Get current motor RPM.
float getVersion ()
 Get current library version.

Function Documentation

◆ Abort()

void DriveControl::Abort ( )

Abort current drive operation immediately.

Typically used as an emergency stop for autonomous movement. Completion/error events may still be emitted depending on implementation.

◆ dispose()

int8_t DriveControl::dispose ( bool dispose_IMU)

Dispose/shutdown drive module and release resources.

Parameters
dispose_IMUIf true, shuts down the IMU module as well.
Returns
Status code:
  • 0 : success
  • 1 : not active / not initialized
Examples
DriveControl/main.cpp.

◆ freeDrive()

bool DriveControl::freeDrive ( uint8_t speed,
bool isLeft,
bool toForward )

Manual motor drive (low-level).

Parameters
speedMotor speed percent (0..100).
isLefttrue = left motor, false = right motor.
toForwardtrue = forward, false = backward.
Returns
true if accepted.
Note
Non-blocking; handled in another thread.

◆ getPosition()

Position DriveControl::getPosition ( )

Get current estimated position.

Returns
Current Position estimate (see Helper.h for definition/units).
Examples
DriveControl/main.cpp.

◆ getRPM()

float DriveControl::getRPM ( bool isLeft)

Get current motor RPM.

Parameters
isLefttrue = left motor, false = right motor.
Returns
RPM value (units: revolutions per minute).

◆ getState()

DriveState DriveControl::getState ( )

Get current drive state.

Returns
Current DriveState.
Examples
DriveControl/main.cpp.

◆ getVersion()

float DriveControl::getVersion ( )

Get current library version.

Original note: format 0.XYZ (3 digits after major).

Returns
Version as float.
Examples
DriveControl/main.cpp.

◆ goDistance()

bool DriveControl::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).

Parameters
idUser command id (returned in events/callbacks).
mmDistance value (named "mm" in API; ensure your implementation uses millimeters).
speedRequested speed percent (0..100).
toForwardtrue forward / false backward.
with_brakeBrake at the end.
acceleration_intervalAcceleration step interval (0 = disabled).
control_speedEnable speed control dynamically.
control_forceEnable force/traction control.
Returns
true if command accepted.
Note
Non-blocking; handled in another thread.
Examples
DriveControl/main.cpp.

◆ goRotate()

bool DriveControl::goRotate ( uint16_t id,
float rotateAngle,
bool from_center,
uint8_t speed,
bool toForward,
bool with_brake = false,
uint8_t acceleration_interval = 0,
bool control_speed = false,
bool control_force = true )

Autonomous rotate (high-level).

Parameters
idUser command id (returned in events/callbacks).
rotateAngleRotation angle in degrees (sign convention is implementation-defined).
from_centertrue = rotate around center, false = rotate around a wheel/edge (implementation-defined).
speedRequested speed percent (0..100).
toForwardDirection preference (implementation-defined for rotation).
with_brakeBrake at the end.
acceleration_intervalAcceleration step interval (0 = disabled).
control_speedEnable speed control dynamically.
control_forceEnable force/traction control.
Returns
true if command accepted.
Note
Non-blocking; handled in another thread.

◆ goXY()

bool DriveControl::goXY ( uint16_t id,
int16_t x,
int16_t y,
uint8_t speed,
bool toForward,
bool with_brake = false,
uint8_t acceleration_interval = 0,
bool control_speed = false,
bool control_force = true )

Autonomous drive to an (x, y) target (high-level).

Parameters
idUser command id (returned in events/callbacks).
xTarget X in your Position coordinate system (units are application-defined).
yTarget Y in your Position coordinate system (same unit as x).
speedRequested speed percent (0..100).
toForwardDirection preference for the move.
with_brakeIf true, brake at the end of motion.
acceleration_intervalAcceleration step interval (0 = disabled).
control_speedEnable speed control dynamically.
control_forceEnable force/traction control (default true).
Returns
true if command accepted.
Note
Non-blocking; handled in another thread.

◆ init()

int8_t DriveControl::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.

IMU offsets are calibration values stored by the platform.

Parameters
imu_off_gxIMU gyro X offset (calibration).
imu_off_gyIMU gyro Y offset (calibration).
imu_off_gzIMU gyro Z offset (calibration).
imu_off_axIMU accel X offset (calibration).
imu_off_ayIMU accel Y offset (calibration).
imu_off_azIMU accel Z offset (calibration).
Returns
Status code:
  • 0 : success
  • 1 : already active / already initialized
  • -1 : motor setup failed
  • -2 : IMU init failed
Examples
DriveControl/main.cpp.

◆ isActive()

bool DriveControl::isActive ( )

Check whether the module is initialized and active.

Returns
true if active, false otherwise.

◆ resetPosition()

void DriveControl::resetPosition ( )

Reset current position estimate to (0, 0, 0) (implementation-defined fields).