12#define IMU_idle_Period 30
13#define Drive_retry_Period 10
15#ifdef ENABLE_DRIVEDC_BRAKE_DELAY
16 #ifndef DRIVEDC_BRAKE_DELAY_MS
17 #define DRIVEDC_BRAKE_DELAY_MS 110
49 uint8_t
begin(uint8_t leftMotorID, uint8_t rightMotorID,
bool isLeftReverse,
bool isRightReverse) {
50 _id_left = leftMotorID;
51 _id_right = rightMotorID;
60 result =
mmL.Set_Drive2Motor_PARAM(_id_left, _id_right, _dir_left, _dir_right, _id);
93 result =
mmL.Set_Drive_MoveSync_PID(kp, ki, kd, _id);
112 result =
mmL.Set_Drive_MoveGyro_PID(kp, ki, kd, _id);
131 result =
mmL.Set_Drive_MoveTurn_PID(kp, ki, kd, _id);
164 uint8_t
Move(int16_t power_left, int16_t power_right) {
171 result =
mmL.Set_Drive_Move_Func(power_left, power_right, _id);
198 uint8_t
MoveDegs(int16_t power_left, int16_t power_right, uint16_t degree,
bool brake,
bool async =
false) {
204 result =
mmL.Set_Drive_Move_Degs(power_left, power_right, degree,
brake, async, _id);
217 if (async ==
false) {
222 mmL.Get_Drive_isTaskDone(_id, stats);
225 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
226 delay(DRIVEDC_BRAKE_DELAY_MS);
245 uint8_t
MoveTime(int16_t power_left, int16_t power_right,
float Time_S,
bool brake,
bool async =
false) {
246 Time_S = Time_S * 1000;
252 result =
mmL.Set_Drive_Move_Time(power_left, power_right, Time_S,
brake, async, _id);
265 if (async ==
false) {
270 mmL.Get_Drive_isTaskDone(_id, stats);
273 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
274 delay(DRIVEDC_BRAKE_DELAY_MS);
290 uint8_t
MoveSync(int16_t power_left, int16_t power_right) {
296 result =
mmL.Set_Drive_MoveSync_Func(power_left, power_right, _id);
324 uint8_t
MoveSyncDegs(int16_t power_left, int16_t power_right, uint16_t degree,
bool brake,
bool async =
false) {
330 result =
mmL.Set_Drive_MoveSync_Degs(power_left, power_right, degree,
brake, async, _id);
343 if (async ==
false) {
348 mmL.Get_Drive_isTaskDone(_id, stats);
351 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
352 delay(DRIVEDC_BRAKE_DELAY_MS);
373 uint8_t
MoveSyncTime(int16_t power_left, int16_t power_right,
float Time_S,
bool brake,
bool async =
false) {
374 Time_S = Time_S * 1000;
380 result =
mmL.Set_Drive_MoveSync_Time(power_left, power_right, Time_S,
brake, async, _id);
393 if (async ==
false) {
398 mmL.Get_Drive_isTaskDone(_id, stats);
401 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
402 delay(DRIVEDC_BRAKE_DELAY_MS);
425 result =
mmL.Set_Drive_MoveGyro_Func(power, Target, _id);
452 uint8_t
MoveGyroDegs(int16_t power_X, int16_t Target_D, uint16_t degree,
bool brake,
bool async =
false) {
458 result =
mmL.Set_Drive_MoveGyro_Degs(power_X, Target_D, degree,
brake, async, _id);
471 if (async ==
false) {
476 mmL.Get_Drive_isTaskDone(_id, stats);
479 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
480 delay(DRIVEDC_BRAKE_DELAY_MS);
500 uint8_t
MoveGyroTime(int16_t power, int16_t Target,
float Time_S,
bool brake,
bool async =
false) {
501 Time_S = Time_S * 1000;
507 result =
mmL.Set_Drive_MoveGyro_Time(power, Target, Time_S,
brake, async, _id);
520 if (async ==
false) {
525 mmL.Get_Drive_isTaskDone(_id, stats);
528 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
529 delay(DRIVEDC_BRAKE_DELAY_MS);
548 uint8_t
TurnGyro(int16_t power, int16_t Target_D, uint8_t mode,
bool brake,
bool async =
false) {
553 result =
mmL.Set_Drive_TurnGyro(power, Target_D, mode,
brake, async, _id);
562 if (async ==
false) {
567 mmL.Get_Drive_isTaskDone(_id, stats);
570 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
571 delay(DRIVEDC_BRAKE_DELAY_MS);
589 result =
mmL.Get_Drive_EncoderCounter(_id, counter);
606 result =
mmL.Get_Drive_Degrees(_id, degrees);
658 return stsu[0] ? false :
true;
662 private: uint8_t _id_left,
Handling the Lower MCU (STM32) communication.
#define Drive_retry_Period
bool setTurnGyroPID(float kp, float ki, float kd)
Sets the PID parameters for DriveDC TurnGyro.
uint8_t Move(int16_t power_left, int16_t power_right)
Sets the Motor Type for DriveDC. (Unuse)
int32_t getCounter(void)
Gets the estimated rotation counter of the drivebase. (not degrees)
uint8_t MoveGyroDegs(int16_t power_X, int16_t Target_D, uint16_t degree, bool brake, bool async=false)
Sets the power level with gyro guidance for specific degrees.
uint8_t MoveSyncDegs(int16_t power_left, int16_t power_right, uint16_t degree, bool brake, bool async=false)
Sets the power level of the DC motor with synchronization for specific degrees.
uint8_t brake(bool brakeType)
Sets the brake mode for the DC motor.
uint8_t MoveSync(int16_t power_left, int16_t power_right)
Sets the power level of the DC motor with synchronization.
uint8_t MoveGyro(int16_t power, int16_t Target)
Sets the power level with gyro guidance.
bool setMoveSyncPID(float kp, float ki, float kd)
Sets the PID parameters for DriveDC MoveSync.
uint8_t resetCounter(void)
Resets the drivebase encoder counter/degrees to zero.
uint8_t MoveDegs(int16_t power_left, int16_t power_right, uint16_t degree, bool brake, bool async=false)
Sets the power level of the DC motor for a specific degree.
int32_t getDegrees(void)
Gets the estimated degrees of the drivebase.
uint8_t MoveGyroTime(int16_t power, int16_t Target, float Time_S, bool brake, bool async=false)
Sets the power level with gyro guidance for specific time.
uint8_t MoveTime(int16_t power_left, int16_t power_right, float Time_S, bool brake, bool async=false)
Sets the power level of the DC motor for a specific time period.
uint8_t MoveSyncTime(int16_t power_left, int16_t power_right, float Time_S, bool brake, bool async=false)
Sets the power level of the DC motor with synchronization for specific time.
uint8_t begin(uint8_t leftMotorID, uint8_t rightMotorID, bool isLeftReverse, bool isRightReverse)
Initializes the DC motor settings.
bool isPrevTaskDone(void)
Checks if the previous task has completed.
bool setMoveGyroPID(float kp, float ki, float kd)
Sets the PID parameters for DriveDC MoveGyro.
uint8_t TurnGyro(int16_t power, int16_t Target_D, uint8_t mode, bool brake, bool async=false)
Turns the robot to a specific gyro heading.