From 49fcdb64ede88fc40749bd4507bc016aa54aba02 Mon Sep 17 00:00:00 2001 From: Chris Gerth Date: Tue, 23 Mar 2021 12:57:32 -0500 Subject: [PATCH] Update Sim Example Unit Conversions (#265) Updated Java examples to fix radians/degrees mismatch. Inspected c++ examples - they create a units::degree_t from the NT value, which should be handled properly inside the PhotonUtils methods. --- .../src/main/java/org/photonlib/examples/aimandrange/Robot.java | 2 +- .../src/main/java/org/photonlib/examples/getinrange/Robot.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/photonlib-java-examples/src/main/java/org/photonlib/examples/aimandrange/Robot.java b/photonlib-java-examples/src/main/java/org/photonlib/examples/aimandrange/Robot.java index 3e168e4d9..f2f624604 100644 --- a/photonlib-java-examples/src/main/java/org/photonlib/examples/aimandrange/Robot.java +++ b/photonlib-java-examples/src/main/java/org/photonlib/examples/aimandrange/Robot.java @@ -79,7 +79,7 @@ public class Robot extends TimedRobot { CAMERA_HEIGHT_METERS, TARGET_HEIGHT_METERS, CAMERA_PITCH_RADIANS, - result.getBestTarget().getPitch()); + Units.degreesToRadians(result.getBestTarget().getPitch())); // Use this range as the measurement we give to the PID controller. // -1.0 required to ensure positive PID controller effort _increases_ range diff --git a/photonlib-java-examples/src/main/java/org/photonlib/examples/getinrange/Robot.java b/photonlib-java-examples/src/main/java/org/photonlib/examples/getinrange/Robot.java index 3d11bdf5e..26cea1bac 100644 --- a/photonlib-java-examples/src/main/java/org/photonlib/examples/getinrange/Robot.java +++ b/photonlib-java-examples/src/main/java/org/photonlib/examples/getinrange/Robot.java @@ -81,7 +81,7 @@ public class Robot extends TimedRobot { CAMERA_HEIGHT_METERS, TARGET_HEIGHT_METERS, CAMERA_PITCH_RADIANS, - result.getBestTarget().getPitch()); + Units.degreesToRadians(result.getBestTarget().getPitch())); // Use this range as the measurement we give to the PID controller. // -1.0 required to ensure positive PID controller effort _increases_ range