Skip to content

Z Code Documentation 2021

LightenDarkness edited this page Sep 18, 2022 · 1 revision

This is the coding documentation for the Truckee Robotics Team.

Bruteforce Scripts

The two scripts, BruteforceRed.java and BruteforceBlue.java, use a move by time method to achieve goals. The reason why it’s called Bruteforce is because the robot does not know what its location is.

BruteforceBlue code

BruteforceRed code

Functions

The following functions are all of the self-coded functions used in the Bruteforce scripts

Calc Power

Sets the wheels on the robot to the correct power calculations for a mecanum wheel robot. The parameters are based on a controller layout. For example, y is the left joystick y if you were driving this robot with a controller.

Parameters: double y, double x, double rx.

Usage

//move forward
calcPower(1, 0, 0);
//move backwords
calcPower(-1, 0, 0);
//strafe left
calcPower(0, -1, 0);
//spin right
calcPower(0, 0, 1);

What do these scripts do

BruteforceRed.java will drive backward for 0.3 seconds, strafe to the right for 2.5 seconds, turn on the spinning wheel for 3 seconds, drive back into the storage box for 1.5 seconds, finally all motors will be turned off. All movements are done with motors at half speed.

BruteforceBlue.java will strafe to the left for 0.5 seconds, drive forward for 2.6 seconds, turn on the spinning wheel for 3 seconds, pause for 0.5 seconds, strafe to the left into the storage box for 1.5 seconds, and finally, all motors will have the power set to 0.

Main Robot Script

The robot script (codename: big boi): bigboi.java uses a controller to control a mecanum wheel robot.

Bigboi github code

Controls

Controler 1

Button Action
Left joystick y move forward/backward
Left joystick x strafe left/right
Right joystick x spin left/right
Left bumper spin wheel
Right bumper spin wheel backward

Controler 2:

Button Action
Hold X intake takes in
Hold B intake outputs
Dpad up linear slide moves up
Dpad down linear slide moves down

There are no functions defined in this script.