Programming Opcontrol

Macros, or a set of actions run after a button in pressed, are what you are looking for. This would be a function that say, tilts a tray forward then backs away without any driver input. A button press on the controller could call that function, making driving easier.

This removes the human element from the risky manuvers, and helps with reliability and reduces driver error.


You can do different things depending on your design of robot. For example, if you have a DR4B you can have preset heights for the lift for poles, while still having a manual control of your lift. It differs from drivers, like some will want tasks done on their own, others prefer to do on own.

Slew rate drive

20 char

ok guys thanks a lot for the suggestions will for sure take your advice and try to implament it!!

Look up these topics:
PID - guide
Statemachines - example

You can find many VEX programs on github or on the forum for examples.

An extreme example of drivercontrol automation is in our Turning Point showcase, under “Angling Hood”:


You can do different driver control layouts
(i,e; arcade drive, tank, one stick drive one stick lift, etc.)

Here is an explanation of some of the operator control programming “assists” that we used last season: What do you think is a more efficient way to drive your robot?

Just like others have mentioned, we also used macros and state-machines for tasks like pressing a button once and having our arm move up to a predefined height, or pressing one button and shooting exactly one/two balls.

1 Like

You might also want to have some programmed “anti-tips”. Don’t allow your robot to change acceleration too rapidly and accidentally tip itself. This might not be necessary depending on your design, but say you have a DR4B. If the lift is all the way extended, your driver won’t be able to know what the exact limit is for changing acceleration while the lift is up, this can cause the robot to tip. So you can fix that by limiting drive speed or direction changes with code. (i.e. rapidly going forward then backward can be limited).

1 Like

How would you limit the acceleration/deceleration?

With code, remember what acceleration is. A change in velocity. So if your robot has a high velocity (near max) then you can use a non-linear regression for the case when the robot changes direction immediately (from forwards to backwards).

Sorry,I should have been more specific. How would you program that.

You’d need to tune it to your specific robot as some robots are more sensitive to acceleration changes than others and some are more sensitive when the robot is in a certain state (i.e. lift is up, tray is full, etc). A non-linear regression is essentially a cubic or quartic function. So all you’d do is run the controller input value through that function only when the robot is that certain tipping state that I mentioned above when the robot changes direction.

Would it also be possible to add a gyro to automatically prevent tipping.

That’s easier said than done. You’d need to change the orientation of the gyro so that it is mounted vertically on the robot. As for coding that, you’d need an algorithm that understands the relationship between “tip angle” (how far back or front the robot is tipped) and the velocity of the base. Presumably, if the robot is tipping backwards, you’d want the back wheels to spin forward and vice versa for the other scenario. Tuning that would probably be very difficult. Also, you have to consider gyro drift, what if the gyro gets a false reading and randomly tries to anti tip in the middle of a match.

You can use gyro sensor to improve driving and implement a deadzone using an array.

You can try resetting the gyro automatically if that happens. Or at least I think you can do that

Thanks a lot for showing me that forum, i will for sure take a look and try to understand it

For the equation you sent, does that work for left and right joysticks because we use tank control ?
and also if you have experiance in PROS would it look like this

left_drive_set((powf(controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y),3))/ powf(127,2));
void left_drive_set (int speed) 


Yes, it will work with both of the joysticks, so you can use it with tank control. I took a very similar approach to the way you have shown, so it should work.

ok then thanks a lot

1 Like