This commit is contained in:
Richie 2023-11-20 14:47:51 +08:00
parent ef9197d899
commit f8f009dd39
2 changed files with 24 additions and 23 deletions

View File

@ -30,7 +30,7 @@ set_wheel_direction(uint32_t direction)
void
update_target_yaw(volatile direction_t * g_direction)
{
updateDirection(g_direction);
// updateDirection(g_direction);
g_direction->target_yaw = g_direction->yaw;
}

View File

@ -105,27 +105,28 @@ set_wheel_speed_synced(uint32_t pwm_level, car_struct_t *pp_car_strut)
set_wheel_speed(pwm_level, pp_car_strut->p_right_motor);
}
///*!
// * @brief Set the distance to travel before stopping, must be called after
// * setting the speed and direction.
// * @param distance_cm distance to travel in cm
// */
//void
//distance_to_stop(float distance_cm)
//{
// float initial = g_motor_right.speed.distance_cm;
//
// for (;;)
// {
// if (g_motor_right.speed.distance_cm - initial >= distance_cm)
// {
// set_wheel_speed_synced(0u);
// break;
// }
// vTaskDelay(pdMS_TO_TICKS(10));
// }
// vTaskDelay(pdMS_TO_TICKS(1000));
// g_motor_right.speed.distance_cm = g_motor_left.speed.distance_cm;
//}
/*!
* @brief Set the distance to travel before stopping, must be called after
* setting the speed and direction.
* @param distance_cm distance to travel in cm
*/
void
distance_to_stop(car_struct_t * pp_car_struct, float distance_cm)
{
float initial = pp_car_struct->p_left_motor->speed.distance_cm;
for (;;)
{
if (pp_car_struct->p_left_motor->speed.distance_cm - initial >= distance_cm)
{
set_wheel_speed_synced(0u);
break;
}
vTaskDelay(pdMS_TO_TICKS(10));
}
vTaskDelay(pdMS_TO_TICKS(1000));
pp_car_struct->p_right_motor->speed.distance_cm =
pp_car_struct->p_left_motor->speed.distance_cm;
}
#endif /* MOTOR_SPEED_H */