-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathSampleAutonomous.java
More file actions
61 lines (50 loc) · 2.19 KB
/
SampleAutonomous.java
File metadata and controls
61 lines (50 loc) · 2.19 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
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Created by Phil Malone. 2023.
This class illustrates my simplified Odometry Strategy.
It implements basic straight line motions but with heading and drift controls to limit drift.
See the readme for a link to a video tutorial explaining the operation and limitations of the code.
*/
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
/*
* This OpMode illustrates an autonomous opmode using simple Odometry
* All robot functions are performed by an external "Robot" class that manages all hardware interactions.
* Pure Drive or Strafe motions are maintained using two Odometry Wheels.
* The IMU gyro is used to stabilize the heading during all motions
*/
@Autonomous(name="Sample Autonomous", group = "Mr. Phil")
public class SampleAutonomous extends LinearOpMode
{
// get an instance of the "Robot" class.
private SimplifiedOdometryRobot robot = new SimplifiedOdometryRobot(this);
@Override public void runOpMode()
{
// Initialize the robot hardware & Turn on telemetry
robot.initialize(true);
// Wait for driver to press start
telemetry.addData(">", "Touch Play to run Auto");
telemetry.update();
waitForStart();
robot.resetHeading(); // Reset heading to set a baseline for Auto
// Run Auto if stop was not pressed.
if (opModeIsActive())
{
// Note, this example takes more than 30 seconds to execute, so turn OFF the auto timer.
// Drive a large rectangle, turning at each corner
robot.drive( 84, 0.60, 0.25);
robot.turnTo(90, 0.45, 0.5);
robot.drive( 72, 0.60, 0.25);
robot.turnTo(180, 0.45, 0.5);
robot.drive( 84, 0.60, 0.25);
robot.turnTo(270, 0.45, 0.5);
robot.drive( 72, 0.60, 0.25);
robot.turnTo(0, 0.45, 0.5);
sleep(500);
// Drive the path again without turning.
robot.drive( 84, 0.60, 0.15);
robot.strafe( 72, 0.60, 0.15);
robot.drive( -84, 0.60, 0.15);
robot.strafe(-72, 0.60, 0.15);
}
}
}