Исправление неправильной установки LOCK-зон, набор исправлений ночного режима

This commit is contained in:
2023-02-05 15:48:43 +03:00
parent ab7d324b3f
commit b83b860e1f
2 changed files with 69 additions and 95 deletions

View File

@@ -82,13 +82,38 @@ short scheduler_find_task(const struct scheduler_task* tasks, const short curr_p
}
void schedule_one_robot(const struct scheduler_task* tasks, const struct robot_regs* r, struct robot_code* code, const short robot_id) {
void schedule_one_robot(const short robot_id) {
struct scheduler_task tasks[BARRELS_COUNT];
for (short i = 0; i < BARRELS_COUNT; i++) {
// для каждой задачи:
tasks[i].start_zone = barrels[i].zone;
// определяем можно ли ее выполнить и что вообще нужно выполнить
tasks[i].dest_zone = can_move(barrels + i, robot_id);
if (tasks[i].dest_zone >= 0) {
tasks[i].priority = get_operation_priority(i);
}
}
// узнаем текущую зону робота
short current_zone;
if (robot_id == ROBOT_1) {
current_zone = robot1.dx.current_zone;
} else {
current_zone = robot2.dx.current_zone;
}
// формируем список задач
short target_task = scheduler_find_task(tasks, r->dx.current_zone);
short target_task = scheduler_find_task(tasks, current_zone);
if (target_task >= 0) {
create_operation(code, target_task, tasks[target_task].start_zone, tasks[target_task].dest_zone,
r->dx.current_zone, robot_id);
if (robot_id == ROBOT_1) {
create_operation(&robot1_code, target_task, tasks[target_task].start_zone, tasks[target_task].dest_zone,
current_zone, robot_id);
} else {
create_operation(&robot2_code, target_task, tasks[target_task].start_zone, tasks[target_task].dest_zone,
current_zone, robot_id);
}
}
}
@@ -98,7 +123,6 @@ void scheduler_main()
#endif
{
if (scheduler_start_signal) {
scheduler_correction_stage = 0;
robot1_code.PC = -1;
robot2_code.PC = -1;
@@ -220,8 +244,6 @@ void scheduler_main()
if (!auto_mode_pause) {
if ((hla_robot1_en && robot1_code.PC < 0) || (hla_robot2_en && robot2_code.PC < 0)) {
struct scheduler_task tasks[BARRELS_COUNT];
if (one_robot_mode) {
// режим одного робота
char robot_id = ROBOT_NONE;
@@ -248,21 +270,7 @@ void scheduler_main()
robot2_code.PC = 0;
}
} else {
for (short i = 0; i < BARRELS_COUNT; i++) {
// для каждой задачи:
tasks[i].start_zone = barrels[i].zone;
// определяем можно ли ее выполнить и что вообще нужно выполнить
tasks[i].dest_zone = can_move(barrels + i, robot_id);
if (tasks[i].dest_zone >= 0) {
tasks[i].priority = get_operation_priority(i);
}
}
if (robot_id == ROBOT_1) {
schedule_one_robot(tasks, &robot1, &robot1_code, ROBOT_1);
} else {
schedule_one_robot(tasks, &robot2, &robot2_code, ROBOT_2);
}
schedule_one_robot(robot_id);
}
}
} else {
@@ -302,23 +310,13 @@ void scheduler_main()
} else {
// отдельно просчитаем все для первого робота
if (robot1_code.PC < 0) {
for (short i = 0; i < BARRELS_COUNT; i++) {
// для каждой задачи:
tasks[i].start_zone = barrels[i].zone;
// определяем можно ли ее выполнить и что вообще нужно выполнить
tasks[i].dest_zone = can_move(barrels + i, ROBOT_1);
if (tasks[i].dest_zone >= 0) {
tasks[i].priority = get_operation_priority(i);
}
}
schedule_one_robot(tasks, &robot1, &robot1_code, ROBOT_1);
schedule_one_robot(ROBOT_1);
}
// и отдельно для второго (только если не в ночном режиме)
if (robot2_code.PC < 0) {
if (robot2.dx.current_zone < ZONE_WASHING_1A) {
// начальная позиция робота 1 - обезжир
// начальная позиция робота 2 - промывка 1a
robot2_lock_zone = ZONE_WASHING_1A;
if (robot2_code.PC < 0) {
robot2_code.barrel_id = -1;
@@ -328,17 +326,7 @@ void scheduler_main()
robot2_code.PC = 0;
}
} else {
for (short i = 0; i < BARRELS_COUNT; i++) {
// для каждой задачи:
tasks[i].start_zone = barrels[i].zone;
// определяем можно ли ее выполнить и что вообще нужно выполнить
tasks[i].dest_zone = can_move(barrels + i, ROBOT_2);
if (tasks[i].dest_zone >= 0) {
tasks[i].priority = get_operation_priority(i);
}
}
schedule_one_robot(tasks, &robot2, &robot2_code, ROBOT_2);
schedule_one_robot(ROBOT_2);
}
}
}