Rename myRobot to developerRobot and move docs to subproject (#6283)

This commit is contained in:
Tyler Veness
2024-05-24 10:41:23 -07:00
committed by GitHub
parent 65f4505e3c
commit ae655a3a71
10 changed files with 85 additions and 53 deletions

View File

@@ -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)

43
developerRobot/README.md Normal file
View File

@@ -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.

324
developerRobot/build.gradle Normal file
View File

@@ -0,0 +1,324 @@
import edu.wpi.first.deployutils.deploy.target.RemoteTarget
import edu.wpi.first.deployutils.deploy.target.location.SshDeployLocation
import edu.wpi.first.deployutils.deploy.artifact.*
import org.gradle.internal.os.OperatingSystem
plugins {
id 'java'
id 'application'
id 'cpp'
id 'visual-studio'
}
apply plugin: 'edu.wpi.first.NativeUtils'
apply plugin: 'edu.wpi.first.DeployUtils'
apply from: '../shared/config.gradle'
application {
if (OperatingSystem.current().isMacOsX()) {
applicationDefaultJvmArgs = ['-XstartOnFirstThread']
}
}
ext {
sharedCvConfigs = [developerRobotCpp: []]
staticCvConfigs = [developerRobotCppStatic: []]
useJava = true
useCpp = true
skipDev = true
}
apply from: "${rootDir}/shared/opencv.gradle"
application {
mainClass = 'frc.robot.Main'
}
apply plugin: 'com.github.johnrengelman.shadow'
repositories {
maven {
url = 'https://frcmaven.wpi.edu/artifactory/ex-mvn'
}
}
dependencies {
implementation project(':wpilibj')
implementation project(':wpimath')
implementation project(':hal')
implementation project(':wpiutil')
implementation project(':wpinet')
implementation project(':ntcore')
implementation project(':cscore')
implementation project(':cameraserver')
implementation project(':wpilibNewCommands')
implementation project(':apriltag')
}
tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach {
onlyIf { false }
}
def simProjects = ['halsim_gui']
deploy {
targets {
roborio(RemoteTarget) {
directory = '/home/lvuser'
maxChannels = 4
locations {
ssh(SshDeployLocation) {
address = "172.22.11.2"
user = 'admin'
password = ''
ipv6 = false
}
}
def remote = it
artifacts.registerFactory(WPIJREArtifact) {
return objects.newInstance(WPIJREArtifact, it, remote)
}
artifacts {
all {
predeploy << { ctx ->
ctx.execute('. /etc/profile.d/natinst-path.sh; /usr/local/frc/bin/frcKillRobot.sh -t 2> /dev/null')
ctx.execute("sed -i -e 's/\"exec /\"/' /usr/local/frc/bin/frcRunRobot.sh")
}
postdeploy << { ctx ->
ctx.execute("sync")
ctx.execute("ldconfig")
}
}
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/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/developerRobotCpp\"")
ctx.execute('chmod +x developerRobotCpp')
}
}
developerRobotCppStatic(NativeExecutableArtifact) {
libraryDirectory = '/usr/local/frc/third-party/lib'
postdeploy << { ctx ->
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/developerRobotCppStatic\"")
ctx.execute('chmod +x developerRobotCppStatic')
}
}
developerRobotCppJava(NativeExecutableArtifact) {
libraryDirectory = '/usr/local/frc/third-party/lib'
def excludes = getLibraryFilter().getExcludes()
excludes.add('**/*.so.debug')
excludes.add('**/*.so.*.debug')
}
jre(WPIJREArtifact) {
}
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/developerRobot-all.jar' > /home/lvuser/robotCommand")
ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand")
}
}
}
}
}
}
tasks.register('deployJava') {
try {
dependsOn tasks.named('deployjreroborio')
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('deploydeveloperRobotCpproborio')
} catch (ignored) {
}
}
tasks.register('deployStatic') {
try {
dependsOn tasks.named('deploydeveloperRobotCppStaticroborio')
} catch (ignored) {
}
}
model {
components {
developerRobotCpp(NativeExecutableSpec) {
targetBuildTypes 'debug'
sources {
cpp {
source {
srcDirs = ['src/main/native/cpp']
includes = ['**/*.cpp']
}
exportedHeaders {
srcDirs = ['src/main/native/include']
includes = ['**/*.h']
}
}
}
binaries.all { binary ->
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (binary.buildType.name == 'debug') {
deploy.targets.roborio.artifacts.developerRobotCpp.binary = binary
deploy.targets.roborio.artifacts.developerRobotCppJava.binary = binary
}
}
lib project: ':apriltag', library: 'apriltag', linkage: 'shared'
lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared'
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
project(':ntcore').addNtcoreDependency(binary, 'shared')
project(':ntcore').addNtcoreJniDependency(binary)
lib project: ':cscore', library: 'cscore', linkage: 'shared'
lib project: ':cscore', library: 'cscoreJNIShared', linkage: 'shared'
lib project: ':wpimath', library: 'wpimathJNIShared', linkage: 'shared'
lib project: ':wpinet', library: 'wpinetJNIShared', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutilJNIShared', linkage: 'shared'
project(':hal').addHalDependency(binary, 'shared')
project(':hal').addHalJniDependency(binary)
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
nativeUtils.useRequiredLibrary(binary, 'ni_link_libraries', 'ni_runtime_libraries')
} else {
def systemArch = getCurrentArch()
if (binary.targetPlatform.name == systemArch) {
simProjects.each {
lib project: ":simulation:$it", library: it, linkage: 'shared'
}
}
}
}
}
developerRobotCppStatic(NativeExecutableSpec) {
targetBuildTypes 'debug'
nativeUtils.excludeBinariesFromStrip(it)
sources {
cpp {
source {
srcDirs = ['src/main/native/cpp']
includes = ['**/*.cpp']
}
exportedHeaders {
srcDirs = ['src/main/native/include']
includes = ['**/*.h']
}
}
}
binaries.all { binary ->
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (binary.buildType.name == 'debug') {
deploy.targets.roborio.artifacts.developerRobotCppStatic.binary = binary
}
}
lib project: ':apriltag', library: 'apriltag', linkage: 'static'
lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'static'
lib project: ':wpilibc', library: 'wpilibc', linkage: 'static'
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
lib project: ':cameraserver', library: 'cameraserver', linkage: 'static'
project(':ntcore').addNtcoreDependency(binary, 'static')
lib project: ':cscore', library: 'cscore', linkage: 'static'
project(':hal').addHalDependency(binary, 'static')
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
nativeUtils.useRequiredLibrary(binary, 'ni_link_libraries', 'ni_runtime_libraries')
}
}
}
}
tasks {
def c = $.components
project.tasks.create('runCpp', Exec) {
group = 'WPILib'
description = "Run the developerRobotCpp executable"
def found = false
def systemArch = getCurrentArch()
def runTask = it
c.each {
if (it in NativeExecutableSpec && it.name == "developerRobotCpp") {
it.binaries.each {
if (!found) {
def arch = it.targetPlatform.name
if (arch == systemArch) {
dependsOn it.tasks.install
commandLine it.tasks.install.runScriptFile.get().asFile.toString()
def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib'
run.dependsOn it.tasks.install
run.systemProperty 'java.library.path', filePath
run.environment 'LD_LIBRARY_PATH', filePath
run.environment 'DYLD_LIBRARY_PATH', filePath
def installTask = it.tasks.install
def doFirstTask = {
def extensions = '';
installTask.installDirectory.get().getAsFile().eachFileRecurse {
def name = it.name
if (!(name.endsWith('.dll') || name.endsWith('.so') || name.endsWith('.dylib'))) {
return
}
def file = it
simProjects.each {
if (name.startsWith(it) || name.startsWith("lib$it".toString())) {
extensions += file.absolutePath + File.pathSeparator
}
}
}
if (extensions != '') {
run.environment 'HALSIM_EXTENSIONS', extensions
runTask.environment 'HALSIM_EXTENSIONS', extensions
}
}
runTask.doFirst doFirstTask
run.doFirst doFirstTask
run.workingDir filePath
found = true
}
}
}
}
}
}
installAthena(Task) {
$.binaries.each {
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 == 'developerRobotCppStatic') {
dependsOn it.tasks.install
}
}
}
}
}

