-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d302437
commit f2f99a3
Showing
5 changed files
with
104 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/RIC_samples/AutonomousSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.firstinspires.ftc.teamcode.RIC_samples; | ||
|
||
import com.acmerobotics.roadrunner.Pose2d; | ||
import com.acmerobotics.roadrunner.Vector2d; | ||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous; | ||
|
||
import org.firstinspires.ftc.teamcode.DriveControls.SimpleMecanumDrive.DriveCommandPackage; | ||
import org.firstinspires.ftc.teamcode.utils.AutonomousProgramTemplate; | ||
import org.firstinspires.ftc.teamcode.utils.enums.AutonomousLocation; | ||
|
||
@Autonomous(name = "AutonomousSample",group = "SAMPLE") | ||
public class AutonomousSample extends AutonomousProgramTemplate { | ||
@Override | ||
public void runOpMode() { | ||
Init(new Pose2d(0,0,0)); | ||
robot.client.addData("Position","WAITING FOR REQUEST"); | ||
AutonomousLocation location = AutonomousLocation.failed; | ||
while (opModeIsNotActive()) { | ||
location=robot.webcam.getLocation(); | ||
robot.client.changeDate("Position",location.name()); | ||
sleep(50); | ||
} | ||
|
||
if(!WaitForStartRequest())return; | ||
|
||
robot.client.deleteDate("Position"); | ||
switch (location){ | ||
case left: | ||
robot.strafeTo(robot.pose().position.plus(new Vector2d(0,24))); | ||
robot.turnAngle(90); | ||
robot.strafeTo(new Vector2d(24,0)); | ||
break; | ||
case centre: | ||
DriveCommandPackage command=drive.drivingCommandsBuilder() | ||
.StrafeTo(robot.pose().position.plus(new Vector2d(0,24))) | ||
.TurnAngle(90) | ||
.StrafeInDistance(Math.toRadians(-90),Math.sqrt(1152)) | ||
.END(); | ||
drive.runDriveCommandPackage(command); | ||
break; | ||
case right: | ||
break; | ||
case failed: | ||
return; | ||
} | ||
|
||
sleep(1145141919); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/utils/AutonomousProgramTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.firstinspires.ftc.teamcode.utils; | ||
|
||
import com.acmerobotics.roadrunner.Pose2d; | ||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; | ||
|
||
import org.firstinspires.ftc.teamcode.DriveControls.SimpleMecanumDrive; | ||
import org.firstinspires.ftc.teamcode.Robot; | ||
import org.firstinspires.ftc.teamcode.utils.enums.runningState; | ||
|
||
public abstract class AutonomousProgramTemplate extends LinearOpMode { | ||
public Robot robot; | ||
public SimpleMecanumDrive drive; | ||
|
||
public void Init(Pose2d position){ | ||
robot=new Robot(hardwareMap, runningState.Autonomous,telemetry); | ||
drive=robot.enableSimpleMecanumDrive(position); | ||
} | ||
public boolean WaitForStartRequest(){ | ||
while(opModeIsNotActive()){ | ||
sleep(50); | ||
} | ||
|
||
return opModeStopped(); | ||
} | ||
public boolean opModeIsNotActive(){ | ||
return !opModeIsActive()&&!isStopRequested(); | ||
} | ||
public boolean opModeStopped(){ | ||
return opModeIsActive() && ! isStopRequested(); | ||
} | ||
} |