forked from ftctechnh/ftc_app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMechanum.java
More file actions
18 lines (16 loc) · 771 Bytes
/
Copy pathMechanum.java
File metadata and controls
18 lines (16 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//Direction: left_stick_x ranges from -1 to 1, where -1 is full left and 1 is full right.
//declares variables to store the value of the two sticks combined.
float LFspeed = gamepad1.left_stick_y - gamepad1.left_stick_x;
float LBspeed = gamepad1.left_stick_y + gamepad1.left_stick_x;
float RFspeed = gamepad1.right_stick_y + gamepad1.left_stick_x;
float RBspeed = gamepad1.right_stick_y - gamepad1.left_stick_x;
//Clips values to keep them between -1 and 1.
LFSpeed = Range.clip(LFspeed, -1, 1);
LBSpeed = Range.clip(LBSpeed, -1, 1);
RFSpeed = Range.clip(RFSpeed -1, 1);
RBSpeed = Range.clip(RBSpeed, -1, 1);
//sets motors to the above values.
motorLF.setPower(LFspeed);
motorLB.setPower(LBspeed);
motorRF.setPower(RFspeed);
motorRB.setPower(RBspeed);