Skip to content

Commit

Permalink
prevented accidental timeout for calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
Andd54 committed Dec 20, 2023
1 parent d65a8a4 commit b642f8c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion boards/DJI_Board_TypeC/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [4.1.0] date: [Tue Dec 19 16:10:57 CST 2023]
# File automatically-generated by tool: [projectgenerator] version: [4.1.0] date: [Tue Dec 19 18:42:31 CST 2023]
##########################################################################################################################

# ------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions vehicles/Fortress/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ void fortressTask(void* arg) {
// SelfTest
//==================================================================================================

const osThreadAttr_t selfTestTaskAttribute = {.name = "selfTestTask",
const osThreadAttr_t rmselfTestTaskAttribute = {.name = "selfTestTask",
.attr_bits = osThreadDetached,
.cb_mem = nullptr,
.cb_size = 0,
Expand Down Expand Up @@ -1111,7 +1111,7 @@ void RM_RTOS_Threads_Init(void) {
chassisTaskHandle = osThreadNew(chassisTask, nullptr, &chassisTaskAttribute);
shooterTaskHandle = osThreadNew(shooterTask, nullptr, &shooterTaskAttribute);
fortressTaskHandle = osThreadNew(fortressTask, nullptr, &fortressTaskAttribute);
selfTestTaskHandle = osThreadNew(selfTestTask, nullptr, &selfTestTaskAttribute);
selfTestTaskHandle = osThreadNew(selfTestTask, nullptr, &rmselfTestTaskAttribute);
UITaskHandle = osThreadNew(UITask, nullptr, &UITaskAttribute);
}

Expand Down
21 changes: 14 additions & 7 deletions vehicles/Steering/gimbal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@ void imuTask(void* arg) {
while (true) {
uint32_t flags = osThreadFlagsWait(IMU_RX_SIGNAL, osFlagsWaitAll, osWaitForever);
if (flags & IMU_RX_SIGNAL) imu->Update();

}
}

//==================================================================================================
// Gimbal
//==================================================================================================

const osThreadAttr_t gimbalTaskAttribute = {.name = "gimbalTask",
const osThreadAttr_t rmgimbalTaskAttribute = {.name = "gimbalTask",
.attr_bits = osThreadDetached,
.cb_mem = nullptr,
.cb_size = 0,
Expand Down Expand Up @@ -191,6 +192,7 @@ void gimbalTask(void* arg) {
control::MotorCANBase::TransmitOutput(motors_can1_gimbal, 1);
osDelay(GIMBAL_TASK_DELAY);
++i;

}

pitch_motor->MotorEnable();
Expand All @@ -206,6 +208,7 @@ void gimbalTask(void* arg) {
pitch_motor->SetOutput(pitch_motor->GetRelativeTarget(), 1, 115, 0.5, 0);
control::Motor4310::TransmitOutput(motors_can1_pitch, 1);
osDelay(GIMBAL_TASK_DELAY);

}

print("Start Calibration.\r\n");
Expand All @@ -222,9 +225,11 @@ void gimbalTask(void* arg) {
control::MotorCANBase::TransmitOutput(motors_can1_gimbal, 1);
pitch_motor->SetOutput(pitch_motor->GetRelativeTarget(), 1, 115, 0.5, 0);
control::Motor4310::TransmitOutput(motors_can1_pitch, 1);

osDelay(GIMBAL_TASK_DELAY);
}

HAL_IWDG_Refresh(&hiwdg);
// prevent unexpected timeout
print("Gimbal Begin!\r\n");
RGB->Display(display::color_green);
laser->On();
Expand Down Expand Up @@ -350,6 +355,7 @@ void refereeTask(void* arg) {
length = referee_uart->Read(&data);
referee->Receive(communication::package_t{data, (int)length});
}

}
}

Expand Down Expand Up @@ -628,7 +634,7 @@ void chassisTask(void* arg) {
// SelfTest
//==================================================================================================

const osThreadAttr_t selfTestTaskAttribute = {.name = "selfTestTask",
const osThreadAttr_t rmselfTestTaskAttribute = {.name = "selfTestTask",
.attr_bits = osThreadDetached,
.cb_mem = nullptr,
.cb_size = 0,
Expand All @@ -654,12 +660,13 @@ static display::OLED* OLED = nullptr;
void selfTestTask(void* arg) {
UNUSED(arg);
osDelay(100);

MX_IWDG_Init();
//Try to make the chassis Flags initialized at first.

//Could need more time to test it out.
//The self test task for chassis will not update after the first check.
OLED->ShowIlliniRMLOGO();
HAL_IWDG_Refresh(&hiwdg);
buzzer->SingSong(Mario, [](uint32_t milli) { osDelay(milli); });
OLED->OperateGram(display::PEN_CLEAR);
OLED->ShowString(0, 0, (uint8_t*)"GP");
Expand All @@ -680,7 +687,7 @@ void selfTestTask(void* arg) {
//
OLED->ShowString(3, 12, (uint8_t*)"BL");
OLED->ShowString(4, 12, (uint8_t*)"BR");
MX_IWDG_Init();

selftestStart = send->self_check_flag;
while(!selftestStart){
// wait for the self check signal
Expand Down Expand Up @@ -839,11 +846,11 @@ void RM_RTOS_Init(void) {

void RM_RTOS_Threads_Init(void) {
imuTaskHandle = osThreadNew(imuTask, nullptr, &imuTaskAttribute);
gimbalTaskHandle = osThreadNew(gimbalTask, nullptr, &gimbalTaskAttribute);
gimbalTaskHandle = osThreadNew(gimbalTask, nullptr, &rmgimbalTaskAttribute);
refereeTaskHandle = osThreadNew(refereeTask, nullptr, &refereeTaskAttribute);
shooterTaskHandle = osThreadNew(shooterTask, nullptr, &shooterTaskAttribute);
chassisTaskHandle = osThreadNew(chassisTask, nullptr, &chassisTaskAttribute);
selfTestTaskHandle = osThreadNew(selfTestTask, nullptr, &selfTestTaskAttribute);
selfTestTaskHandle = osThreadNew(selfTestTask, nullptr, &rmselfTestTaskAttribute);
// jetsonCommTaskHandle = osThreadNew(jetsonCommTask, nullptr, &jetsonCommTaskAttribute);
}

Expand Down

0 comments on commit b642f8c

Please sign in to comment.