Skip to content

Commit 357a84e

Browse files
authored
Merge pull request #8 from 6-BennyLi-9/OnBotDebug
Weekly Update 周更
2 parents aa35699 + 8222712 commit 357a84e

67 files changed

Lines changed: 1015 additions & 372 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

TeamCode/build.gradle

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,25 @@ apply from: '../build.common.gradle'
1616
apply from: '../build.dependencies.gradle'
1717

1818
android {
19-
namespace = 'org.firstinspires.ftc.teamcode'
20-
androidResources {
21-
noCompress 'tflite'
22-
}
23-
24-
packagingOptions {
25-
jniLibs {
26-
pickFirsts += ['**/*.so']
27-
}
28-
jniLibs.useLegacyPackaging true
29-
}
19+
namespace = 'org.firstinspires.ftc.teamcode'
20+
21+
packagingOptions {
22+
jniLibs.useLegacyPackaging true
23+
}
3024
}
3125

3226
repositories {
33-
maven {
34-
url = 'https://maven.brott.dev/'
35-
}
27+
maven {
28+
url = 'https://maven.brott.dev/'
29+
}
3630
}
3731

3832
dependencies {
39-
implementation project(':FtcRobotController')
40-
annotationProcessor files('lib/OpModeAnnotationProcessor.jar')
33+
implementation project(':FtcRobotController')
34+
35+
implementation "com.acmerobotics.roadrunner:ftc:0.1.14"
36+
implementation "com.acmerobotics.roadrunner:core:1.0.0"
37+
implementation "com.acmerobotics.roadrunner:actions:1.0.0"
38+
implementation "com.acmerobotics.dashboard:dashboard:0.4.16"
39+
implementation 'org.openftc:easyopencv:1.7.3'
4140
}

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/VoidKeyMapController.java renamed to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/DefaultKeyMapController.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
import org.firstinspires.ftc.teamcode.keymap.KeyMap;
66

