ROBOTC Competition Switch Bug

Let me try and explain what is happening and why ROBOTC has less control over this than you may think.

There are only two messages that are sent using the programming cable that can control the competition mode.

  1. A message that toggles the disabled/enabled state. Every time this message is sent the current state is changed, if the robot is disabled then it will be enabled, if the robot is enabled then it will be disabled. If the robot is not in game mode then the first message will place the robot into the disabled state.

  2. A message that toggles the autonomous/driver control flag. Each time this message is sent the robot will change modes.

Put this information aside for a moment and consider the architecture of the cortex. As we have discussed many times, the cortex contains two micro-controllers that we have referred to as the master processor and user processor. ROBOTC (and EasyC, ConVEX and PROS) runs on the user processor, the master processor controls the USB port, either in tethered mode or with VEXnet, the motors and competition state. The user processor communicates periodically with the master processor, the user processor sends motor speeds for motor ports 1 through 9 and receives the joystick and other status. One of the status bytes contains two flags (bits within the byte) that indicate what the competition state is, that is, is the robot disabled or enabled and is it in autonomous or driver control. These two flags are read by ROBOTC and used to set the variables that can be read by the code as bIfiRobotDisabled and bIfiAutonomousMode. They are also sent back to the PC when we are debugging and displayed in the system parameters window as well as being used by the competition switch simulation. There is a major issue with these two flags, the auton/driver control flag does not indicate the correct status when the robot is disabled.

So what happens with ROBOTC.

We push the Autonomous button, ROBOTC sends the message to toggle the competition disabled/enabled state but does not know for certain if the robot will enter autonomous or driver control. ROBOTC checks to see if the robot is enabled and also the auton/driver status, if it finds that the robot has entered the driver control mode then it sends the message to toggle auton/driver control. This is why when you start either mode, auton or driver, you may find the robot briefly starts in the wrong one and then changes.

With only three buttons it’s very easy to get ROBOTC out of sync with the actual operation of the robot.

My advice, don’t use the competition switch simulation and always use a real competition switch.

ROBOTC V4.06 has an additional bug where the auton/driver flag seems to be changing state on it’s own. This is a new bug that was not present in the V3.6X versions and needs to be fixed.