Working code
Signed-off-by: linuxes_mojoworld@aleeas.com <linuxes_mojoworld@aleeas.com>
This commit is contained in:
parent
ac9a3ccc7e
commit
7aa3ff6af3
|
@ -33,6 +33,8 @@ 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;
|
||||||
|
set_wheel_direction(DIRECTION_FORWARD);
|
||||||
|
set_wheel_speed_synced(90u, car_struct);
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -40,24 +42,19 @@ motor_control_task(void *params)
|
||||||
switch (temp)
|
switch (temp)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
set_wheel_direction(DIRECTION_FORWARD);
|
|
||||||
set_wheel_speed_synced(90u, car_struct);
|
|
||||||
distance_to_stop(car_struct, 50.f);
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(3000));
|
|
||||||
break;
|
break;
|
||||||
case 0b01:
|
case 0b01:
|
||||||
car_struct->p_right_motor->speed.current_cms
|
car_struct->p_right_motor->speed.distance_cm
|
||||||
+= SLOT_DISTANCE_CM * 1000.f;
|
-= SLOT_DISTANCE_CM;
|
||||||
break;
|
break;
|
||||||
case 0b10:
|
case 0b10:
|
||||||
car_struct->p_right_motor->speed.current_cms
|
car_struct->p_right_motor->speed.distance_cm
|
||||||
-= SLOT_DISTANCE_CM * 1000.f;
|
+= SLOT_DISTANCE_CM;
|
||||||
break;
|
break;
|
||||||
case 0b11:
|
case 0b11:
|
||||||
// set_wheel_direction(DIRECTION_MASK);
|
turn(DIRECTION_LEFT, 90u, 90u, car_struct);
|
||||||
// set_wheel_speed_synced(0u, car_struct);
|
set_wheel_direction(DIRECTION_FORWARD);
|
||||||
// vTaskDelay(pdMS_TO_TICKS(1000));
|
set_wheel_speed_synced(90u, car_struct);
|
||||||
// turn(DIRECTION_LEFT, 90u, 90u, car_struct);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +79,7 @@ obs_task(void *params)
|
||||||
// set_wheel_speed_synced(90u, car_struct);
|
// set_wheel_speed_synced(90u, car_struct);
|
||||||
//
|
//
|
||||||
revert_wheel_direction();
|
revert_wheel_direction();
|
||||||
distance_to_stop(car_struct, 100.f);
|
distance_to_stop(car_struct, 20.f);
|
||||||
}
|
}
|
||||||
vTaskDelay(pdMS_TO_TICKS(50));
|
vTaskDelay(pdMS_TO_TICKS(50));
|
||||||
}
|
}
|
||||||
|
@ -96,14 +93,14 @@ turn_task(void *params)
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
set_wheel_direction(DIRECTION_FORWARD);
|
set_wheel_direction(DIRECTION_FORWARD);
|
||||||
set_wheel_speed_synced(90u, car_struct);
|
set_wheel_speed_synced(89u, car_struct);
|
||||||
|
|
||||||
distance_to_stop(car_struct, 50.f);
|
distance_to_stop(car_struct, 20.f);
|
||||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||||
|
|
||||||
// turn_to_yaw(DIRECTION_LEFT, 230.f, 80u, car_struct);
|
// turn_to_yaw(DIRECTION_LEFT, 230.f, 80u, car_struct);
|
||||||
|
|
||||||
turn(DIRECTION_RIGHT, 50.f, 90u, car_struct);
|
turn(DIRECTION_RIGHT, 80.f, 90u, car_struct);
|
||||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,14 +171,14 @@ main(void)
|
||||||
|
|
||||||
sleep_ms(1000u);
|
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,
|
||||||
// "motor_turning_task",
|
// "motor_turning_task",
|
||||||
// configMINIMAL_STACK_SIZE,
|
// configMINIMAL_STACK_SIZE,
|
||||||
// (void *)&car_struct,
|
// (void *)&car_struct,
|
||||||
// PRIO,
|
// PRIO,
|
||||||
// &h_motor_turning_task_handle);
|
// &h_motor_turning_task_handle);
|
||||||
|
|
||||||
// obs task
|
// obs task
|
||||||
// TaskHandle_t h_obs_task_handle = NULL;
|
// TaskHandle_t h_obs_task_handle = NULL;
|
||||||
|
|
Loading…
Reference in New Issue