Skip to content

The updated code for the TShirt Cannon bot (AAA) as of 2024

Notifications You must be signed in to change notification settings

team20/TShirtCannon

Repository files navigation

Team 20's T-Shirt cannon

Controls

The T-Shirt cannon is a standard tank drive, left trigger to turn left, right trigger to turn right, and left joystick to go forwards and backwards.

Charging the cannons uses the DPad. All cannons charge at the same time to the same pressure. Pressing down charges to 20 PSI, right charges to 40 PSI, and up charges to 60 PSI.

Firing the cannons requires the left bumper to be held down to prevent accidental firings. Once the left bumper is held down, press the square button to fire the left cannon, press the triangle button to fire the middle cannon, and press the circle button to fire the right cannon.

Press and hold the touchpad to turn on the horn, release to turn it off.

Controls Action
Drive Controls
Left Trigger Spin left
Right Trigger Spin right
Left Joystick Drive forward/backward
Cannon Controls
DPad Down Charge cannons to 20 PSI
DPad Right Charge cannons to 40 PSI
DPad Up Charge cannons to 60 PSI
Left Bumper + Square Fire left cannon
Left Bumper + Triangle Fire middle cannon
Left Bumper + Circle Fire right cannon
Left Bumper + X Fire all cannons
Horn Controls
Touchpad (hold) Turn on the horn
LED Controls
Share RainbowPartyFunTime
Options Shen Lights

The cannon

There are three cannons, each with a double solenoid and an analog pressure sensor.

Pressure calculations

The analog pressure sensor starts at ~0.47 volts when the PSI is 0. At 45 PSI, the voltage is ~1.37 volts. This works out to 50 PSI per volt. To calculate the pressure from the analog sensor, we read the voltage, subtract 0.47 (to normalize the voltage to 0), and multiply by 50 to get the PSI of the cannon.

Controlling the cannon solenoids

When the double solenoid is set to kForward, the cannon builds pressure. When the double solenoid is set to kReverse, the cannon fires.

The command that charges all the cannons simultaneously checks if a cannon is below the target PSI. If it is, it will set the cannon's solenoid to kReverse and charges the cannon. If the cannon's pressure is above the target PSI, it sets the cannon to kOff, stopping the charge. The command runs these checks for all three cannons. The command ends when all the cannons are above the target pressure. As a backup measure, the command will set all solenoids to kOff when the command is ended. This also means if you fire a cannon early, all cannons will stop charging.

The commands that fire a cannon sets the solenoid to kForward, then sets the solenoid to kOff.

The horn and light

The horn and light are each controlled by a VEX Relay (connected to the Relay ports).

The horn is honked by setting the relay to kOn. The command that does this then also sets the relay to kOff to turn off the horn when the command ends. The button binding is hold to run, so the command ends and the horn turns off when the button is released.

The light can be turned on by setting the relay to either kForward or kReverse, which represent different directions that the light can spin. kForward spins the light clockwise, kReverse spins the light counterclockwise.

About

The updated code for the TShirt Cannon bot (AAA) as of 2024

Resources

Stars

Watchers

Forks