From ae655a3a71aa38add7d81ca5e8342bcd28ed01ee Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Fri, 24 May 2024 10:41:23 -0700 Subject: [PATCH] Rename myRobot to developerRobot and move docs to subproject (#6283) --- CMakeLists.txt | 4 +- DevelopmentBuilds.md | 13 +---- developerRobot/CMakeLists.txt | 8 +++ developerRobot/README.md | 43 +++++++++++++++ {myRobot => developerRobot}/build.gradle | 52 +++++++++---------- .../src/main/java/frc/robot/Main.java | 2 +- .../src/main/java/frc/robot/Robot.java | 2 +- .../src/main/native/cpp/Robot.cpp | 4 +- myRobot/CMakeLists.txt | 8 --- settings.gradle | 2 +- 10 files changed, 85 insertions(+), 53 deletions(-) create mode 100644 developerRobot/CMakeLists.txt create mode 100644 developerRobot/README.md rename {myRobot => developerRobot}/build.gradle (87%) rename {myRobot => developerRobot}/src/main/java/frc/robot/Main.java (92%) rename myRobot/src/main/java/frc/robot/MyRobot.java => developerRobot/src/main/java/frc/robot/Robot.java (96%) rename myRobot/src/main/native/cpp/MyRobot.cpp => developerRobot/src/main/native/cpp/Robot.cpp (93%) delete mode 100644 myRobot/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 79df35974b..fd08d1254c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ option(WITH_CSCORE "Build cscore (needs OpenCV)" ON) option(WITH_NTCORE "Build ntcore" ON) option(WITH_WPIMATH "Build wpimath" ON) option(WITH_WPIUNITS "Build wpiunits" ON) -option(WITH_WPILIB "Build hal, wpilibc/j, and myRobot (needs OpenCV)" ON) +option(WITH_WPILIB "Build hal, wpilibc/j, and developerRobot (needs OpenCV)" ON) option(WITH_EXAMPLES "Build examples" OFF) option(WITH_TESTS "Build unit tests (requires internet connection)" ON) option(WITH_GUI "Build GUI items" ON) @@ -405,7 +405,7 @@ if(WITH_WPILIB) if(WITH_EXAMPLES) add_subdirectory(wpilibcExamples) endif() - add_subdirectory(myRobot) + add_subdirectory(developerRobot) endif() if(WITH_SIMULATION_MODULES AND NOT WITH_EXTERNAL_HAL) diff --git a/DevelopmentBuilds.md b/DevelopmentBuilds.md index 86eb538306..6b244d34f9 100644 --- a/DevelopmentBuilds.md +++ b/DevelopmentBuilds.md @@ -89,15 +89,4 @@ wpi.versions.wpimathVersion = 'YEAR.424242.+' # roboRIO Development -This repo contains a myRobot project built in way to do full project development without needing to do a full publish into GradleRIO. These also only require building the minimum amount of binaries for the roboRIO, so the builds are much faster as well. - -The setup only works if the roboRIO is USB connected. If an alternate IP address is preferred, the `address` block in myRobot\build.gradle can be changed to point to another address. - -The following 3 tasks can be used for deployment: -* `:myRobot:deployShared` deploys the C++ project using shared dependencies. Prefer this one for most C++ development. -* `:myRobot:deployStatic` deploys the C++ project with all dependencies statically linked. -* `:myRobot:deployJava` deploys the Java project and all required dependencies. Also installs the JRE if not currently installed. - -Deploying any of these to the roboRIO will disable the current startup project until it is redeployed. - -From here, ssh into the roboRIO using the `lvuser` account and run `frcRunRobot.sh` (It's in path). +See the [developerRobot](developerRobot/README.md) subproject. diff --git a/developerRobot/CMakeLists.txt b/developerRobot/CMakeLists.txt new file mode 100644 index 0000000000..f942e01bb0 --- /dev/null +++ b/developerRobot/CMakeLists.txt @@ -0,0 +1,8 @@ +project(developerRobot) + +include(CompileWarnings) + +file(GLOB developerRobotCpp_src src/main/native/cpp/*.cpp) + +add_executable(developerRobotCpp ${developerRobotCpp_src}) +target_link_libraries(developerRobotCpp wpilibc) diff --git a/developerRobot/README.md b/developerRobot/README.md new file mode 100644 index 0000000000..8e01131440 --- /dev/null +++ b/developerRobot/README.md @@ -0,0 +1,43 @@ +# Developer Robot + +This is a robot project built directly against this repo's sources. It builds the minimum required for deploying to a roboRIO, so it's faster than publishing the whole library to Maven first. + +This command builds everything. +```bash +./gradlew developerRobot:build +``` + +## Simulation + +This command runs the C++ subproject on desktop. +```bash +./gradlew developerRobot:runCpp +``` + +## Deploy to a roboRIO + +This project can only deploy over USB. If an alternate IP address is preferred, the `address` block in developerRobot\build.gradle can be changed to point to another address. + +This command deploys the C++ project using shared dependencies. Prefer this one for most C++ development. +```bash +./gradlew developerRobot:deployShared +``` + +This command deploys the C++ project with all dependencies statically linked. +```bash +./gradlew developerRobot:deployStatic +``` + +This command deploys the Java project and all required dependencies. It also installs the JRE if it's not currently installed. +```bash +./gradlew developerRobot:deployJava +``` + +Those commands won't start the robot executable, so you have to manually ssh in and start it. The following command will do that. +```bash +ssh lvuser@172.22.11.2 frcRunRobot.sh +``` + +Console log prints will appear in the terminal. + +Deploying any of these to the roboRIO will disable the current startup project until it is redeployed. diff --git a/myRobot/build.gradle b/developerRobot/build.gradle similarity index 87% rename from myRobot/build.gradle rename to developerRobot/build.gradle index a513d26111..96cf8c2a6d 100644 --- a/myRobot/build.gradle +++ b/developerRobot/build.gradle @@ -22,8 +22,8 @@ application { } ext { - sharedCvConfigs = [myRobotCpp: []] - staticCvConfigs = [myRobotCppStatic: []] + sharedCvConfigs = [developerRobotCpp: []] + staticCvConfigs = [developerRobotCppStatic: []] useJava = true useCpp = true skipDev = true @@ -94,30 +94,30 @@ deploy { } } - myRobotCpp(NativeExecutableArtifact) { + developerRobotCpp(NativeExecutableArtifact) { libraryDirectory = '/usr/local/frc/third-party/lib' def excludes = getLibraryFilter().getExcludes() excludes.add('**/*.so.debug') excludes.add('**/*.so.*.debug') postdeploy << { ctx -> - ctx.execute("echo '/home/lvuser/myRobotCpp' > /home/lvuser/robotCommand") + ctx.execute("echo '/home/lvuser/developerRobotCpp' > /home/lvuser/robotCommand") ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand") - ctx.execute("setcap cap_sys_nice+eip \"/home/lvuser/myRobotCpp\"") - ctx.execute('chmod +x myRobotCpp') + ctx.execute("setcap cap_sys_nice+eip \"/home/lvuser/developerRobotCpp\"") + ctx.execute('chmod +x developerRobotCpp') } } - myRobotCppStatic(NativeExecutableArtifact) { + developerRobotCppStatic(NativeExecutableArtifact) { libraryDirectory = '/usr/local/frc/third-party/lib' postdeploy << { ctx -> - ctx.execute("echo '/home/lvuser/myRobotCppStatic' > /home/lvuser/robotCommand") + ctx.execute("echo '/home/lvuser/developerRobotCppStatic' > /home/lvuser/robotCommand") ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand") - ctx.execute("setcap cap_sys_nice+eip \"/home/lvuser/myRobotCppStatic\"") - ctx.execute('chmod +x myRobotCppStatic') + ctx.execute("setcap cap_sys_nice+eip \"/home/lvuser/developerRobotCppStatic\"") + ctx.execute('chmod +x developerRobotCppStatic') } } - myRobotCppJava(NativeExecutableArtifact) { + developerRobotCppJava(NativeExecutableArtifact) { libraryDirectory = '/usr/local/frc/third-party/lib' def excludes = getLibraryFilter().getExcludes() excludes.add('**/*.so.debug') @@ -127,10 +127,10 @@ deploy { jre(WPIJREArtifact) { } - myRobotJava(JavaArtifact) { + developerRobotJava(JavaArtifact) { jarTask = shadowJar postdeploy << { ctx -> - ctx.execute("echo '/usr/local/frc/JRE/bin/java -XX:+UseSerialGC -Djava.library.path=/usr/local/frc/third-party/lib -Djava.lang.invoke.stringConcat=BC_SB -jar /home/lvuser/myRobot-all.jar' > /home/lvuser/robotCommand") + ctx.execute("echo '/usr/local/frc/JRE/bin/java -XX:+UseSerialGC -Djava.library.path=/usr/local/frc/third-party/lib -Djava.lang.invoke.stringConcat=BC_SB -jar /home/lvuser/developerRobot-all.jar' > /home/lvuser/robotCommand") ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand") } } @@ -142,29 +142,29 @@ deploy { tasks.register('deployJava') { try { dependsOn tasks.named('deployjreroborio') - dependsOn tasks.named('deploymyRobotJavaroborio') - dependsOn tasks.named('deploymyRobotCppJavaroborio') // Deploying shared C++ is how to get the Java shared libraries. + dependsOn tasks.named('deploydeveloperRobotJavaroborio') + dependsOn tasks.named('deploydeveloperRobotCppJavaroborio') // Deploying shared C++ is how to get the Java shared libraries. } catch (ignored) { } } tasks.register('deployShared') { try { - dependsOn tasks.named('deploymyRobotCpproborio') + dependsOn tasks.named('deploydeveloperRobotCpproborio') } catch (ignored) { } } tasks.register('deployStatic') { try { - dependsOn tasks.named('deploymyRobotCppStaticroborio') + dependsOn tasks.named('deploydeveloperRobotCppStaticroborio') } catch (ignored) { } } model { components { - myRobotCpp(NativeExecutableSpec) { + developerRobotCpp(NativeExecutableSpec) { targetBuildTypes 'debug' sources { cpp { @@ -181,8 +181,8 @@ model { binaries.all { binary -> if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { if (binary.buildType.name == 'debug') { - deploy.targets.roborio.artifacts.myRobotCpp.binary = binary - deploy.targets.roborio.artifacts.myRobotCppJava.binary = binary + deploy.targets.roborio.artifacts.developerRobotCpp.binary = binary + deploy.targets.roborio.artifacts.developerRobotCppJava.binary = binary } } lib project: ':apriltag', library: 'apriltag', linkage: 'shared' @@ -213,7 +213,7 @@ model { } } } - myRobotCppStatic(NativeExecutableSpec) { + developerRobotCppStatic(NativeExecutableSpec) { targetBuildTypes 'debug' nativeUtils.excludeBinariesFromStrip(it) sources { @@ -231,7 +231,7 @@ model { binaries.all { binary -> if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { if (binary.buildType.name == 'debug') { - deploy.targets.roborio.artifacts.myRobotCppStatic.binary = binary + deploy.targets.roborio.artifacts.developerRobotCppStatic.binary = binary } } lib project: ':apriltag', library: 'apriltag', linkage: 'static' @@ -254,12 +254,12 @@ model { def c = $.components project.tasks.create('runCpp', Exec) { group = 'WPILib' - description = "Run the myRobotCpp executable" + description = "Run the developerRobotCpp executable" def found = false def systemArch = getCurrentArch() def runTask = it c.each { - if (it in NativeExecutableSpec && it.name == "myRobotCpp") { + if (it in NativeExecutableSpec && it.name == "developerRobotCpp") { it.binaries.each { if (!found) { def arch = it.targetPlatform.name @@ -308,14 +308,14 @@ model { } installAthena(Task) { $.binaries.each { - if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'myRobotCpp') { + if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'developerRobotCpp') { dependsOn it.tasks.install } } } installAthenaStatic(Task) { $.binaries.each { - if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'myRobotCppStatic') { + if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'developerRobotCppStatic') { dependsOn it.tasks.install } } diff --git a/myRobot/src/main/java/frc/robot/Main.java b/developerRobot/src/main/java/frc/robot/Main.java similarity index 92% rename from myRobot/src/main/java/frc/robot/Main.java rename to developerRobot/src/main/java/frc/robot/Main.java index 428a73d112..9d5286d912 100644 --- a/myRobot/src/main/java/frc/robot/Main.java +++ b/developerRobot/src/main/java/frc/robot/Main.java @@ -15,6 +15,6 @@ public final class Main { *

If you change your main robot class, change the parameter type. */ public static void main(String... args) { - RobotBase.startRobot(MyRobot::new); + RobotBase.startRobot(Robot::new); } } diff --git a/myRobot/src/main/java/frc/robot/MyRobot.java b/developerRobot/src/main/java/frc/robot/Robot.java similarity index 96% rename from myRobot/src/main/java/frc/robot/MyRobot.java rename to developerRobot/src/main/java/frc/robot/Robot.java index a5f88bd3f3..0263e33698 100644 --- a/myRobot/src/main/java/frc/robot/MyRobot.java +++ b/developerRobot/src/main/java/frc/robot/Robot.java @@ -6,7 +6,7 @@ package frc.robot; import edu.wpi.first.wpilibj.TimedRobot; -public class MyRobot extends TimedRobot { +public class Robot extends TimedRobot { /** * This function is run when the robot is first started up and should be used for any * initialization code. diff --git a/myRobot/src/main/native/cpp/MyRobot.cpp b/developerRobot/src/main/native/cpp/Robot.cpp similarity index 93% rename from myRobot/src/main/native/cpp/MyRobot.cpp rename to developerRobot/src/main/native/cpp/Robot.cpp index f339b95a84..238697d42b 100644 --- a/myRobot/src/main/native/cpp/MyRobot.cpp +++ b/developerRobot/src/main/native/cpp/Robot.cpp @@ -4,7 +4,7 @@ #include -class MyRobot : public frc::TimedRobot { +class Robot : public frc::TimedRobot { /** * This function is run when the robot is first started up and should be * used for any initialization code. @@ -43,5 +43,5 @@ class MyRobot : public frc::TimedRobot { }; int main() { - return frc::StartRobot(); + return frc::StartRobot(); } diff --git a/myRobot/CMakeLists.txt b/myRobot/CMakeLists.txt deleted file mode 100644 index fd9fba624c..0000000000 --- a/myRobot/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -project(myRobot) - -include(CompileWarnings) - -file(GLOB myRobotCpp_src src/main/native/cpp/*.cpp) - -add_executable(myRobotCpp ${myRobotCpp_src}) -target_link_libraries(myRobotCpp wpilibc) diff --git a/settings.gradle b/settings.gradle index 38ebe2a348..0ce2398ca6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -52,7 +52,7 @@ include 'cameraserver:multiCameraServer' include 'wpilibNewCommands' include 'romiVendordep' include 'xrpVendordep' -include 'myRobot' +include 'developerRobot' include 'docs' include 'msvcruntime' include 'ntcoreffi'