7-
public class VoidKeyMapController extends KeyMapController{
7+
public class DefaultKeyMapController extends KeyMapController{
88
@Override
9-
public void KeyMapOverride(@NonNull KeyMap keyMap) {}
9+
public void KeyMapOverride(@NonNull KeyMap keyMap) {
10+
/**/
11+
}
1012
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.firstinspires.ftc.teamcode;
2+
3+
public class DefaultParamsController extends ParamsController{
4+
@Override
5+
public void PramsOverride() {
6+
/**/
7+
}
8+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package org.firstinspires.ftc.teamcode;
2+
3+
import androidx.annotation.NonNull;
4+
5+
import com.qualcomm.robotcore.hardware.Gamepad;
6+
7+
import org.firstinspires.ftc.teamcode.drives.controls.definition.DriverProgram;
8+
import org.firstinspires.ftc.teamcode.hardwares.integration.IntegrationGamepad;
9+
import org.firstinspires.ftc.teamcode.hardwares.integration.IntegrationHardwareMap;
10+
import org.firstinspires.ftc.teamcode.utils.ActionBox;
11+
import org.firstinspires.ftc.teamcode.utils.annotations.UserRequirementFunctions;
12+
import org.firstinspires.ftc.teamcode.utils.clients.Client;
13+
import org.firstinspires.ftc.teamcode.utils.enums.RunningMode;
14+
15+
public final class Global {
16+
public static Robot robot;
17+
public static Client client;
18+
public static RunningMode runMode;
19+
public static ActionBox actionBox;
20+
public static DriverProgram driverProgram;
21+
public static IntegrationGamepad integrationGamepad;
22+
public static Gamepad currentGamepad1, currentGamepad2;
23+
public static IntegrationHardwareMap integrationHardwareMap;
24+
25+
@UserRequirementFunctions
26+
public static void clear() {
27+
robot = null;
28+
client = null;
29+
runMode = null;
30+
actionBox = null;
31+
driverProgram = null;
32+
integrationGamepad = null;
33+
currentGamepad1 = null;
34+
currentGamepad2 = null;
35+
}
36+
37+
public static void setRobot(@NonNull Robot robot) {
38+
Global.robot = robot;
39+
Global.driverProgram = robot.drive;
40+
Global.client = robot.client;
41+
Global.runMode = robot.runningState;
42+
Global.actionBox = robot.actionBox;
43+
integrationHardwareMap=robot.lazyIntegratedDevices;
44+
if(robot.gamepad!= null) {
45+
Global.integrationGamepad = robot.gamepad;
46+
Global.currentGamepad1 = robot.gamepad.gamepad1.gamepad;
47+
Global.currentGamepad2 = robot.gamepad.gamepad2.gamepad;
48+
}
49+
}
50+
}

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Params.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public static class Configs{
3939
public static boolean useOutTimeProtection = true;
4040
/**自动在初始化<code>IntegrationHardwareMap</code>时,登记所有硬件<p>适合单一队伍的程序*/
4141
public static boolean autoRegisterAllHardwaresWhenInit = true;
42+
43+
44+
public static final String TuningAndTuneOpModesGroup = "0_Tunings";
45+
public static final String SampleOpModesGroup = "0_Samples";
4246
}
4347
@Config
4448
public static class HardwareNamespace {

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Robot.java

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,32 @@ public class Robot {
5454
public RunningMode runningState;
5555
public IntegrationGamepad gamepad=null;
5656
public final ActionBox actionBox;
57-
private DriverProgram drive=null;
57+
public DriverProgram drive=null;
5858

5959
public Timer timer;
6060

61-
public ParamsController paramsController =new VoidParamsController();
62-
public KeyMapController keyMapController =new VoidKeyMapController();
61+
public ParamsController paramsController =new DefaultParamsController();
62+
public KeyMapController keyMapController =new DefaultKeyMapController();
63+
64+
private void configsReset(){
65+
Params.Configs.driverUsingAxisPowerInsteadOfCurrentPower=true;
66+
Params.Configs.runUpdateWhenAnyNewOptionsAdded=false;
67+
Params.Configs.waitForServoUntilThePositionIsInPlace=false;
68+
Params.Configs.autoPrepareForNextOptionWhenUpdate=false;
69+
Params.Configs.alwaysRunPIDInAutonomous=false;
70+
Params.Configs.usePIDInAutonomous=true;
71+
Params.Configs.useOutTimeProtection=true;
72+
Params.Configs.autoRegisterAllHardwaresWhenInit=true;
73+
}
6374

6475
public Robot(@NonNull HardwareMap hardwareMap, @NonNull RunningMode state, @NonNull Telemetry telemetry){
6576
this(hardwareMap,state,new Client(telemetry));
6677
}
78+
6779
public Robot(@NonNull HardwareMap hardwareMap, @NonNull RunningMode state, @NonNull Client client){
80+
pidProcessor=new PidProcessor();
81+
configsReset();
82+
6883
lazyIntegratedDevices=new IntegrationHardwareMap(hardwareMap,pidProcessor);
6984

7085
motors=new Motors(lazyIntegratedDevices);
@@ -82,6 +97,8 @@ public Robot(@NonNull HardwareMap hardwareMap, @NonNull RunningMode state, @NonN
8297
//TODO:如果需要,在这里修改 Params.Config 中的值
8398
switch (state) {
8499
case Autonomous:
100+
Params.Configs.driverUsingAxisPowerInsteadOfCurrentPower=true;
101+
85102
InitInAutonomous();
86103
break;
87104
case ManualDrive:
@@ -100,6 +117,8 @@ public Robot(@NonNull HardwareMap hardwareMap, @NonNull RunningMode state, @NonN
100117
actionBox = new ActionBox();
101118
timer=new Timer();
102119
client.addData("RobotState","UnKnow");
120+
121+
Global.setRobot(this);
103122
}
104123

105124
@UserRequirementFunctions
@@ -118,7 +137,7 @@ public void setKeyMapController(KeyMapController controller){
118137
* @return 返回定义好的SimpleMecanumDrive
119138
*/
120139
public DriverProgram InitMecanumDrive(Pose2d RobotPosition){
121-
drive=new SimpleMecanumDrive(this,RobotPosition);
140+
drive=new SimpleMecanumDrive(RobotPosition);
122141
if(runningState != RunningMode.Autonomous) {
123142
Log.w("Robot.java","Initialized Driving Program in Manual Driving RobotState.");
124143
}
@@ -138,10 +157,14 @@ private void InitInManualDrive(){
138157

139158
public void registerGamepad(Gamepad gamepad1,Gamepad gamepad2){
140159
gamepad=new IntegrationGamepad(gamepad1,gamepad2);
160+
161+
Global.currentGamepad1=gamepad1;
162+
Global.currentGamepad2=gamepad2;
163+
Global.integrationGamepad=gamepad;
141164
}
142165

143166
public void update() {
144-
if(timer.stopAndGetDeltaTime()>=90000){
167+
if(timer.stopAndGetDeltaTime()>=90000&&runningState==RunningMode.ManualDrive){
145168
robotState = RobotState.FinalState;
146169
}
147170

@@ -210,9 +233,6 @@ public Pose2d pose(){
210233
* @param BufPower 提供的电机力度因数
211234
*/
212235
public void SetGlobalBufPower(double BufPower){
213-
if(drive!=null) {
214-
drive.runOrderPackage(DrivingOrderBuilder().SetPower(BufPower).END());//考虑是否删去此代码片段
215-
}
216236
motors.setBufPower(BufPower);
217237
}
218238

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/VoidParamsController.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/codes/samples/AutonomousSample.java renamed to TeamCode/src/main/java/org/firstinspires/ftc/teamcode/codes/samples/AutonomousSample2024.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@
55
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
66
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
77

8+
import org.firstinspires.ftc.teamcode.Params;
89
import org.firstinspires.ftc.teamcode.codes.templates.AutonomousProgramTemplate;
910
import org.firstinspires.ftc.teamcode.drives.controls.commands.DriveCommandPackage;
11+
import org.firstinspires.ftc.teamcode.hardwares.Webcam;
1012
import org.firstinspires.ftc.teamcode.utils.enums.AutonomousLocation;
1113

12-
@Autonomous(name = "AutonomousSample",group = "SAMPLE")
14+
/**
15+
* A sample of 2023-2024 season basic Autonomous.
16+
* <p>
17+
* 基於 FTC 2023-2034 賽季的代碼樣式
18+
*/
19+
@Autonomous(name = "AutonomousSample",group = Params.Configs.SampleOpModesGroup)
1320
@Disabled
14-
@Deprecated
15-
public class AutonomousSample extends AutonomousProgramTemplate {
21+
//@Deprecated
22+
public class AutonomousSample2024 extends AutonomousProgramTemplate {
1623
@Override
1724
public void runOpMode() {
25+
Webcam.useWebcam=true;
1826
Init(new Pose2d(0,0,0));
1927
robot.addData("Position","WAITING FOR REQUEST");
2028
AutonomousLocation location = AutonomousLocation.failed;

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/codes/samples/CameraDetection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
55

66
import org.firstinspires.ftc.robotcore.external.hardware.camera.WebcamName;
7+
import org.firstinspires.ftc.teamcode.Params;
78
import org.firstinspires.ftc.teamcode.codes.templates.AutonomousProgramTemplate;
89
import org.firstinspires.ftc.teamcode.hardwares.basic.Camera;
910
import org.openftc.easyopencv.OpenCvCamera;
1011
import org.openftc.easyopencv.OpenCvCameraFactory;
1112
import org.openftc.easyopencv.OpenCvCameraRotation;
1213

1314
@Disabled
14-
@Autonomous(name = "CameraDetection",group = "sample")
15+
@Autonomous(name = "CameraDetection",group = Params.Configs.SampleOpModesGroup)
1516
public class CameraDetection extends AutonomousProgramTemplate {
1617
OpenCvCamera webcam;
1718
Camera detector=new Camera(telemetry);

TeamCode/src/main/java/org/firstinspires/ftc/teamcode/codes/samples/ClientUsage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
77
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
88

9+
import org.firstinspires.ftc.teamcode.Params;
910
import org.firstinspires.ftc.teamcode.utils.clients.Client;
1011

11-
@TeleOp(name = "ClientUsage",group = "sample")
12+
@TeleOp(name = "ClientUsage",group = Params.Configs.SampleOpModesGroup)
1213
@Disabled
1314
public class ClientUsage extends OpMode {
1415
Client client;

0 commit comments

Comments
 (0)