-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetVolocity.java
More file actions
48 lines (40 loc) · 1.84 KB
/
SetVolocity.java
File metadata and controls
48 lines (40 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// set volocity is a better way to move the robot instead of using set power, especially for autonomous.
/*
This example code was found on game manuel zero
at https://gm0.org/en/latest/docs/software/tutorials/mecanum-drive.html
*/
package org.firstinspires.ftc.teamcode.reference.gm0_examples;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.hardware.IMU;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.hardware.rev.RevHubOrientationOnRobot;
import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit;
@TeleOp
public class SetVolocity extends LinearOpMode {
@Override
public void runOpMode() throws InterruptedException {
// Declare our motors
// Make sure your ID's match your configuration
DcMotor frontLeftMotor = hardwareMap.dcMotor.get("fl");
DcMotor backLeftMotor = hardwareMap.dcMotor.get("bl");
DcMotor frontRightMotor = hardwareMap.dcMotor.get("fr");
DcMotor backRightMotor = hardwareMap.dcMotor.get("br");
// Reverse the right side motors. This may be wrong for your setup.
// If your robot moves backwards when commanded to go forwards,
// reverse the left side instead.
// See the note about this earlier on this page.
frontRightMotor.setDirection(DcMotorSimple.Direction.REVERSE);
backRightMotor.setDirection(DcMotorSimple.Direction.REVERSE);
waitForStart();
if (isStopRequested()) return;
while (opModeIsActive()) {
int speed = 5000;
frontLeftMotor.setVolocity(speed);
backLeftMotor.setVolocity(speed);
frontRightMotor.setVolocity(speed);
backRightMotor.setVolocity(speed);
}
}
}