Skip to content

Commit

Permalink
Merge pull request #26 from RoboMaster-Club/1-robot-state-machine
Browse files Browse the repository at this point in the history
move safe start to global struct for better debug
  • Loading branch information
jia-xie authored Apr 5, 2024
2 parents 4880c6b + 7577340 commit c62179e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/app/inc/robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

typedef struct {
uint8_t enabled;
uint8_t safely_started;
uint8_t spintop_mode;
uint8_t autoaiming_enabled;
float chassis_x_speed;
Expand Down
6 changes: 4 additions & 2 deletions src/app/src/robot.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ void Robot_Ctrl_Loop()
*/
void Robot_Cmd_Loop()
{
if (g_start_safely)
// safely startly will be 1 after first time right switch is down
// this is to make sure the robot is disabled when it starts
if (g_robot_state.safely_started == 1)
{
if ((g_remote.online_flag == REMOTE_OFFLINE) || (g_remote.controller.right_switch == DOWN))
{
Expand Down Expand Up @@ -202,7 +204,7 @@ void Robot_Cmd_Loop()
{
if (g_remote.controller.right_switch == DOWN)
{
g_start_safely = 1;
g_robot_state.safely_started = 1;
}
}
}
Expand Down

0 comments on commit c62179e

Please sign in to comment.