What type programs are teams using in order to move the tilter out of the way when moving the arm.
My team uses pre-programmed positions for the arm and tray,
Example: (You can add/remove positions as you need)
Tray Positions:
Pos 0: Starting Position
Pos 1: Intaking Position (Same as Pos 0)
Pos 2: Almost Vertical Position (We use this so we can judge if the stack is in the right place before finishing the placement)
Pos 3: Vertical Position
Arm Positions:
Pos 0: Starting Position
Pos 1: Intaking Position (A little higher than Pos 0)
Pos 2: Low Tower Position
Pos 3: Med Tower Position
The way we change between them is by using IF statements for Arm/Tray Position
EX: (Typed in from memory, so the syntax isn’t exactly right)
if (armPosition == 0) {
armMotor.spinto(0, deg, 50rpm);
}
else if (armPosition == 1) {
armMotor.spinto(70, deg, 50rpm);
}
If you wanted to move the tray to a position while the arm is at a certain position, you simply add trayPosition to the loop
if (armPosition == 0) {
armMotor.spinto(0, deg, 50rpm);
}
else if (armPosition == 1) {
armMotor.spinto(70, deg, 50rpm);
trayPosition = 1;
}
To change the position with the buttons, we do something like this:
if (buttonLeft.pressed) {
if (armPosition <= 3) {
armPosition = armPosition + 1;
}
if (armPosition > 3) {
armPosition = 1;
}
wait(.15,sec);
}
What happens with this is :
When the button is pressed:
If armPosition is less than or equal to 3, it adds 1 to the value of armPosition.
Then it looks at armPosition, and if the position is greater than 3, it sets it to 1.
Then it waits .15 seconds and repeats the cycle
In English, what this does is:
When you press the button when it’s at intaking position, it goes to the Low Tower.
If you Press it again, it goes to the Mid Tower.
Press it another time, and it resets back to the Intake Position.
Hope this Helps!
Thank you. I will try.
Can you explain more about pre-programed positions? If we accidentally start the tray from a different position, values might get messed upright? we tried hard coding values, but that keeps changing while testing.
I used to use the tray encoders, but I had some strange issues during matches where after autonomous the motor encoders would reset (not sure if this is normal behavior from field control or not.) so I use a limit switch to get an absolute 0 value for my tray. whenever the limit switch is pressed, the encoder on the tray gets set to 0. at the star of the code, I tell the tray to go down until the limit switch is pressed. that way no matter how I start the robot, it will always know where I want it to go.
that make totally sense.
That is exactly what we do