Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.cwd": "photon-lib/py"
"python.testing.cwd": "photon-lib/py",
"files.associations": {
"bitset": "cpp"
}
}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id "cpp"
id "com.diffplug.spotless" version "6.24.0"
id "edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin" version "2020.2"
id "edu.wpi.first.GradleRIO" version "2025.3.2"
id "edu.wpi.first.GradleRIO" version "2026.1.1-beta-1"
id 'edu.wpi.first.WpilibTools' version '1.3.0'
id 'com.google.protobuf' version '0.9.3' apply false
id 'edu.wpi.first.GradleJni' version '1.1.0'
Expand Down Expand Up @@ -32,7 +32,7 @@ ext.allOutputsFolder = file("$project.buildDir/outputs")
apply from: "versioningHelper.gradle"

ext {
wpilibVersion = "2025.3.2"
wpilibVersion = "2026.1.1-beta-1"
wpimathVersion = wpilibVersion
openCVYear = "2025"
openCVversion = "4.10.0-3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Bonjour provides more stable networking when using Windows PCs. Install [Bonjour

## Installing Java

PhotonVision requires a JDK installed and on the system path. **JDK 17 is needed. Windows Users must use the JDK that ships with WPILib.** [Download and install it from here.](https://github.com/wpilibsuite/allwpilib/releases/tag/v2025.3.2) Either ensure the only Java on your PATH is the WPILIB Java or specify it to gradle with `-Dorg.gradle.java.home=C:\Users\Public\wpilib\2025\jdk`:
PhotonVision requires a JDK installed and on the system path. **JDK 17 is needed. Windows Users must use the JDK that ships with WPILib.** [Download and install it from here.](https://github.com/wpilibsuite/allwpilib/releases/tag/2026.1.1-beta-1) Either ensure the only Java on your PATH is the WPILIB Java or specify it to gradle with `-Dorg.gradle.java.home=C:\Users\Public\wpilib\2025\jdk`:

```
> ./gradlew run "-Dorg.gradle.java.home=C:\Users\Public\wpilib\2025\jdk"
Expand Down
10 changes: 5 additions & 5 deletions photon-lib/py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
version=versionString,
install_requires=[
"numpy~=2.1",
"wpilib<2026,>=2025.3.2",
"robotpy-wpimath<2026,>=2025.3.2",
"robotpy-apriltag<2026,>=2025.3.2",
"robotpy-cscore<2026,>=2025.3.2",
"pyntcore<2026,>=2025.3.2",
"wpilib==2026.1.1-beta-1",
"robotpy-wpimath==2026.1.1-beta-1",
"robotpy-apriltag==2026.1.1-beta-1",
"robotpy-cscore==2026.1.1-beta-1",
"pyntcore==2026.1.1-beta-1",
"opencv-python;platform_machine!='roborio'",
],
description=descriptionStr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ struct ProblemState {
#undef MAKE_ARGV
};

wpi::expected<constrained_solvepnp::RobotStateMat,
sleipnir::SolverExitCondition>
wpi::expected<constrained_solvepnp::RobotStateMat, slp::ExitStatus>
constrained_solvepnp::do_optimization(
bool heading_free, int nTags,
constrained_solvepnp::CameraCalibration cameraCal,
Expand All @@ -173,7 +172,7 @@ constrained_solvepnp::do_optimization(
if constexpr (VERBOSE) fmt::println("Got unexpected num cols!");
// TODO find a new error code
return wpi::unexpected{
sleipnir::SolverExitCondition::kNonfiniteInitialCostOrConstraints};
slp::ExitStatus::NONFINITE_INITIAL_COST_OR_CONSTRAINTS};
}

// rescale observations to homogenous pixel coordinates
Expand Down Expand Up @@ -203,7 +202,7 @@ constrained_solvepnp::do_optimization(
auto problemOpt = createProblem(nTags, heading_free);
if (!problemOpt) {
return wpi::unexpected{
sleipnir::SolverExitCondition::kNonfiniteInitialCostOrConstraints};
slp::ExitStatus::NONFINITE_INITIAL_COST_OR_CONSTRAINTS};
}

ProblemState<3> pState{robot2camera, field2points, point_observations,
Expand Down Expand Up @@ -233,7 +232,7 @@ constrained_solvepnp::do_optimization(

// Check for diverging iterates
if (x.template lpNorm<Eigen::Infinity>() > 1e20 || !x.allFinite()) {
return wpi::unexpected{sleipnir::SolverExitCondition::kDivergingIterates};
return wpi::unexpected{slp::ExitStatus::DIVERGING_ITERATES};
}

GradMat g = pState.calculateGradJ(x);
Expand All @@ -254,7 +253,7 @@ constrained_solvepnp::do_optimization(
auto H_ldlt = H.ldlt();
if (H_ldlt.info() != Eigen::Success) {
std::cerr << "LDLT decomp failed! H=" << std::endl << H << std::endl;
return wpi::unexpected{sleipnir::SolverExitCondition::kLocallyInfeasible};
return wpi::unexpected{slp::ExitStatus::LOCALLY_INFEASIBLE};
}

// Make sure H is positive definite (all eigenvalues are > 0)
Expand All @@ -278,8 +277,7 @@ constrained_solvepnp::do_optimization(

if (H_ldlt.info() != Eigen::Success) {
std::cerr << "LDLT decomp failed! H=" << std::endl << H << std::endl;
return wpi::unexpected{
sleipnir::SolverExitCondition::kLocallyInfeasible};
return wpi::unexpected{slp::ExitStatus::LOCALLY_INFEASIBLE};
}

// If our eigenvalues aren't positive definite, pick a new δ for next
Expand All @@ -289,8 +287,7 @@ constrained_solvepnp::do_optimization(

// If the Hessian perturbation is too high, report failure
if (δ > 1e20) {
return wpi::unexpected{
sleipnir::SolverExitCondition::kLocallyInfeasible};
return wpi::unexpected{slp::ExitStatus::LOCALLY_INFEASIBLE};
}
} else {
// Done!
Expand All @@ -301,8 +298,7 @@ constrained_solvepnp::do_optimization(
}

if (i_reg == MAX_REG_STEPS) {
return wpi::unexpected{
sleipnir::SolverExitCondition::kLocallyInfeasible};
return wpi::unexpected{slp::ExitStatus::LOCALLY_INFEASIBLE};
}
} else {
// std::printf("Already regularized\n");
Expand Down Expand Up @@ -345,8 +341,7 @@ constrained_solvepnp::do_optimization(

// If our step size shrank too much, report local infesibility
if (alpha < α_min_frac * γConstraint) {
return wpi::unexpected{
sleipnir::SolverExitCondition::kLocallyInfeasible};
return wpi::unexpected{slp::ExitStatus::LOCALLY_INFEASIBLE};
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,8 @@ std::optional<photon::PnpResult> EstimateRobotPoseConstrainedSolvePNP(
guess2.X().value(), guess2.Y().value(),
guess2.Rotation().Radians().value()};

wpi::expected<constrained_solvepnp::RobotStateMat,
sleipnir::SolverExitCondition>
result = constrained_solvepnp::do_optimization(
wpi::expected<constrained_solvepnp::RobotStateMat, slp::ExitStatus> result =
constrained_solvepnp::do_optimization(
headingFree, knownTags.size(), cameraCal, robotToCamera, guessMat,
field2points, pointObservations, gyroTheta.Radians().value(),
gyroErrorScaleFac);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#pragma once

#include <Eigen/Core>
#include <sleipnir/optimization/SolverExitCondition.hpp>
#include <sleipnir/optimization/solver/exit_status.hpp>
#include <wpi/expected>

namespace constrained_solvepnp {
Expand All @@ -40,7 +40,7 @@ using RobotStateMat = Eigen::Matrix<casadi_real, 3, 1>;
* to this. The number of columns in field2points and point_observations just be
* exactly 4x nTags.
*/
wpi::expected<RobotStateMat, sleipnir::SolverExitCondition> do_optimization(
wpi::expected<RobotStateMat, slp::ExitStatus> do_optimization(
bool heading_free, int nTags, CameraCalibration cameraCal,
// Note that casadi is column major, apparently
Eigen::Matrix<casadi_real, 4, 4, Eigen::ColMajor> robot2camera,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ Java_org_photonvision_jni_ConstrainedSolvepnpJni_do_1optimization
std::cout << "observations:\n" << pointObservationsMat << std::endl;
#endif

wpi::expected<constrained_solvepnp::RobotStateMat,
sleipnir::SolverExitCondition>
result = constrained_solvepnp::do_optimization(
wpi::expected<constrained_solvepnp::RobotStateMat, slp::ExitStatus> result =
constrained_solvepnp::do_optimization(
headingFree, nTags, cameraCal_, robot2cameraMat, xGuessMat,
field2pointsMat, pointObservationsMat, gyro_θ, gyro_error_scale_fac);

Expand Down
6 changes: 3 additions & 3 deletions photonlib-cpp-examples/aimandrange/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2025.3.2"
id "edu.wpi.first.GradleRIO" version "2026.1.1-beta-1"
}

repositories {
Expand All @@ -11,8 +11,8 @@ repositories {

wpi.maven.useLocal = false
wpi.maven.useDevelopment = false
wpi.versions.wpilibVersion = "2025.3.2"
wpi.versions.wpimathVersion = "2025.3.2"
wpi.versions.wpilibVersion = "2026.1.1-beta-1"
wpi.versions.wpimathVersion = "2026.1.1-beta-1"

// Define my targets (RoboRIO) and artifacts (deployable files)
// This is added by GradleRIO's backing project DeployUtils.
Expand Down
6 changes: 3 additions & 3 deletions photonlib-cpp-examples/aimattarget/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2025.3.2"
id "edu.wpi.first.GradleRIO" version "2026.1.1-beta-1"
}

repositories {
Expand All @@ -11,8 +11,8 @@ repositories {

wpi.maven.useLocal = false
wpi.maven.useDevelopment = false
wpi.versions.wpilibVersion = "2025.3.2"
wpi.versions.wpimathVersion = "2025.3.2"
wpi.versions.wpilibVersion = "2026.1.1-beta-1"
wpi.versions.wpimathVersion = "2026.1.1-beta-1"

// Define my targets (RoboRIO) and artifacts (deployable files)
// This is added by GradleRIO's backing project DeployUtils.
Expand Down
6 changes: 3 additions & 3 deletions photonlib-cpp-examples/poseest/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2025.3.2"
id "edu.wpi.first.GradleRIO" version "2026.1.1-beta-1"
}

repositories {
Expand All @@ -11,8 +11,8 @@ repositories {

wpi.maven.useLocal = false
wpi.maven.useDevelopment = false
wpi.versions.wpilibVersion = "2025.3.2"
wpi.versions.wpimathVersion = "2025.3.2"
wpi.versions.wpilibVersion = "2026.1.1-beta-1"
wpi.versions.wpimathVersion = "2026.1.1-beta-1"

// Define my targets (RoboRIO) and artifacts (deployable files)
// This is added by GradleRIO's backing project DeployUtils.
Expand Down
6 changes: 3 additions & 3 deletions photonlib-java-examples/aimandrange/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2025.3.2"
id "edu.wpi.first.GradleRIO" version "2026.1.1-beta-1"
}

sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -13,8 +13,8 @@ repositories {
}

wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = "2025.3.2"
wpi.versions.wpimathVersion = "2025.3.2"
wpi.versions.wpilibVersion = "2026.1.1-beta-1"
wpi.versions.wpimathVersion = "2026.1.1-beta-1"


// Define my targets (RoboRIO) and artifacts (deployable files)
Expand Down
6 changes: 3 additions & 3 deletions photonlib-java-examples/aimattarget/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2025.3.2"
id "edu.wpi.first.GradleRIO" version "2026.1.1-beta-1"
}

sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -9,8 +9,8 @@ targetCompatibility = JavaVersion.VERSION_17
def ROBOT_MAIN_CLASS = "frc.robot.Main"

wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = "2025.3.2"
wpi.versions.wpimathVersion = "2025.3.2"
wpi.versions.wpilibVersion = "2026.1.1-beta-1"
wpi.versions.wpimathVersion = "2026.1.1-beta-1"


// Define my targets (RoboRIO) and artifacts (deployable files)
Expand Down
6 changes: 3 additions & 3 deletions photonlib-java-examples/poseest/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2025.3.2"
id "edu.wpi.first.GradleRIO" version "2026.1.1-beta-1"
}

sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -9,8 +9,8 @@ targetCompatibility = JavaVersion.VERSION_17
def ROBOT_MAIN_CLASS = "frc.robot.Main"

wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = "2025.3.2"
wpi.versions.wpimathVersion = "2025.3.2"
wpi.versions.wpilibVersion = "2026.1.1-beta-1"
wpi.versions.wpimathVersion = "2026.1.1-beta-1"


// Define my targets (RoboRIO) and artifacts (deployable files)
Expand Down
2 changes: 1 addition & 1 deletion photonlib-python-examples/aimandrange/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[tool.robotpy]

# Version of robotpy this project depends on
robotpy_version = "2025.3.2"
robotpy_version = "2026.1.1-beta-1"

# Which extra RobotPy components should be installed
# -> equivalent to `pip install robotpy[extra1, ...]
Expand Down
2 changes: 1 addition & 1 deletion photonlib-python-examples/aimattarget/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[tool.robotpy]

# Version of robotpy this project depends on
robotpy_version = "2025.3.2"
robotpy_version = "2026.1.1-beta-1"

# Which extra RobotPy components should be installed
# -> equivalent to `pip install robotpy[extra1, ...]
Expand Down
2 changes: 1 addition & 1 deletion photonlib-python-examples/poseest/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[tool.robotpy]

# Version of robotpy this project depends on
robotpy_version = "2025.3.2"
robotpy_version = "2026.1.1-beta-1"

# Which extra RobotPy components should be installed
# -> equivalent to `pip install robotpy[extra1, ...]
Expand Down
Loading