Files
PhotonVision/photon-server/build.gradle
Chris Gerth f1d1d325e0 Move to using Absolute Exposure Range (#1352)
Uses logic in
https://github.com/PhotonVision/photon-libcamera-gl-driver/pull/16 to
push the ov9281 down to its true minimum exposure.

Updates UI to list the exposure settings in ~~microseconds.~~ Native
units - not everyone works in microseconds.

Does its darndest to actually try to set the exposure in
~~microseconds.~~ Native Units. To do this...

Lifecam is funky when doing this - [cscore limits the exposure settings
to certain quantized
values](https://github.com/wpilibsuite/allwpilib/blob/main/cscore/src/main/native/linux/UsbCameraImpl.cpp#L129).
Add a new camera quirk to allow that.

~~Updated camera quirks to re-evaluate every camera load (rather than
recalling from settings - this shouldn't be necessary)~~ This should be
rolled back, needed for arducam type selection.

Updated camera quirk matching logic to make PID/VID optional, and
basename optional (and only match trailing characters). This enables
mirroring CSCore's logic for identifying lifecams by name.

Updated the USBCamera to primarily use cscore's exposed property names.

Since camera manufacturers use a potpourri of names for the same
thing....

For nice-to-have settings: new soft-set logic to try all possible names,
but gracefully pass if the property isn't there.
For required settings: Search a list for the first setting that's
supported, fail if none are supported.

More logging of camera properties to help debug.

Note: most of this work is because cscore doesn't directly expose a
massaged exposure-setting-absolute API (and, given what we've seen,
probably _shouldn't_, this struggle is not for the faint of heart).

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2024-08-17 10:02:59 -05:00

134 lines
4.4 KiB
Groovy

plugins {
id "application"
id 'com.github.johnrengelman.shadow' version '8.1.1'
id "com.github.node-gradle.node" version "7.0.1"
id "org.hidetake.ssh" version "2.11.2"
id 'edu.wpi.first.WpilibTools' version '1.3.0'
}
apply from: "${rootDir}/shared/common.gradle"
dependencies {
implementation project(':photon-core')
// Needed for Javalin Runtime Logging
implementation "org.slf4j:slf4j-simple:2.0.7"
}
group 'org.photonvision'
version versionString + (project.hasProperty('pionly') ? "-raspi" : "")
application {
mainClass = 'org.photonvision.Main'
}
shadowJar {
archiveBaseName = "photonvision"
archiveVersion = project.version as String
archiveClassifier.set(wpilibTools.currentPlatform.platformName)
configurations = [
project.configurations.runtimeClasspath
]
}
node {
nodeProjectDir = file("${projectDir}/../photon-client")
}
tasks.register('copyClientUIToResources', Copy) {
from "${projectDir}/../photon-client/dist/"
into "${projectDir}/src/main/resources/web/"
}
tasks.register("buildAndCopyUI") {
dependsOn "npm_run_build"
finalizedBy "copyClientUIToResources"
}
run {
environment "PATH_PREFIX", "../"
}
run {
if (project.hasProperty("profile")) {
jvmArgs=[
"-Dcom.sun.management.jmxremote=true",
"-Dcom.sun.management.jmxremote.ssl=false",
"-Dcom.sun.management.jmxremote.authenticate=false",
"-Dcom.sun.management.jmxremote.port=5000",
"-Djava.rmi.server.hostname=0.0.0.0",
]
}
}
remotes {
pi {
host = 'photonvision.local'
user = 'pi'
password = 'raspberry'
knownHosts = allowAnyHosts
}
}
task findDeployTarget {
doLast {
if(project.hasProperty('tgtIP')){
//If user specificed IP, default to using the PI profile
// but adjust hostname to match the provided IP address
findDeployTarget.ext.rmt = remotes.pi
findDeployTarget.ext.rmt.host=tgtIP
} else {
findDeployTarget.ext.rmt = null
for(testRmt in remotes){
println "Checking for " + testRmt.host
boolean canContact = false;
try {
InetAddress testAddr = InetAddress.getByName(testRmt.host)
canContact = testAddr.isReachable(2000)
} catch(UnknownHostException e) {
canContact = false;
}
if(canContact){
println "Found!"
findDeployTarget.ext.rmt = testRmt
break
} else {
println "Not Found."
}
}
if(findDeployTarget.ext.rmt == null ){
throw new GradleException("Could not find a supported target for deployment!")
}
}
}
}
task deploy {
dependsOn findDeployTarget
dependsOn assemble
doLast {
println 'Starting deployment to ' + findDeployTarget.rmt.host
println 'targetArch = ' + wpilibTools.platformMapper.currentPlatform.platformName
ssh.run{
session(findDeployTarget.rmt) {
//Stop photonvision before manipulating its files
execute 'sudo systemctl stop photonvision.service'
// gerth2 - I was having issues with the .jar being in use still - waiting a tiny bit here seems to get rid of it on a pi4
execute 'sleep 3'
// Copy into a folder owned by PI. Mostly because, as far as I can tell, the put command doesn't support sudo.
put from: "${projectDir}/build/libs/photonvision-${project.version}-${wpilibTools.platformMapper.currentPlatform.platformName}.jar", into: "/tmp/photonvision.jar"
//belt-and-suspenders. Make sure the old jar is gone first.
execute 'sudo rm -f /opt/photonvision/photonvision.jar'
//Copy in the new .jar and make sure it's executable
execute 'sudo mv /tmp/photonvision.jar /opt/photonvision/photonvision.jar'
execute 'sudo chmod +x /opt/photonvision/photonvision.jar'
//Fire up photonvision again
execute 'sudo systemctl start photonvision.service'
//Cleanup
execute 'sudo rm -f /tmp/photonvision.jar'
}
}
}
}