Skip to content

Commit

Permalink
Merge pull request #4 from frc1711/development
Browse files Browse the repository at this point in the history
v2023.1.3-beta release is ready
  • Loading branch information
gabrielseaver9678 authored Mar 13, 2023
2 parents d44af21 + 74712fb commit 87f06b5
Show file tree
Hide file tree
Showing 66 changed files with 2,540 additions and 761 deletions.
1 change: 1 addition & 0 deletions build-lib.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ cd lib
@REM Build the distribution zip (used for the driverstation client)
call gradlew.bat distZip
@REM Build the maven repo (used for the test-bot and for any vendor dependencies)
rmdir /Q /S app\build\maven-repo\org\frc\raptors1711\raptors-claw
call gradlew.bat publish
cd ..

Expand Down
2 changes: 2 additions & 0 deletions lib/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ dependencies {
// Used by other dependencies
implementation "edu.wpi.first.wpimath:wpimath-java:2023.1.1"

implementation "edu.wpi.first.hal:hal-java:2023.1.1"
implementation "edu.wpi.first.hal:hal-jni:2023.1.1"

// Add org.fusesource.jansi
// Used for console ANSI processing for driverstation-side RCT
Expand Down
Binary file modified lib/app/build/distributions/driverstation-rct-client.zip
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f7be92f5ac76d7f011f43a4fbab9352a
2a98f4603c63168315cd902fdea8ed8c
Original file line number Diff line number Diff line change
@@ -1 +1 @@
94c6057efb26087e59d62bc642d50770cae0f2f3
45408af577b0daeb320a4061a63a1c8358d865ef
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cc0de2620d8b5d26842e4091d44d9848c9782fc261dbdc893eaecb36e666ff1c
cf51b16c07af45d32ca8cf75785f093af125c18a334ce74c4154d450207f046c
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fe7f1e6c62a01bfd8d2d4ef4c7b814db7e818bb0ea0552dc80b6278d41765fc5955627bd1843083a43bf1b6db817afbd51a077ef496f82fd37bfb50ecb5f6e4e
7a49dc68e04b31347589e9d450515505c6ad259c068d85b00536ac8369124278e500ea479201c7d3413d9121f729aeec87684e69225b1b2829544b443ef6ba49
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c64437c4e3855dfdbbc48ce9634a60bb
69c7395c4e981d1c9876168dfbad12e3
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bb5fa500ca0622333860118f2ad73d77621d4ad6
fa571001cca7fc6b1b6a3a5cb904b877c00dccf3
Original file line number Diff line number Diff line change
@@ -1 +1 @@
41050bf4db962f80a1e2456ad2def64d4851aac0173987f0cfec1b3a65c7aa3d
5639e1fcd244f5a278d31d39521d48fa862b7fdd5c52c20a5fff82e9f694ab67
Original file line number Diff line number Diff line change
@@ -1 +1 @@
25bee8a2b2221c1544b9860de60442c8cf77efed71e73f6f168c05ec812308b9c78262debc086cdf77426e26544b10be4af823118e25fc820b0f5962f65c3db7
cc5581befe8bad65b269aab28a848429ff746c62df122529eb02ef629d61803213c7c3139e9b2a091db3b3c5aec5aa5b35eaa0a98c3d7ee4c36cc3458cae1d21
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
{
"name": "raptors-claw-0.jar",
"url": "raptors-claw-0.jar",
"size": 113205,
"sha512": "25bee8a2b2221c1544b9860de60442c8cf77efed71e73f6f168c05ec812308b9c78262debc086cdf77426e26544b10be4af823118e25fc820b0f5962f65c3db7",
"sha256": "41050bf4db962f80a1e2456ad2def64d4851aac0173987f0cfec1b3a65c7aa3d",
"sha1": "bb5fa500ca0622333860118f2ad73d77621d4ad6",
"md5": "c64437c4e3855dfdbbc48ce9634a60bb"
"size": 143380,
"sha512": "cc5581befe8bad65b269aab28a848429ff746c62df122529eb02ef629d61803213c7c3139e9b2a091db3b3c5aec5aa5b35eaa0a98c3d7ee4c36cc3458cae1d21",
"sha256": "5639e1fcd244f5a278d31d39521d48fa862b7fdd5c52c20a5fff82e9f694ab67",
"sha1": "fa571001cca7fc6b1b6a3a5cb904b877c00dccf3",
"md5": "69c7395c4e981d1c9876168dfbad12e3"
}
]
},
Expand Down Expand Up @@ -87,6 +87,20 @@
"requires": "2023.1.1"
}
},
{
"group": "edu.wpi.first.hal",
"module": "hal-java",
"version": {
"requires": "2023.1.1"
}
},
{
"group": "edu.wpi.first.hal",
"module": "hal-jni",
"version": {
"requires": "2023.1.1"
}
},
{
"group": "org.fusesource.jansi",
"module": "jansi",
Expand Down Expand Up @@ -120,11 +134,11 @@
{
"name": "raptors-claw-0.jar",
"url": "raptors-claw-0.jar",
"size": 113205,
"sha512": "25bee8a2b2221c1544b9860de60442c8cf77efed71e73f6f168c05ec812308b9c78262debc086cdf77426e26544b10be4af823118e25fc820b0f5962f65c3db7",
"sha256": "41050bf4db962f80a1e2456ad2def64d4851aac0173987f0cfec1b3a65c7aa3d",
"sha1": "bb5fa500ca0622333860118f2ad73d77621d4ad6",
"md5": "c64437c4e3855dfdbbc48ce9634a60bb"
"size": 143380,
"sha512": "cc5581befe8bad65b269aab28a848429ff746c62df122529eb02ef629d61803213c7c3139e9b2a091db3b3c5aec5aa5b35eaa0a98c3d7ee4c36cc3458cae1d21",
"sha256": "5639e1fcd244f5a278d31d39521d48fa862b7fdd5c52c20a5fff82e9f694ab67",
"sha1": "fa571001cca7fc6b1b6a3a5cb904b877c00dccf3",
"md5": "69c7395c4e981d1c9876168dfbad12e3"
}
]
},
Expand All @@ -140,11 +154,11 @@
{
"name": "raptors-claw-0-sources.jar",
"url": "raptors-claw-0-sources.jar",
"size": 71904,
"sha512": "fe7f1e6c62a01bfd8d2d4ef4c7b814db7e818bb0ea0552dc80b6278d41765fc5955627bd1843083a43bf1b6db817afbd51a077ef496f82fd37bfb50ecb5f6e4e",
"sha256": "cc0de2620d8b5d26842e4091d44d9848c9782fc261dbdc893eaecb36e666ff1c",
"sha1": "94c6057efb26087e59d62bc642d50770cae0f2f3",
"md5": "f7be92f5ac76d7f011f43a4fbab9352a"
"size": 87408,
"sha512": "7a49dc68e04b31347589e9d450515505c6ad259c068d85b00536ac8369124278e500ea479201c7d3413d9121f729aeec87684e69225b1b2829544b443ef6ba49",
"sha256": "cf51b16c07af45d32ca8cf75785f093af125c18a334ce74c4154d450207f046c",
"sha1": "45408af577b0daeb320a4061a63a1c8358d865ef",
"md5": "2a98f4603c63168315cd902fdea8ed8c"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b0fc064dd4e57caccd34e492db097cd4
2b7c30da23792f8bb8e99cac0d2fcce8
Original file line number Diff line number Diff line change
@@ -1 +1 @@
da4aa36ea816d3804b06ebf152431494f655656a
dbe5d06ba94a5718b942b99ad8b1775ca3ab2bab
Original file line number Diff line number Diff line change
@@ -1 +1 @@
09b794a92a2a4d97c16d99ae7071b4007290f898bed7f4781b0253fb5b4011b9
4e145cf6795a3cbb0ca471c72fe20ef7bba3cf7ac7551095eded4b73f1cfa883
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0476cd79862afcdb30762d775b5d37753cd58fe3c35439e2198fa915b396284ff45ebe73121f7a0fc413d15fe6e7ef15e8967bb1ba2c67978c9bd66ef125344e
99dd9f4b385f74ed29298a341963ca0ebf14e447454713f0cf7db679b18ed8e38665129b3a8181bcc03970429a5287a8a83fe3069303179894ee0f5098f5315a
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@
<version>2023.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>edu.wpi.first.hal</groupId>
<artifactId>hal-java</artifactId>
<version>2023.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>edu.wpi.first.hal</groupId>
<artifactId>hal-jni</artifactId>
<version>2023.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a875c60bcc81513eb2da3f571a22fc25
e02ff13651d2c72425dd2e1317c719fb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e53e55f8df7b668d00bc63f023be1fa87e3341c3
e0aa31056f00965a658913cd0727081b875e0be8
Original file line number Diff line number Diff line change
@@ -1 +1 @@
814fad6c4d5e1204b77f01926947061d9974cec316dd58847c537463719e7bb9
ba87785d734ee69db697ddccabc4b796704d2d83808dfa7c66df5546d371c8e2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fb1c6d465f43f2a19a96e10689739116a2d9db345fc148eb21b3e98a9ad7da829911208386cd9c31ff3e4adbc1eb54bcf3eaae4fdf6bee7f0e2376ae5fcf8c3a
b9fb86f462200fac15cebace6413dcf3887c768c4a3cd5d12065ea41ce4a59a794a026bd00b201d2e9ab747c1f1cff800cbdf9afc03b265fe7edd032d03fc4b9
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<versions>
<version>0</version>
</versions>
<lastUpdated>20230223211415</lastUpdated>
<lastUpdated>20230313202232</lastUpdated>
</versioning>
</metadata>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ddd5917af0b7d7cb8178add75c5eac89
db1d12f0bc9179176520bd51c4e5d25e
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0bfb9526335c17b0cdc65c3192f8f22c8dd0077c
1254df09615b3cd2a0b31493ecafc7cf4eb8c613
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d2a64a5cfac32dca1136e654e98f6d1cf7d8b80d5e7f1c4acd1f21a1802c7744
a0550bca32e3a3204a52d8e2d91839ff3254ba7b2f5f801c23deed2cd8f68831
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7dd20974a1222fbfd1ee6291cd9eb11a0bbe17e0406cd85eb756ddd9c6a4237a99f4d81e9616bfa1c5d7d01d6318c4a3908dc0c58aa84661968781881a09e3c1
55e9af188bf935923a37bdf033f332be519dcf2e18b53ee1ffc189c2fef1100966f46df9b7c782119d832161a324f5c7a75903f5c3a9adb34d414e4fdbe3a91b
98 changes: 63 additions & 35 deletions lib/app/src/main/java/claw/CLAWRobot.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,55 @@
import claw.logs.LogHandler;
import claw.rct.commands.CommandLineInterpreter;
import claw.rct.remote.RCTServer;
import edu.wpi.first.wpilibj.Preferences;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;

public class CLAWRobot {

// Runtime execution determined by preferences so that the user can control
// this through any NetorkTables client (so that if you turn the server off,
// you can still control this execution)
private static final String RUN_RCT_SERVER = "CLAW.RUN_RCT_SERVER", RCT_SERVER_PORT = "CLAW.RCT_SERVER_PORT";
private static final int DEFAULT_SERVER_PORT = 5800;

private static final CommandLineInterpreter EXTENSIBLE_COMMAND_INTERPRETER = new CommandLineInterpreter();

private static boolean hasStartedCompetition = false;

public static void startCompetition (TimedRobot robot, Runnable robotStartCompetition) {
// Do not call startCompetition more than once
if (hasStartedCompetition)
throw new RuntimeException("Cannot call startCompetition more than once");
hasStartedCompetition = true;

initializeRuntime();
robot.addPeriodic(CLAWRobot::robotPeriodic, TimedRobot.kDefaultPeriod);

try {
robotStartCompetition.run();
} catch (Throwable exception) {
handleFatalUncaughtException(exception);
onRobotCodeFinish();
throw exception;
// Start the RCT server if indicated by preferences to do so
Preferences.initBoolean(RUN_RCT_SERVER, true);
Preferences.initInt(RCT_SERVER_PORT, DEFAULT_SERVER_PORT);
if (Preferences.getBoolean(RUN_RCT_SERVER, true)) {
startThread(CLAWRobot::initializeRCTServer);
}

// Run until robot code finishes
runRobotCode(robot, robotStartCompetition);

}
public static CommandLineInterpreter getExtensibleCommandInterpreter () {
return EXTENSIBLE_COMMAND_INTERPRETER;

private static void startThread (Runnable thread) {
new Thread(thread).start();
}

private static final CLAWLogger
COMMANDS_LOG = CLAWLogger.getLogger("claw.commands"),
RUNTIME_LOG = CLAWLogger.getLogger("claw.runtime");

private static RCTServer server;
private static boolean initialized = false;

private static void initializeRuntime () {

if (initialized) return;
initialized = true;

/**
* Start the robot code and the CLAW robot code runtime necessary for robot code functioning
*/
private static void runRobotCode (TimedRobot robot, Runnable robotStartCompetition) {
// Put a message into the console indicating that the CLAWRobot runtime has started
System.out.println("\n -- CLAW is running -- \n");

Expand All @@ -59,23 +69,34 @@ private static void initializeRuntime () {
CommandScheduler.getInstance().onCommandFinish(CLAWRobot::onCommandFinish);
CommandScheduler.getInstance().onCommandInterrupt(CLAWRobot::onCommandInterrupt);

// Start RCT server thread
new Thread(() -> {
try {
server = new RCTServer(5800, EXTENSIBLE_COMMAND_INTERPRETER);
server.start();
} catch (IOException e) {
System.err.println("Failed to start RCT server.");
e.printStackTrace();
}
}).start();

try {
// Add the periodic method for the CLAWRobot and call start competition within a try-catch
// loop to catch any exceptions
robot.addPeriodic(CLAWRobot::robotPeriodic, TimedRobot.kDefaultPeriod);
robotStartCompetition.run();
} catch (Throwable exception) {
// Catch any uncaught robot exceptions
handleFatalUncaughtException(exception);
throw exception;
}
}

/**
* Initialize the RCT server allowing for advanced debugging and control from the driver station
*/
private static void initializeRCTServer () {
// Start RCT server
try {
server = new RCTServer(Preferences.getInt(RCT_SERVER_PORT, DEFAULT_SERVER_PORT), EXTENSIBLE_COMMAND_INTERPRETER);
server.start();
} catch (IOException e) {
System.err.println("Failed to start RCT server.");
e.printStackTrace();
}
}

private static void onRobotCodeFinish () {
if (server != null)
LogHandler.getInstance().sendData(server);
public static CommandLineInterpreter getExtensibleCommandInterpreter () {
return EXTENSIBLE_COMMAND_INTERPRETER;
}

private static void robotPeriodic () {
Expand All @@ -101,7 +122,12 @@ private static void onCommandInterrupt (Command command) {

private static void handleUncaughtException (Thread thread, Throwable exception) {
// Print to the driver station
System.err.println("Caught an uncaught exception: " + exception.getMessage());
System.err.println(
"Caught an exception in the robot code: " + exception.getMessage()+". Use the " +
"'errlog' command in the Robot Control Terminal to examine it."
);

RobotErrorLog.logThreadError(exception);

// Put to the logger
RUNTIME_LOG.err("Uncaught exception in a thread '"+thread.getName()+"':\n"+getStackTrace(exception));
Expand All @@ -110,6 +136,8 @@ private static void handleUncaughtException (Thread thread, Throwable exception)
private static void handleFatalUncaughtException (Throwable exception) {
// Put to the logger
RUNTIME_LOG.err("Fatal uncaught exception in robot code:\n"+getStackTrace(exception));

RobotErrorLog.logFatalError(exception);
}

private static String getStackTrace (Throwable e) {
Expand Down
Loading

0 comments on commit 87f06b5

Please sign in to comment.