V5 brake type/PID gyro control in Driver Control

When initializing the robot’s brake type in a program, where should I put the code to do so? In the initialize.cpp or the program which I’m running it in? Furthermore, how would I run the three programs in the project all together like a competition? Would I have to select it as a competition program? I’m also interested in knowing how to make my robot drive straight. During the driver control period, whether or not that is recommended. But only when I desire to do so. By using arcade control to go straight. Hopefully, someone has an answer.

You can buy a competition switch and use that to select auton or driver control mode. But you have to write your program in competition template first.


But is there anything else than the competition switch to allow me to simulate the conditions of the competition? The competition is rather pricey($57 with taxes). In canada, plus shipping fees. The larger issue is the fact that they may release a better competition switch V2 to fit the new sensors released along with the V5.

I highly doubt a v2 switch will be released. It doesn’t have anything to do with interfacing with sensors, but rather tells the robot when to switch into driver and autonomous modes.
On the Vex website it shows CA$25.99 - do you really have to pay that much tax?https://www.vexrobotics.com/276-2335.html

However, I don’t think that you need one to run auton. I don’t have a controller with me right now, but if you press ‘Timed Run’ or ‘Competition’ instead of ‘Run’ when you have selected a program on V5, I’m pretty sure it will do the auton without a switch. (The program does have to be formatted in a competition template)

About going straight - during driver control, it is generally much easier to just correct the turning by hand with the controller. In auton however, some correction in code is often needed. The best way of doing this is using a PID algorithm. There are many resources and threads already out there about this.
Here’s a recent example:

1 Like

But I was worried that it may not always go straight, by simply using the encoders. I thought that the wheels may slip causing irregularities. And using a Gyroscope would make it easier to drive.

I’ve tried to do this before here . The brakemode of pros just doesnt work. See my holding example. Also, the autonomous, opcontrol, disabled and competition-initialize functions is called with a competition switch. the initialize function will be called first no matter what and op control will be next. Note that initialize and opcontrol will be called even without a competition switch. You can also test out only your autonomous function but not the disabled and competition-initialize by pressing your program->competition->Programming skills or ur program->timed run. Timed run will run 15 sec of auton and 1:45 of opcontrol like a real competition. Next, ur 3rd question, i do not recommend making the robot drive “straight” or tweaking the speed during opcontrol. This will make the control very limited (maybe he wants to curve a bit but the program limits him). However, you can make some buttons dedicated for strait forward movement and straight backwards movement (but i dont really use them in competition cause the reason to put a driver there in the opcontrol peirod is because they can adjust to make the robot go strait again). For how to make the robot go straight in autonomous and opcontrol, see this.


And by pressing my program then timed run, will it automatically run the initialization code?

yes no matter what you run, initialize must and will run first. (whispers: you can test it yourself)

1 Like

The only reason, I’m asking here is because I don’t have the robot available on hand. I will not happen to have it for another 2 weeks. But thanks for the help.

Good luck using pros! I spent more than a year to learn enough c++ and gain enough experience of pros to create my api im using now. Is has a very wide range of functions (not boasting or advertising here) like async mode functions, which includes lockthread, unlock thread when condition is met, wait until all finished etc and vision, pid, lvgl and more. I had gained a lot of experience on this forum with a lot of smart and kind people. If you have any questions on programming, feel free to ask!


Thanks for offering!.

See this.

@Eden (and others)
When you set the brake mode on the motor, the motor stores and remembers that mode.
However, to get it to brake, you must set the motor to 0 velocity, not voltage.
Setting voltage simply makes the motor coast - you are setting 0 voltage.
However, when you say 0 velocity, the motor (depending on brake mode) will try to actively achieve 0 velocity.

1 Like

Ive tried it before here. It only supplys a small force, not enough to hold it only spot or resist another robot.