mirror of
https://github.com/TimeCrafters/FreightFrenzy.git
synced 2025-12-13 05:02:34 +00:00
Compare commits
6 Commits
add_tacnet
...
e025034655
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e025034655 | ||
|
|
aa6ce00f3c | ||
|
|
6eb9c46e59 | ||
| 9b98cf5840 | |||
|
|
99bbfee101 | ||
|
|
12a306965a |
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
||||
30
.idea/jarRepositories.xml
generated
Normal file
30
.idea/jarRepositories.xml
generated
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="MavenRepo" />
|
||||
<option name="name" value="MavenRepo" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="BintrayJCenter" />
|
||||
<option name="name" value="BintrayJCenter" />
|
||||
<option name="url" value="https://jcenter.bintray.com/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="Google" />
|
||||
<option name="name" value="Google" />
|
||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
9
.idea/misc.xml
generated
Normal file
9
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -49,6 +49,8 @@ import android.preference.PreferenceManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
@@ -410,6 +412,12 @@ public class FtcRobotControllerActivity extends Activity
|
||||
checkPreferredChannel();
|
||||
|
||||
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() {
|
||||
|
||||
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
|
||||
public void setup() {
|
||||
this.robot = new Robot(this);
|
||||
robot.resetEncoders();
|
||||
|
||||
addState(new TurretOrbit(robot, robot.turretServoWhite, robot.whiteMag, "BlueWarehouseAutonomous", "01_0"));
|
||||
addState(new TensorFlowState(robot, robot.whiteArmRiser, robot.whiteArmBobbin, "BlueWarehouseAutonomous", "01_1"));
|
||||
// addState(new TurretArmExtension(robot, robot.whiteArmBobbin, "BlueWarehouseAutonomous", "02_0"));
|
||||
// addState(new TurretArmRiser(robot, robot.whiteArmRiser, "BlueWarehouseAutonomous", "03_0_middle"));
|
||||
// addState(new TurretArmExtension(robot, robot.whiteArmBobbin, "BlueWarehouseAutonomous", "04_0_middle"));
|
||||
addState(new CollectorToggle(robot, robot.collectorWhite, "BlueWarehouseAutonomous", "05_0"));
|
||||
addState(new CollectorToggle(robot, robot.collectorWhite, "BlueWarehouseAutonomous", "06_0"));
|
||||
addState(new TurretArmExtension(robot, robot.whiteArmBobbin, "BlueWarehouseAutonomous", "07_0"));
|
||||
addState(new TurretOrbit(robot, robot.turretServoOrange, robot.orangeMag, "BlueWarehouseAutonomous", "01_0"));
|
||||
addState(new TensorFlowState(robot, robot.orangeArmRiser, robot.orangeArmBobbin, "BlueWarehouseAutonomous", "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, "BlueWarehouseAutonomous", "05_0"));
|
||||
addState(new CollectorToggle(robot, robot.collectorOrange, "BlueWarehouseAutonomous", "06_0"));
|
||||
addState(new TurretArmExtension(robot, robot.orangeArmBobbin, "BlueWarehouseAutonomous", "07_0"));
|
||||
addState(new DriveState(robot,"BlueWarehouseAutonomous", "08_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
|
||||
public void setup() {
|
||||
this.robot = new Robot(this);
|
||||
robot.resetEncoders();
|
||||
|
||||
addState(new TurretOrbit(robot, robot.turretServoWhite, robot.whiteMag, "RedWarehouseAutonomous", "01_0"));
|
||||
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;
|
||||
double time;
|
||||
CRServo servo;
|
||||
int power;
|
||||
double power;
|
||||
|
||||
public CollectorToggle(Robot robot, CRServo servo, String groupName, String actionName) {
|
||||
this.servo = servo;
|
||||
|
||||
@@ -15,6 +15,8 @@ public class TensorFlowState extends CyberarmState {
|
||||
private double checkTime;
|
||||
private int manualPath;
|
||||
private int path = 0;
|
||||
private double leftDuck;
|
||||
private double middleDuck;
|
||||
|
||||
private String groupName;
|
||||
private DcMotor armRiser, armExtension;
|
||||
@@ -24,6 +26,8 @@ public class TensorFlowState extends CyberarmState {
|
||||
this.groupName = groupName;
|
||||
this.armRiser = armRiser;
|
||||
this.armExtension = armExtension;
|
||||
this.leftDuck = robot.configuration.variable(groupName, actionName, "leftDuck").value();
|
||||
this.middleDuck = robot.configuration.variable(groupName, actionName, "middleDuck").value();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,7 +39,7 @@ public class TensorFlowState extends CyberarmState {
|
||||
@Override
|
||||
public void exec() {
|
||||
recognitions = robot.tensorflowDetections();
|
||||
//
|
||||
|
||||
if (runTime() < checkTime) {
|
||||
if (manualPath != -1) {
|
||||
|
||||
@@ -43,12 +47,10 @@ public class TensorFlowState extends CyberarmState {
|
||||
if (recognitions.size() == 1) {
|
||||
Recognition recognition = recognitions.get(0);
|
||||
|
||||
if (recognition.getLabel().equals("duck")){
|
||||
if (recognition.getLeft() < 320) {
|
||||
path = 0;
|
||||
} else {
|
||||
path = 1;
|
||||
}
|
||||
if (recognition.getLeft() < leftDuck) {
|
||||
path = 0;
|
||||
} else {
|
||||
path = 1;
|
||||
}
|
||||
} else {
|
||||
path = 2;
|
||||
@@ -70,7 +72,7 @@ public class TensorFlowState extends CyberarmState {
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
motor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
||||
motor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exec() {
|
||||
if (motor.getCurrentPosition() < targetPosition - tolerance){
|
||||
@@ -40,4 +34,9 @@ public class TurretArmExtension extends CyberarmState {
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
motor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
||||
motor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exec() {
|
||||
if (motor.getCurrentPosition() < targetPosition - tolerance){
|
||||
|
||||
@@ -24,7 +24,7 @@ public class TurretOrbit extends CyberarmState {
|
||||
|
||||
@Override
|
||||
public void exec() {
|
||||
if (magnetSwitch.isPressed() || runTime() < time ){
|
||||
if ((magnetSwitch != null && magnetSwitch.isPressed()) || runTime() > time ){
|
||||
servo.setPower(0);
|
||||
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() {
|
||||
int tfodMonitorViewId = engine.hardwareMap.appContext.getResources().getIdentifier(
|
||||
"tfodMonitorViewId", "id", engine.hardwareMap.appContext.getPackageName());
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TeleOpState extends CyberarmState {
|
||||
robot.driveGoalRight.setPower(-engine.gamepad1.right_stick_y * maxDriveSpeed);
|
||||
|
||||
// dispenser powered
|
||||
if (engine.gamepad1.b){
|
||||
if (engine.gamepad1.a){
|
||||
robot.orangeDispenser.setPosition(0);
|
||||
}
|
||||
// if not pressed dispenser off
|
||||
@@ -86,12 +86,14 @@ public class TeleOpState extends CyberarmState {
|
||||
robot.orangeArmRiser.setPower(0);
|
||||
}
|
||||
|
||||
// button x pressed carousel wheel move.
|
||||
// button x pressed carousel wheel move, for blue side, if b pressed wheel spins for red side;
|
||||
|
||||
if (engine.gamepad1.x){
|
||||
if (engine.gamepad2.x){
|
||||
robot.carouselWheel.setPower(1);
|
||||
}
|
||||
|
||||
else if (engine.gamepad2.b){
|
||||
robot.carouselWheel.setPower(-1);
|
||||
}
|
||||
else {
|
||||
robot.carouselWheel.setPower(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user