mirror of
https://github.com/TimeCrafters/FreightFrenzy.git
synced 2025-12-13 05:02:34 +00:00
Compare commits
3 Commits
99bbfee101
...
aa6ce00f3c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa6ce00f3c | ||
|
|
6eb9c46e59 | ||
| 9b98cf5840 |
@@ -49,6 +49,8 @@ import android.preference.PreferenceManager;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
@@ -410,6 +412,12 @@ public class FtcRobotControllerActivity extends Activity
|
|||||||
checkPreferredChannel();
|
checkPreferredChannel();
|
||||||
|
|
||||||
AnnotatedHooksClassFilter.getInstance().callOnCreateMethods(this);
|
AnnotatedHooksClassFilter.getInstance().callOnCreateMethods(this);
|
||||||
|
|
||||||
|
/* REV CONTROL HUB APPEARS TO PREVENT ANY APP NOT ON ITS WHITELIST FROM USING ON_BOOT_COMPLETED RECEIVERS */
|
||||||
|
/* USING THIS HACK DUE TO THAT... */
|
||||||
|
Intent tacnetIntent = new Intent("org.timecrafters.TimeCraftersConfigurationTool.tacnet.ACTION_START_SERVER");
|
||||||
|
tacnetIntent.setPackage("org.timecrafters.TimeCraftersConfigurationTool");
|
||||||
|
ContextCompat.startForegroundService(context, tacnetIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected UpdateUI createUpdateUI() {
|
protected UpdateUI createUpdateUI() {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,59 @@
|
|||||||
|
package org.timecrafters.FreightFrenzy.Competition.Autonomous.Engines;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
|
||||||
|
import org.cyberarm.engine.V2.CyberarmEngine;
|
||||||
|
import org.timecrafters.FreightFrenzy.Competition.Autonomous.States.CollectorToggle;
|
||||||
|
import org.timecrafters.FreightFrenzy.Competition.Autonomous.States.DriveState;
|
||||||
|
import org.timecrafters.FreightFrenzy.Competition.Autonomous.States.TensorFlowState;
|
||||||
|
import org.timecrafters.FreightFrenzy.Competition.Autonomous.States.TurretArmExtension;
|
||||||
|
import org.timecrafters.FreightFrenzy.Competition.Autonomous.States.TurretOrbit;
|
||||||
|
import org.timecrafters.FreightFrenzy.Competition.Common.Robot;
|
||||||
|
|
||||||
|
@Autonomous (name = "Blue Duck Autonomous", group = "blue")
|
||||||
|
public class BlueDuckEngine extends CyberarmEngine {
|
||||||
|
Robot robot;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
this.robot = new Robot(this);
|
||||||
|
robot.resetEncoders();
|
||||||
|
|
||||||
|
addState(new TurretOrbit(robot, robot.turretServoWhite, robot.whiteMag, "BlueDuckAutonomous", "01_0"));
|
||||||
|
addState(new TensorFlowState(robot, robot.whiteArmRiser, robot.whiteArmBobbin, "BlueDuckAutonomous", "01_1"));
|
||||||
|
// addState(new TurretArmExtension(robot, robot.whiteArmBobbin, "RedWarehouseAutonomous", "02_0"));
|
||||||
|
// addState(new TurretArmRiser(robot, robot.whiteArmRiser, "RedWarehouseAutonomous", "03_0_middle"));
|
||||||
|
// addState(new TurretArmExtension(robot, robot.whiteArmBobbin, "RedWarehouseAutonomous", "04_0"));
|
||||||
|
addState(new CollectorToggle(robot, robot.collectorWhite, "BlueDuckAutonomous", "05_0"));
|
||||||
|
addState(new CollectorToggle(robot, robot.collectorWhite, "BlueDuckAutonomous", "06_0"));
|
||||||
|
addState(new TurretArmExtension(robot, robot.whiteArmBobbin, "BlueDuckAutonomous", "07_0"));
|
||||||
|
addState(new DriveState(robot,"BlueDuckAutonomous", "08_0"));
|
||||||
|
addState(new DriveState(robot, "BlueDuckAutonomous", "09_0"));
|
||||||
|
addState(new TurretOrbit(robot, robot.turretServoWhite, null, "BlueDuckAutonomous", "10_0"));
|
||||||
|
addState(new DriveState(robot, "BlueDuckAutonomous", "10_1"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loop() {
|
||||||
|
super.loop();
|
||||||
|
|
||||||
|
telemetry.addData("white arm extension", robot.whiteArmBobbin.getCurrentPosition());
|
||||||
|
telemetry.addData("White Riser Arm", robot.whiteArmRiser.getCurrentPosition());
|
||||||
|
telemetry.addData("white Turret Switch", robot.whiteMag.isPressed());
|
||||||
|
telemetry.addData("white Turret orbit Power", robot.turretServoWhite.getPower());
|
||||||
|
telemetry.addData("White Door Position", robot.whiteDispenser.getPosition());
|
||||||
|
telemetry.addLine();
|
||||||
|
|
||||||
|
telemetry.addData("Orange Riser Arm", robot.orangeArmRiser.getCurrentPosition());
|
||||||
|
telemetry.addData("orange arm extension", robot.orangeArmBobbin.getCurrentPosition());
|
||||||
|
telemetry.addData("orange Turret Switch", robot.orangeMag.isPressed());
|
||||||
|
telemetry.addData("orange Turret Orbit Power", robot.turretServoOrange.getPower());
|
||||||
|
telemetry.addData("Orange Door Position", robot.orangeDispenser.getPosition());
|
||||||
|
telemetry.addLine();
|
||||||
|
|
||||||
|
telemetry.addData("driveWarehouseLeft", robot.driveWarehouseLeft.getCurrentPosition());
|
||||||
|
telemetry.addData("driveWarehouseRight", robot.driveWarehouseRight.getCurrentPosition());
|
||||||
|
telemetry.addData("driveGoalLeft", robot.driveGoalLeft.getCurrentPosition());
|
||||||
|
telemetry.addData("driveGoalRight", robot.driveGoalRight.getCurrentPosition());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,18 +18,20 @@ public class BlueWarehouseEngine extends CyberarmEngine {
|
|||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.robot = new Robot(this);
|
this.robot = new Robot(this);
|
||||||
|
robot.resetEncoders();
|
||||||
|
|
||||||
addState(new TurretOrbit(robot, robot.turretServoWhite, robot.whiteMag, "BlueWarehouseAutonomous", "01_0"));
|
addState(new TurretOrbit(robot, robot.turretServoOrange, robot.orangeMag, "BlueWarehouseAutonomous", "01_0"));
|
||||||
addState(new TensorFlowState(robot, robot.whiteArmRiser, robot.whiteArmBobbin, "BlueWarehouseAutonomous", "01_1"));
|
addState(new TensorFlowState(robot, robot.orangeArmRiser, robot.orangeArmBobbin, "BlueWarehouseAutonomous", "01_1"));
|
||||||
// addState(new TurretArmExtension(robot, robot.whiteArmBobbin, "BlueWarehouseAutonomous", "02_0"));
|
// addState(new TurretArmExtension(robot, robot.orangeArmBobbin, "RedWarehouseAutonomous", "02_0"));
|
||||||
// addState(new TurretArmRiser(robot, robot.whiteArmRiser, "BlueWarehouseAutonomous", "03_0_middle"));
|
// addState(new TurretArmRiser(robot, robot.orangeArmRiser, "RedWarehouseAutonomous", "03_0_middle"));
|
||||||
// addState(new TurretArmExtension(robot, robot.whiteArmBobbin, "BlueWarehouseAutonomous", "04_0_middle"));
|
// addState(new TurretArmExtension(robot, robot.orangeArmBobbin, "RedWarehouseAutonomous", "04_0"));
|
||||||
addState(new CollectorToggle(robot, robot.collectorWhite, "BlueWarehouseAutonomous", "05_0"));
|
addState(new CollectorToggle(robot, robot.collectorOrange, "BlueWarehouseAutonomous", "05_0"));
|
||||||
addState(new CollectorToggle(robot, robot.collectorWhite, "BlueWarehouseAutonomous", "06_0"));
|
addState(new CollectorToggle(robot, robot.collectorOrange, "BlueWarehouseAutonomous", "06_0"));
|
||||||
addState(new TurretArmExtension(robot, robot.whiteArmBobbin, "BlueWarehouseAutonomous", "07_0"));
|
addState(new TurretArmExtension(robot, robot.orangeArmBobbin, "BlueWarehouseAutonomous", "07_0"));
|
||||||
addState(new DriveState(robot,"BlueWarehouseAutonomous", "08_0"));
|
addState(new DriveState(robot,"BlueWarehouseAutonomous", "08_0"));
|
||||||
addState(new DriveState(robot, "BlueWarehouseAutonomous", "09_0"));
|
addState(new DriveState(robot, "BlueWarehouseAutonomous", "09_0"));
|
||||||
addState(new DriveState(robot, "BlueWarehouseAutonomous", "10_0"));
|
addState(new TurretOrbit(robot, robot.turretServoOrange, null, "BlueWarehouseAutonomous", "10_0"));
|
||||||
|
addState(new DriveState(robot, "BlueWarehouseAutonomous", "10_1"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package org.timecrafters.FreightFrenzy.Competition.Autonomous.Engines;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
|
||||||
|
import org.cyberarm.engine.V2.CyberarmEngine;
|
||||||
|
import org.timecrafters.FreightFrenzy.Competition.Autonomous.States.CollectorToggle;
|
||||||
|
import org.timecrafters.FreightFrenzy.Competition.Autonomous.States.DriveState;
|
||||||
|
import org.timecrafters.FreightFrenzy.Competition.Autonomous.States.TensorFlowState;
|
||||||
|
import org.timecrafters.FreightFrenzy.Competition.Autonomous.States.TurretArmExtension;
|
||||||
|
import org.timecrafters.FreightFrenzy.Competition.Autonomous.States.TurretOrbit;
|
||||||
|
import org.timecrafters.FreightFrenzy.Competition.Common.Robot;
|
||||||
|
|
||||||
|
@Autonomous(name = "RedDuckAutonomous", group = "red")
|
||||||
|
|
||||||
|
public class RedDuckEngine extends CyberarmEngine {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
Robot robot = new Robot(this);
|
||||||
|
robot.resetEncoders();
|
||||||
|
|
||||||
|
addState(new TurretOrbit(robot, robot.turretServoOrange, robot.orangeMag, "RedDuckAutonomous", "01_0"));
|
||||||
|
addState(new TensorFlowState(robot, robot.orangeArmRiser, robot.orangeArmBobbin, "RedDuckAutonomous", "01_1"));
|
||||||
|
// addState(new TurretArmExtension(robot, robot.orangeArmBobbin, "RedWarehouseAutonomous", "02_0"));
|
||||||
|
// addState(new TurretArmRiser(robot, robot.orangeArmRiser, "RedWarehouseAutonomous", "03_0_middle"));
|
||||||
|
// addState(new TurretArmExtension(robot, robot.orangeArmBobbin, "RedWarehouseAutonomous", "04_0"));
|
||||||
|
addState(new CollectorToggle(robot, robot.collectorOrange, "RedDuckAutonomous", "05_0"));
|
||||||
|
addState(new CollectorToggle(robot, robot.collectorOrange, "RedDuckAutonomous", "06_0"));
|
||||||
|
addState(new TurretArmExtension(robot, robot.orangeArmBobbin, "RedDuckAutonomous", "07_0"));
|
||||||
|
addState(new DriveState(robot,"RedDuckAutonomous", "08_0"));
|
||||||
|
addState(new DriveState(robot, "RedDuckAutonomous", "09_0"));
|
||||||
|
addState(new TurretOrbit(robot, robot.turretServoOrange, null, "RedDuckAutonomous", "10_0"));
|
||||||
|
addState(new DriveState(robot, "RedDuckAutonomous", "10_1"));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ public class RedWarehouseEngine extends CyberarmEngine {
|
|||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.robot = new Robot(this);
|
this.robot = new Robot(this);
|
||||||
|
robot.resetEncoders();
|
||||||
|
|
||||||
addState(new TurretOrbit(robot, robot.turretServoWhite, robot.whiteMag, "RedWarehouseAutonomous", "01_0"));
|
addState(new TurretOrbit(robot, robot.turretServoWhite, robot.whiteMag, "RedWarehouseAutonomous", "01_0"));
|
||||||
addState(new TensorFlowState(robot, robot.whiteArmRiser, robot.whiteArmBobbin, "RedWarehouseAutonomous", "01_1"));
|
addState(new TensorFlowState(robot, robot.whiteArmRiser, robot.whiteArmBobbin, "RedWarehouseAutonomous", "01_1"));
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class CollectorToggle extends CyberarmState {
|
|||||||
final static public int MODE_STOPPED = 0;
|
final static public int MODE_STOPPED = 0;
|
||||||
double time;
|
double time;
|
||||||
CRServo servo;
|
CRServo servo;
|
||||||
int power;
|
double power;
|
||||||
|
|
||||||
public CollectorToggle(Robot robot, CRServo servo, String groupName, String actionName) {
|
public CollectorToggle(Robot robot, CRServo servo, String groupName, String actionName) {
|
||||||
this.servo = servo;
|
this.servo = servo;
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ public class TensorFlowState extends CyberarmState {
|
|||||||
private double checkTime;
|
private double checkTime;
|
||||||
private int manualPath;
|
private int manualPath;
|
||||||
private int path = 0;
|
private int path = 0;
|
||||||
|
private double leftDuck;
|
||||||
|
private double middleDuck;
|
||||||
|
|
||||||
private String groupName;
|
private String groupName;
|
||||||
private DcMotor armRiser, armExtension;
|
private DcMotor armRiser, armExtension;
|
||||||
@@ -24,6 +26,8 @@ public class TensorFlowState extends CyberarmState {
|
|||||||
this.groupName = groupName;
|
this.groupName = groupName;
|
||||||
this.armRiser = armRiser;
|
this.armRiser = armRiser;
|
||||||
this.armExtension = armExtension;
|
this.armExtension = armExtension;
|
||||||
|
this.leftDuck = robot.configuration.variable(groupName, actionName, "leftDuck").value();
|
||||||
|
this.middleDuck = robot.configuration.variable(groupName, actionName, "middleDuck").value();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -35,7 +39,7 @@ public class TensorFlowState extends CyberarmState {
|
|||||||
@Override
|
@Override
|
||||||
public void exec() {
|
public void exec() {
|
||||||
recognitions = robot.tensorflowDetections();
|
recognitions = robot.tensorflowDetections();
|
||||||
//
|
|
||||||
if (runTime() < checkTime) {
|
if (runTime() < checkTime) {
|
||||||
if (manualPath != -1) {
|
if (manualPath != -1) {
|
||||||
|
|
||||||
@@ -43,12 +47,10 @@ public class TensorFlowState extends CyberarmState {
|
|||||||
if (recognitions.size() == 1) {
|
if (recognitions.size() == 1) {
|
||||||
Recognition recognition = recognitions.get(0);
|
Recognition recognition = recognitions.get(0);
|
||||||
|
|
||||||
if (recognition.getLabel().equals("duck")){
|
if (recognition.getLeft() < leftDuck) {
|
||||||
if (recognition.getLeft() < 320) {
|
path = 0;
|
||||||
path = 0;
|
} else {
|
||||||
} else {
|
path = 1;
|
||||||
path = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
path = 2;
|
path = 2;
|
||||||
@@ -70,7 +72,7 @@ public class TensorFlowState extends CyberarmState {
|
|||||||
addState(new TurretArmExtension(robot, armExtension, groupName, "04_0_top"));
|
addState(new TurretArmExtension(robot, armExtension, groupName, "04_0_top"));
|
||||||
}
|
}
|
||||||
|
|
||||||
setHasFinished(true);
|
setHasFinished(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,6 @@ public class TurretArmExtension extends CyberarmState {
|
|||||||
this.tolerance = robot.configuration.variable(groupName, actionName, "tolerance").value();
|
this.tolerance = robot.configuration.variable(groupName, actionName, "tolerance").value();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() {
|
|
||||||
motor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
|
||||||
motor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exec() {
|
public void exec() {
|
||||||
if (motor.getCurrentPosition() < targetPosition - tolerance){
|
if (motor.getCurrentPosition() < targetPosition - tolerance){
|
||||||
@@ -40,4 +34,9 @@ public class TurretArmExtension extends CyberarmState {
|
|||||||
motor.setPower(0);
|
motor.setPower(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void telemetry() {
|
||||||
|
engine.telemetry.addData("targetPosition", targetPosition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,6 @@ public class TurretArmRiser extends CyberarmState {
|
|||||||
this.tolerance = robot.configuration.variable(groupName, actionName, "tolerance").value();
|
this.tolerance = robot.configuration.variable(groupName, actionName, "tolerance").value();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() {
|
|
||||||
motor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
|
||||||
motor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exec() {
|
public void exec() {
|
||||||
if (motor.getCurrentPosition() < targetPosition - tolerance){
|
if (motor.getCurrentPosition() < targetPosition - tolerance){
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class TurretOrbit extends CyberarmState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exec() {
|
public void exec() {
|
||||||
if (magnetSwitch.isPressed() || runTime() < time ){
|
if ((magnetSwitch != null && magnetSwitch.isPressed()) || runTime() > time ){
|
||||||
servo.setPower(0);
|
servo.setPower(0);
|
||||||
setHasFinished(true);
|
setHasFinished(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,6 +274,18 @@ public class Robot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetEncoders(){
|
||||||
|
orangeArmBobbin.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
||||||
|
whiteArmBobbin.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
||||||
|
orangeArmRiser.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
||||||
|
whiteArmRiser.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
||||||
|
|
||||||
|
orangeArmBobbin.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
|
||||||
|
whiteArmBobbin.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
|
||||||
|
orangeArmRiser.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
|
||||||
|
whiteArmRiser.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
|
||||||
|
}
|
||||||
|
|
||||||
private void initTensorflow() {
|
private void initTensorflow() {
|
||||||
int tfodMonitorViewId = engine.hardwareMap.appContext.getResources().getIdentifier(
|
int tfodMonitorViewId = engine.hardwareMap.appContext.getResources().getIdentifier(
|
||||||
"tfodMonitorViewId", "id", engine.hardwareMap.appContext.getPackageName());
|
"tfodMonitorViewId", "id", engine.hardwareMap.appContext.getPackageName());
|
||||||
|
|||||||
Reference in New Issue
Block a user