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);
132 result =
mmL.Set_Drive_MoveSync_PID(kp, ki, kd, _id);
151 result =
mmL.Set_Drive_MoveGyro_PID(kp, ki, kd, _id);
170 result =
mmL.Set_Drive_MoveTurn_PID(kp, ki, kd, _id);
203 uint8_t
Move(int16_t power_left, int16_t power_right) {
210 result =
mmL.Set_Drive_Move_Func(power_left, power_right, _id);
237 uint8_t
MoveDegs(int16_t power_left, int16_t power_right, uint16_t degree,
bool brake,
bool async =
false) {
243 result =
mmL.Set_Drive_Move_Degs(power_left, power_right, degree,
brake, async, _id);
256 if (async ==
false) {
261 mmL.Get_Drive_isTaskDone(_id, stats);
264 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
265 delay(DRIVEDC_BRAKE_DELAY_MS);
284 uint8_t
MoveTime(int16_t power_left, int16_t power_right,
float Time_S,
bool brake,
bool async =
false) {
285 Time_S = Time_S * 1000;
291 result =
mmL.Set_Drive_Move_Time(power_left, power_right, Time_S,
brake, async, _id);
304 if (async ==
false) {
309 mmL.Get_Drive_isTaskDone(_id, stats);
312 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
313 delay(DRIVEDC_BRAKE_DELAY_MS);
329 uint8_t
MoveSync(int16_t power_left, int16_t power_right) {
335 result =
mmL.Set_Drive_MoveSync_Func(power_left, power_right, _id);
363 uint8_t
MoveSyncDegs(int16_t power_left, int16_t power_right, uint16_t degree,
bool brake,
bool async =
false) {
369 result =
mmL.Set_Drive_MoveSync_Degs(power_left, power_right, degree,
brake, async, _id);
382 if (async ==
false) {
387 mmL.Get_Drive_isTaskDone(_id, stats);
390 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
391 delay(DRIVEDC_BRAKE_DELAY_MS);
412 uint8_t
MoveSyncTime(int16_t power_left, int16_t power_right,
float Time_S,
bool brake,
bool async =
false) {
413 Time_S = Time_S * 1000;
419 result =
mmL.Set_Drive_MoveSync_Time(power_left, power_right, Time_S,
brake, async, _id);
432 if (async ==
false) {
437 mmL.Get_Drive_isTaskDone(_id, stats);
440 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
441 delay(DRIVEDC_BRAKE_DELAY_MS);
464 result =
mmL.Set_Drive_MoveGyro_Func(power, Target, _id);
491 uint8_t
MoveGyroDegs(int16_t power_X, int16_t Target_D, uint16_t degree,
bool brake,
bool async =
false) {
497 result =
mmL.Set_Drive_MoveGyro_Degs(power_X, Target_D, degree,
brake, async, _id);
510 if (async ==
false) {
515 mmL.Get_Drive_isTaskDone(_id, stats);
518 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
519 delay(DRIVEDC_BRAKE_DELAY_MS);
539 uint8_t
MoveGyroTime(int16_t power, int16_t Target,
float Time_S,
bool brake,
bool async =
false) {
540 Time_S = Time_S * 1000;
546 result =
mmL.Set_Drive_MoveGyro_Time(power, Target, Time_S,
brake, async, _id);
559 if (async ==
false) {
564 mmL.Get_Drive_isTaskDone(_id, stats);
567 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
568 delay(DRIVEDC_BRAKE_DELAY_MS);
587 uint8_t
TurnGyro(int16_t power, int16_t Target_D, uint8_t mode,
bool brake,
bool async =
false) {
592 result =
mmL.Set_Drive_TurnGyro(power, Target_D, mode,
brake, async, _id);
601 if (async ==
false) {
606 mmL.Get_Drive_isTaskDone(_id, stats);
609 #ifdef ENABLE_DRIVEDC_BRAKE_DELAY
610 delay(DRIVEDC_BRAKE_DELAY_MS);
628 result =
mmL.Get_Drive_EncoderCounter(_id, counter);
645 result =
mmL.Get_Drive_Degrees(_id, degrees);
697 return stsu[0] ? false :
true;
701 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 DriveDC motor parameters (Unuse)
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.