Is there a flag or variable or something in ROBOTC to detect if at actual competition? For example, it would be false if I am just practicing or using ROBOTC’s debugger competition switch, but would be true if I am actually at a competition, and plugged into the Field Control System? The reason for this is I use a DEBUG flag to determine whether to run certain blocks of code. But I am inevitably going to forget to turn it off then night before a competition, and we will be struggling to figure out why our robot is not working.
Can anyone offer me some wisdom, or is this simply not possible?
I want to say
@jpearman was able to do this in one of his longer analysis posts, but I can’t find it right now. Will edit if I do
VEX V5 General Discussion
The RobotC competition template has been confusing for some students, I though I would try and demystify this and give an overview of how it works. Before diving into the code, it needs to be understood that any RobotC program can be used in...
Reading time: 5 mins 🕑
Likes: 10 ❤
Few different Jpearman threads. From these I believe your software can not detect the difference between the simulated switch and the real switch.
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.
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.
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.
I dont understand the question, can someone explain
See also this thread:
It does not seem like I posted this was 5 years ago. Time flies.
Your right I had missed that. I would believe simulated ROBOTC competition switch would be different than the 2 physical switches you talk about in that post.