Hi all, first post. I hope this is in the correct spot.
I’m volunteering to help our robotics club with their programming; they are limiting to V5 Blocks for this year until they get spun up on the text programming. I’m fine with the blocks programming, but have some questions on the Hat Blocks allowed for competition. Specifically the following:
I know you need the ‘When Started’, ‘When Driver Control’, and When Autonomous’ blocks, but can you have other Hat Blocks? Specifically, can you use the ‘When SwitchX Pressed’, or ‘When Controller Button Pressed’ blocks?
Is it acceptable to use multiple ‘When Driver Control’ blocks or is it preferred to use just one?
Can you use ‘My Blocks’ in Autonomous or should your code be linear?
We are using a Competition Switch to simulate Autonomous and Driver Control. Is it safe to assume that if it works with the Competition Switch it will work in an actual competition? Or are there some differences?
I know this is long for a first post, but I’ve hit a bit of a wall on this and Google isn’t helping with any references. Thanks.
If you’re asking what programming techniques are legal, then we have to consider that the game manual doesn’t give many restrictions on programming techniques at all, it’s simply has to work with the tournament manager system. The fact that you are using the competition switch pretty much insures your autonomous program is compatible, since that is how the referees will inspect the robot at the beginning, by checking it’s operation using the switch
Thanks for the quick response. My main concern was to get our lift and basket working in Driver Control. The best way I’ve found is to use a ‘When Button Pressed’ block or multiple ‘Driver Control’ blocks. I was also worried about having something working with our Competition switch and turnig out to be disallowed in acutual competition. Hopefully others will chime in with their experience. Thanks again.
Thanks for your insight, that’s what I was hoping to hear. I haven’t run across any mention of the referees digging into the code so I’ll proceed with the assumption that as long as it works with the Competition Switch, it will work at competition. Now to get our programmer up to speed on PID…
I think having separate programs for autonomous and driver control might be a violation of R27:
In any case, I’m not sure why you would want to use two separate programs instead of one program that responds to the field controller as designed.
Just put your autonomous code under a “when autonomous” hat, and any code that needs to start at the beginning of teleop under a “when driver control” hat. Additional hat blocks triggered by controller button presses will work only during teleop, just as they’re supposed to.
The game manual does not place any restrictions on what your code looks like or how it is structured, as long as it is in a competition template and interacts correctly with the field control hardware (as tested by using the competition switch – there is no functional difference between how the brain’s firmware responds to the competition switch and how it responds to the actual field control hardware).
I did not know that. When my team’s done autonomous, the period starts then we click Start on our program and put down our controller. I’m going to have to remember that in future.
I’ll change my post above for clarity.
Thanks for all the replies, I think I’m getting a handle on how this should be structured. Just a couple of follow-up questions before I try to explain this to our programmer.
Per R27, I’m guessing a ‘functional equivalent’ to the ‘Competition Template’ is one that has the ‘When Started’, ‘When Driver Control’, and ‘When Autonomous’ hat blocks. Does the Competition Template contain anything else behind the scenes that would be needed? In other words, can I just add those hat blocks to my current program or should I copy my code over to the official Competition Template?
During ‘When Started’, motor movement and the joystick are disabled. During ‘When Autonomous’, motor movement is allowed but the joystick is disabled. During ‘When Driver Control’, both joystick and motor movement are allowed, thus the ‘When Button Pressed’ hat blocks will only work during Driver Control. Is this correct or did I mixed something up?
Thanks again for all the input on this. Sorry if it seems that I’m belaboring the issue, but I just want to make sure I have it down accurately before I go over it with our programmer.
You can just add those blocks to your current program. In VEXcode blocks, the “competition template” is just a blank program with “when autonomous” and “when driver control” hat blocks added, nothing else special going on.
This is correct – another way to think about it is that there are 3 states the robot can be in when under competition control:
Disabled: All motors are stopped; user code can’t move motors or read inputs from controller, but can do other stuff (read from/calibrate sensors, draw to the screen, etc.).
Autonomous: User code can move motors but can’t read inputs from the controller.
Driver control: User code can move motors and read inputs from controller.
If you run the program without being connected to a field or competition switch, you’ll start in the driver control state. When you plug into the field before a match, you’ll start in the disabled state, and the tournament manager software will switch all 4 robots into the autonomous and driver control states at the appropriate points in the match (you’ll go back to disabled in between the auton and driver control periods).
The competition switch does the same job as the field control hardware, it’s just controlled by a couple of switches rather than by tournament manager.
The “when started” hat block starts running when the program is started, regardless of what state the robot is in. The “when autonomous” hat block starts running when the robot enters the autonomous state. The “when driver control” hat block starts running when the robot enters the driver control state. When you switch into the disable state, any stacks under “when autonomous” or “when driver control” hats are stopped.
Thanks for confirming my conclusions, it’s good to know I was on the right track. Also, thanks for the link, that’s an informative (and in depth) thread on how the Field Controller system works. I’m just glad VEX has the Competition Switch so we don’t have to purchase the more expensive Field Controller for testing.
I’m marking your post as the solution as it ties together all the other great responses.