test
This commit is contained in:
parent
1def053dc0
commit
c0aa48b58b
|
@ -27,6 +27,13 @@ set_wheel_direction(uint32_t direction)
|
||||||
gpio_set_mask(direction);
|
gpio_set_mask(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
update_target_yaw(car_struct_t * pp_car_struct)
|
||||||
|
{
|
||||||
|
updateDirection(pp_car_struct->p_direction);
|
||||||
|
pp_car_struct->p_direction->target_yaw = pp_car_struct->p_direction->yaw;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Set the direction of the wheel to opposite direction using bit mask
|
* @brief Set the direction of the wheel to opposite direction using bit mask
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -101,9 +101,6 @@ set_wheel_speed(uint32_t pwm_level, motor_t *p_motor)
|
||||||
void
|
void
|
||||||
set_wheel_speed_synced(uint32_t pwm_level, car_struct_t *pp_car_strut)
|
set_wheel_speed_synced(uint32_t pwm_level, car_struct_t *pp_car_strut)
|
||||||
{
|
{
|
||||||
updateDirection(pp_car_strut->p_direction);
|
|
||||||
pp_car_strut->p_direction->target_yaw = pp_car_strut->p_direction->yaw;
|
|
||||||
|
|
||||||
set_wheel_speed(pwm_level, pp_car_strut->p_left_motor);
|
set_wheel_speed(pwm_level, pp_car_strut->p_left_motor);
|
||||||
set_wheel_speed(pwm_level, pp_car_strut->p_right_motor);
|
set_wheel_speed(pwm_level, pp_car_strut->p_right_motor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,9 @@ void
|
||||||
motor_control_task(void *params)
|
motor_control_task(void *params)
|
||||||
{
|
{
|
||||||
car_struct_t *car_struct = (car_struct_t *)params;
|
car_struct_t *car_struct = (car_struct_t *)params;
|
||||||
|
update_target_yaw(car_struct);
|
||||||
|
set_wheel_direction(DIRECTION_FORWARD);
|
||||||
|
set_wheel_speed_synced(90u, car_struct);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
// printf("Collision: %d\n", check_collision(car_struct));
|
// printf("Collision: %d\n", check_collision(car_struct));
|
||||||
|
@ -45,8 +48,6 @@ motor_control_task(void *params)
|
||||||
// set_wheel_direction(DIRECTION_FORWARD);
|
// set_wheel_direction(DIRECTION_FORWARD);
|
||||||
// set_wheel_speed_synced(90u, car_struct);
|
// set_wheel_speed_synced(90u, car_struct);
|
||||||
// }
|
// }
|
||||||
set_wheel_direction(DIRECTION_FORWARD);
|
|
||||||
set_wheel_speed_synced(90u, car_struct);
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(5));
|
vTaskDelay(pdMS_TO_TICKS(5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,8 +111,11 @@ main(void)
|
||||||
// Magnetometer
|
// Magnetometer
|
||||||
magnetometer_init(&car_struct);
|
magnetometer_init(&car_struct);
|
||||||
// magnetometer_tasks_init(&car_struct);
|
// magnetometer_tasks_init(&car_struct);
|
||||||
|
updateDirection(car_struct.p_direction);
|
||||||
printf("Magnetometer initialized!\n");
|
printf("Magnetometer initialized!\n");
|
||||||
|
|
||||||
|
sleep_ms(1000u);
|
||||||
|
|
||||||
// control task
|
// control task
|
||||||
TaskHandle_t h_motor_turning_task_handle = NULL;
|
TaskHandle_t h_motor_turning_task_handle = NULL;
|
||||||
xTaskCreate(motor_control_task,
|
xTaskCreate(motor_control_task,
|
||||||
|
|
Loading…
Reference in New Issue