Allowed Hat Blocks in V5 Competition

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:

  1. 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?

  2. Is it acceptable to use multiple ‘When Driver Control’ blocks or is it preferred to use just one?

  3. Can you use ‘My Blocks’ in Autonomous or should your code be linear?

  4. 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.

Welcome!

Y̶o̶u̶ ̶d̶o̶n̶’̶t̶ ̶̶h̶a̶v̶e̶̶ ̶t̶o̶ ̶u̶s̶e̶ ̶t̶h̶e̶ ̶’̶W̶h̶e̶n̶ ̶D̶r̶i̶v̶e̶r̶ ̶C̶o̶n̶t̶r̶o̶l̶’̶,̶ ̶’̶W̶h̶e̶n̶ ̶A̶u̶t̶o̶n̶o̶m̶o̶u̶s̶’̶,̶ ̶y̶o̶u̶ ̶c̶a̶n̶ ̶h̶a̶v̶e̶ ̶t̶h̶e̶ ̶p̶r̶o̶g̶r̶a̶m̶s̶ ̶s̶e̶p̶a̶r̶a̶t̶e̶d̶,̶ ̶a̶n̶d̶ ̶r̶u̶n̶ ̶t̶h̶e̶m̶ ̶i̶n̶d̶e̶p̶e̶n̶d̶e̶n̶t̶l̶y̶ ̶d̶u̶r̶i̶n̶g̶ ̶e̶a̶c̶h̶ ̶p̶e̶r̶i̶o̶d̶. ← (Refer to @holbrook’s post).
I believe you can use ‘When Controller Button Pressed’, but only during Driver Control.

I don’t see a problem with using multiple. Though referring to the same motor in multiple may cause problems.

The program is still linear since ‘My Blocks’ acts as a function.

I would say it would work the same. I have haven’t paid that much attention.

Hopefully this helps as an early response. But I would wait a bit longer for someone who knows more to answer, cause I have never thought about some of those questions before (good questions :+1:).

3 Likes

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

2 Likes

StuartV,

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.

kmmohn,

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).

6 Likes

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.

1 Like

holbrook,

Thanks for pointing out . I think I was complying with that even though I had forgotten about reading it.

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.

  1. 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?

  2. 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.

More on how field control works in this thread:

5 Likes

holbrook,

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.

1 Like