View File

@@ -0,0 +1,20 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc.robot;
import edu.wpi.first.wpilibj.RobotBase;
public final class Main {
private Main() {}
/**
* Main initialization function. Do not perform any initialization here.
*
* <p>If you change your main robot class, change the parameter type.
*/
public static void main(String... args) {
RobotBase.startRobot(Robot::new);
}
}

View File

@@ -0,0 +1,40 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc.robot;
import edu.wpi.first.wpilibj.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.
*/
@Override
public void robotInit() {}
/** This function is run once each time the robot enters autonomous mode. */
@Override
public void autonomousInit() {}
/** This function is called periodically during autonomous. */
@Override
public void autonomousPeriodic() {}
/** This function is called once each time the robot enters tele-operated mode. */
@Override
public void teleopInit() {}
/** This function is called periodically during operator control. */
@Override
public void teleopPeriodic() {}
/** This function is called periodically during test mode. */
@Override
public void testPeriodic() {}
/** This function is called periodically during all modes. */
@Override
public void robotPeriodic() {}
}

View File

@@ -0,0 +1,47 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <frc/TimedRobot.h>
class Robot : public frc::TimedRobot {
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
void RobotInit() override {}
/**
* This function is run once each time the robot enters autonomous mode
*/
void AutonomousInit() override {}
/**
* This function is called periodically during autonomous
*/
void AutonomousPeriodic() override {}
/**
* This function is called once each time the robot enters tele-operated mode
*/
void TeleopInit() override {}
/**
* This function is called periodically during operator control
*/
void TeleopPeriodic() override {}
/**
* This function is called periodically during test mode
*/
void TestPeriodic() override {}
/**
* This function is called periodically during all modes
*/
void RobotPeriodic() override {}
};
int main() {
return frc::StartRobot<Robot>();
}