_mode flag summary??

I searched, but I did not find…

Can someone definitively describe the various “_mode” flags in the code, such as autonomous_mode and competition_mode (now called disabled_mode this year, to better reflect the polarity of the bit!) and any similar flags? See below:

/*
 *-----------------------------------------------------------------------------------------------------
 *---------- Aliases for User Modes  ------------------------------------------------------------------
 *-----------------------------------------------------------------------------------------------------
 * These bits tell you what mode your robot is currently in.
 *     1 = in <X> mode; 0 = not in <X> mode
 */

#define user_display_mode   rxdata.rc_mode_byte.mode.user_display
#define autonomous_mode     rxdata.rc_mode_byte.mode.autonomous
#define disabled_mode       rxdata.rc_mode_byte.mode.disabled

I am particularly interested in how they are controlled by the Match Computer. I have a dongle, but that doesn’t tell me under what circumstances which flag is in what state.

This year is especially interesting. For example:

  1. What happens when the human player steps off the switch pad? Do any flags indicate this?

  2. How do I make a timer that measures match time, including the time the human player is off the pad? Last year I simply had a counter in Default_Code(), but that ran all the time, even before the match started.

  3. There is a dead time between autonomous and manual mode during each match for the officials to award tetras, etc. How can my software know when that is the state?

  4. How can I code a “software reset”, so that all the “time counters” can be reset without having to press the “reset” button on the RC? This is especially important for the second run of practice matches.

If someone could describe an example match and how it is reflected in the _mode bits, that would be really helpful.

Thanks all!

  1. Robots are in disabled mode when the human is off the pad, therefore the disabled flag is raised.

  2. Use an onboard timer that starts couting when auto mode starts. Increment one variable every timer click (or every 10 timer clicks, depending on the resolution). Then, increment one other variable only when the robot is in auto mode or user mode. Take the difference to know how much time the robot was in disabled mode.

  3. Look for when the mode flag changes from auto to disabled, then call whatever.

  4. map a button on the joystick to a function that resets your timer variables, stops the hardware timer, then retarts the process.

Hope this helps.

Last year we reset our autonomous whenever the robot was disabled. The drivers didn’t have to remember to reset for the second practice match.

Last year the actual sequence at the SBPLI Regional was:

  • Disable bit set before the match started
  • Both disable and autonomous bits set
  • Then disable was turned off to start the autonomous mode
  • Finally the autonomous bit went off as the user_mode came on

One team had their autonomous timer ticking off while the robot was disabled at the beginning of the match, so the robot always thought it was partway or completely through the 15 seconds, before they were enabled and allowed to move.

I has occured to me that with the code running, and the Camera not controlled thru the RC outputs, the camera can be operating and searching for a target before the match starts. Is this right?

This would allow a robot to scan for the vision tetras before things start.

Control of the camera is all through the serial port.

It is possible, and there is nothing (yet) to say it is illegal.