Function Callback Not Working in Driver Control

Recently, we were at our State Championships (Yes, our State Championships is indeed in November) and we faced issues during driver control in several matches, none of the function callbacks of the buttons were working, so we couldn’t control anything on our robot - puncher, wings, blocker, intake. However, our joysticks were still operating fine and we could drive normally. But all the controls worked perfectly fine when we tested the robot on the practice fields under ‘Timed Run’ on our controller, without the Competition switch. We tried a variety of solutions (switching controller and radio) but ultimately, switching the brain fixed the issue. The most annoying part is that of the 6 matches we played before replacing the brain, only 4 of them had this issue and the controls were completely fine in 2 matches. Although we still won the tournament when we resolved the issue with a new brain, we want to know whether anyone else has encountered similar issues before. Is it purely just a faulty brain, TM or even our code? For reference, our code was almost identical in the 2 previous tournaments that we went to, where we didn’t have any of these control issues.

Below is our Driver Control Code if this helps:

void user_control(void)
{
  con_player.ButtonB.pressed(toggle_blocker);
  con_player.ButtonR1.pressed(toggle_tail);
  con_player.ButtonR2.pressed(toggle_rwing);
  con_player.ButtonL2.pressed(toggle_lwing);
  con_player.ButtonA.pressed(toggle_cata);
  con_player.ButtonX.pressed(toggle_drivetrain_stopping);
  while (1)
  {
    con_movement.drive(con_player.Axis3.position(),
                       con_player.Axis2.position());
    wait(20, msec);
  }
}

If code behaving differently under field control, you might want to look here:

1 Like

Do not register event handlers in user_controil. There’s a very good change user_control is called more than once.

2 Likes

Thanks for the response, if I were to register the function callbacks in pre_auton, would I not face the same issue?

pre_auton or main, same result (as pre_auton is usually just called once from main)

2 Likes