-
Notifications
You must be signed in to change notification settings - Fork 1
Clean Object Detection #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
040edb9
changed order of class variables to match the order of the constructor
ShmayaR dc1b5c5
changed getClosestObjectToPosition to be just. return statement. (tha…
ShmayaR b7940fe
cleaned calculateObjectDistanceRating
ShmayaR dbb4869
cleaned updateObjectPositions
ShmayaR 3467107
this shouldnt be in the template
ShmayaR b7a14a2
renamed stuff
ShmayaR ca9bc12
Revert "cleaned updateObjectPositions"
ShmayaR 9e66d23
got rid of stream
ShmayaR 1173f30
Update ObjectDetectionCamera.java
ShmayaR 3fe3d92
Update SimulationObjectDetectionCameraIO.java
ShmayaR f8e5c7a
added code to use more than one camera
ShmayaR 98ab0c2
moved the object pose estimator to be under the pose estimator package
ShmayaR fb64741
reorganized pose estimation packages and classes
ShmayaR 6bf5614
Merge branch 'main' into clean-object-detection
ShmayaR 78cefa2
reformatted
ShmayaR 295ebe8
extracted update object positions into a few functions to make more r…
ShmayaR fff101a
fixed incorrect condition
ShmayaR 45ecfa2
java doc fix
ShmayaR ece1bda
update logic issue
ShmayaR 251248e
reorganized obejct pose estimation to what it was before
ShmayaR 06f7927
Merge branch 'main' into clean-object-detection
ShmayaR b131bcd
Update lib
ShmayaR e5d38b0
renaming and organizing
ShmayaR ffe948e
rename
ShmayaR a570776
removed distance rating
ShmayaR a3f401f
removed distance calcultation method
ShmayaR ea74422
more ranaming
ShmayaR bf047fa
changed updateObjectPositions to compare both cameras objects to the …
ShmayaR 4ddf1a4
fixed issue
ShmayaR c90f8f3
made object updating function more efficient and separated into mor…
ShmayaR dd4e9bd
updated the function
ShmayaR 3fe913e
updated function again
ShmayaR e81df9f
removed redundant function
ShmayaR 687bef3
extracted into another function for readability
ShmayaR 5f142dd
rename
ShmayaR 471d800
fixed logic issue
ShmayaR e60a7ba
rename
ShmayaR a01fda9
added javadoc
ShmayaR ffc03a9
Merge branch 'main' into clean-object-detection
ShmayaR dd17786
fix
ShmayaR d607c89
fixed issue
ShmayaR d49a98a
extracted into separate functions
ShmayaR 9ddfda6
fixed issue
ShmayaR b0e8f32
reverted to one camera
ShmayaR 124ea0a
Update ObjectPoseEstimator.java
ShmayaR 172bef1
Update ObjectPoseEstimator.java
ShmayaR b0fe9e0
changed functions to void
ShmayaR d6cff5a
added object checking before removing them
ShmayaR daa5a01
made functions void
ShmayaR ddd468c
added javadoc for class hashmap
ShmayaR ebd93d8
fixed javadoc
ShmayaR 12ecdd2
added javadoc
ShmayaR c58b5f7
added function for updating position of discarded update
ShmayaR 4e0068c
fix logic issue
ShmayaR 3ef33a7
fixed logic issue
ShmayaR 8104499
fix order so no crash
ShmayaR 031c69c
clean
ShmayaR 3499127
rename
ShmayaR 456f1f8
reduced unnecessary processes
ShmayaR 83cfa1e
Update ObjectPoseEstimator.java
ShmayaR 77e2c55
Update ObjectPoseEstimator.java
ShmayaR 3878d70
Update ObjectPoseEstimator.java
ShmayaR bb2bbd3
rename and javadoc edits
ShmayaR 9ff0e06
moved double creation outside for loop
ShmayaR b8a1f3d
Merge branch 'main' into clean-object-detection
ShmayaR 018d4cf
simplified logic
ShmayaR 6477951
Update ObjectPoseEstimator.java
ShmayaR fcda610
Update ObjectDetectionCamera.java
ShmayaR 43c1a89
Update ObjectPoseEstimator.java
ShmayaR 5a799b2
mergggge
ShmayaR 342eb19
sdfgh
ShmayaR 330da69
Update lib
ShmayaR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...amera/ObjectDetectionCameraConstants.java → ...ctDetection/ObjectDetectionConstants.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| package frc.trigon.robot.misc.objectdetectioncamera; | ||
| package frc.trigon.robot.misc.objectDetection; | ||
|
|
||
| import frc.trigon.robot.misc.simulatedfield.SimulatedGamePieceConstants; | ||
|
|
||
| public class ObjectDetectionCameraConstants { | ||
| public class ObjectDetectionConstants { | ||
| public static final int NUMBER_OF_GAME_PIECE_TYPES = SimulatedGamePieceConstants.GamePieceType.values().length; | ||
| static final double TRACKED_OBJECT_TOLERANCE_METERS = 0.12; | ||
| } | ||
| } |
220 changes: 220 additions & 0 deletions
220
src/main/java/frc/trigon/robot/misc/objectDetection/ObjectPoseEstimator.java
ShmayaR marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,220 @@ | ||
| package frc.trigon.robot.misc.objectDetection; | ||
|
|
||
| import edu.wpi.first.math.geometry.Pose2d; | ||
| import edu.wpi.first.math.geometry.Transform2d; | ||
| import edu.wpi.first.math.geometry.Translation2d; | ||
| import edu.wpi.first.wpilibj.Timer; | ||
| import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
| import frc.trigon.robot.RobotContainer; | ||
| import frc.trigon.robot.misc.objectDetection.objectdetectioncamera.ObjectDetectionCamera; | ||
| import frc.trigon.robot.misc.simulatedfield.SimulatedGamePieceConstants; | ||
| import org.littletonrobotics.junction.Logger; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| public class ObjectPoseEstimator extends SubsystemBase { | ||
| private final double deletionThresholdSeconds; | ||
| private final SimulatedGamePieceConstants.GamePieceType gamePieceType; | ||
ShmayaR marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private final ObjectDetectionCamera camera; | ||
| /** | ||
| * Stores the position of each detected object along with the timestamp of when it was detected. | ||
| */ | ||
| private final HashMap<Translation2d, Double> objectPositionsToDetectionTimestamp; | ||
|
|
||
| /** | ||
| * Constructs an ObjectPoseEstimator for estimating the positions of objects detected by camera. | ||
| * | ||
| * @param deletionThresholdSeconds the time in seconds after which an object is considered old and removed | ||
| * @param gamePieceType the type of game piece to track | ||
| * @param camera the camera used for detecting objects | ||
| */ | ||
| public ObjectPoseEstimator(double deletionThresholdSeconds, | ||
| SimulatedGamePieceConstants.GamePieceType gamePieceType, | ||
| ObjectDetectionCamera camera) { | ||
| this.deletionThresholdSeconds = deletionThresholdSeconds; | ||
| this.gamePieceType = gamePieceType; | ||
| this.camera = camera; | ||
| this.objectPositionsToDetectionTimestamp = new HashMap<>(); | ||
| } | ||
|
|
||
| /** | ||
| * Updates the object positions based on the camera detected objects. | ||
| * Removes objects that have not been detected for a certain time frame, defined in {@link ObjectPoseEstimator#deletionThresholdSeconds}. | ||
| */ | ||
| @Override | ||
| public void periodic() { | ||
| updateTrackedObjectsPositions(); | ||
| removeOldObjects(); | ||
| Logger.recordOutput("ObjectPoseEstimator/knownObjectPositions", getObjectsOnField().toArray(Translation2d[]::new)); | ||
| } | ||
ShmayaR marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Gets the position of all known objects on the field. | ||
| * | ||
| * @return a list of Translation2d representing the positions of objects on the field | ||
| */ | ||
| public ArrayList<Translation2d> getObjectsOnField() { | ||
| return new ArrayList<>(objectPositionsToDetectionTimestamp.keySet()); | ||
| } | ||
|
|
||
| /** | ||
| * Removes the closest object to the robot from the list of objects in the pose estimator. | ||
| */ | ||
| public void removeClosestObjectToRobot() { | ||
| final Translation2d closestObject = getClosestObjectToRobot(); | ||
| if (closestObject == null) | ||
| return; | ||
| removeObject(closestObject); | ||
| } | ||
|
|
||
| /** | ||
| * Removes the closest object to the intake from the list of objects in the pose estimator. | ||
| * | ||
| * @param intakeTransform the transform of the intake relative to the robot | ||
| */ | ||
| public void removeClosestObjectToIntake(Transform2d intakeTransform) { | ||
| final Pose2d robotPose = RobotContainer.ROBOT_POSE_ESTIMATOR.getEstimatedRobotPose(); | ||
| final Translation2d closestObjectToIntake = getClosestTrackedObjectToPosition(robotPose.transformBy(intakeTransform).getTranslation()); | ||
| if (closestObjectToIntake == null) | ||
| return; | ||
| removeObject(closestObjectToIntake); | ||
| } | ||
|
|
||
| /** | ||
| * Removes the closest object to a given pose from the list of objects in the pose estimator. | ||
ShmayaR marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * | ||
| * @param fieldRelativePose the pose to which the removed object is closest | ||
| */ | ||
| public void removeClosestObjectToPose(Pose2d fieldRelativePose) { | ||
| removeClosestObjectToPosition(fieldRelativePose.getTranslation()); | ||
| } | ||
|
|
||
| /** | ||
| * Removes the closest object to a given position from the stored objects in the pose estimator. | ||
| * | ||
| * @param position the position to which the removed object is closest | ||
| */ | ||
| public void removeClosestObjectToPosition(Translation2d position) { | ||
| final Translation2d closestObject = getClosestTrackedObjectToPosition(position); | ||
| if (closestObject == null) | ||
| return; | ||
| removeObject(closestObject); | ||
| } | ||
|
|
||
| /** | ||
| * Removes a specific object from the stored objects in the pose estimator. | ||
| * Unlike {@link #removeClosestObjectToPosition} which removes the closest object to a given position. | ||
| * | ||
ShmayaR marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * @param objectPosition the position of the object to be removed. Must be the precise position as stored in the pose estimator. | ||
| */ | ||
| public void removeObject(Translation2d objectPosition) { | ||
| objectPositionsToDetectionTimestamp.remove(objectPosition); | ||
| } | ||
|
|
||
| /** | ||
| * Returns whether any objects are stored in the pose estimator. | ||
| * | ||
| * @return if there are objects stored in the pose estimator | ||
| */ | ||
| public boolean hasObjects() { | ||
| return !objectPositionsToDetectionTimestamp.isEmpty(); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the position of the closest object to the robot. | ||
| * | ||
| * @return the closest object to the robot | ||
| */ | ||
| public Translation2d getClosestObjectToRobot() { | ||
| return getClosestTrackedObjectToPosition(RobotContainer.ROBOT_POSE_ESTIMATOR.getEstimatedRobotPose().getTranslation()); | ||
| } | ||
|
|
||
| private void updateTrackedObjectsPositions() { | ||
| final Translation2d[] visibleObjects = camera.getObjectPositionsOnField(gamePieceType); | ||
| final HashMap<Translation2d, Translation2d> trackedObjectsToUpdatedPositions = new HashMap<>(); | ||
|
|
||
| for (Translation2d visibleObject : visibleObjects) | ||
| updateObjectPosition(visibleObject, trackedObjectsToUpdatedPositions); | ||
|
|
||
| applyObjectUpdates(trackedObjectsToUpdatedPositions); | ||
| } | ||
|
|
||
| private void applyObjectUpdates(HashMap<Translation2d, Translation2d> currentToNewObjectPositions) { | ||
| final double currentTimestamp = Timer.getTimestamp(); | ||
|
|
||
| objectPositionsToDetectionTimestamp.keySet().removeAll(currentToNewObjectPositions.keySet()); | ||
| currentToNewObjectPositions.values().forEach(object -> objectPositionsToDetectionTimestamp.put(object, currentTimestamp)); | ||
| } | ||
|
|
||
| private void updateObjectPosition(Translation2d objectUpdate, HashMap<Translation2d, Translation2d> trackedObjectsToUpdatedPositions) { | ||
| final Translation2d closestAvailableTrackedObjectToVisibleObject = getClosestAvailableObjectToUpdate(objectUpdate, trackedObjectsToUpdatedPositions); | ||
| if (closestAvailableTrackedObjectToVisibleObject == null) { | ||
| trackedObjectsToUpdatedPositions.put(objectUpdate, objectUpdate); | ||
| return; | ||
| } | ||
| final Translation2d previousUpdate = trackedObjectsToUpdatedPositions.get(closestAvailableTrackedObjectToVisibleObject); | ||
| trackedObjectsToUpdatedPositions.put(closestAvailableTrackedObjectToVisibleObject, objectUpdate); | ||
| if (previousUpdate != null) | ||
| updateObjectPosition(previousUpdate, trackedObjectsToUpdatedPositions); | ||
| } | ||
|
|
||
| private Translation2d getClosestAvailableObjectToUpdate(Translation2d update, HashMap<Translation2d, Translation2d> objectsWithUpdates) { | ||
| final Set<Translation2d> availableObjectsToUpdate = getAvailableObjectsToUpdate(update, objectsWithUpdates); | ||
| if (availableObjectsToUpdate == null || availableObjectsToUpdate.isEmpty()) | ||
| return null; | ||
| return getClosestObjectFromSetToPosition(update, availableObjectsToUpdate); | ||
| } | ||
|
|
||
| private Set<Translation2d> getAvailableObjectsToUpdate(Translation2d update, HashMap<Translation2d, Translation2d> objectsWithUpdates) { | ||
| if (objectPositionsToDetectionTimestamp.isEmpty()) | ||
| return null; | ||
| final Set<Translation2d> availableObjects = new HashSet<>(); | ||
| for (Translation2d currentObject : objectPositionsToDetectionTimestamp.keySet()) { | ||
| final double updateDistanceFromCurrentObject = update.getDistance(currentObject); | ||
| if (updateDistanceFromCurrentObject > ObjectDetectionConstants.TRACKED_OBJECT_TOLERANCE_METERS) | ||
| continue; | ||
| if (!objectsWithUpdates.containsKey(currentObject)) { | ||
| availableObjects.add(currentObject); | ||
| continue; | ||
| } | ||
| if (isNewUpdateCloserThanPreviousUpdate(update, objectsWithUpdates.get(currentObject), currentObject)) | ||
| availableObjects.add(currentObject); | ||
| } | ||
| return availableObjects; | ||
| } | ||
levyishai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private boolean isNewUpdateCloserThanPreviousUpdate(Translation2d newUpdate, Translation2d previousUpdate, Translation2d object) { | ||
| return newUpdate.getDistance(object) < previousUpdate.getDistance(object); | ||
| } | ||
|
|
||
| private Translation2d getClosestTrackedObjectToPosition(Translation2d position) { | ||
| return getClosestObjectFromSetToPosition(position, objectPositionsToDetectionTimestamp.keySet()); | ||
| } | ||
|
|
||
| private Translation2d getClosestObjectFromSetToPosition(Translation2d position, Set<Translation2d> objects) { | ||
| if (objects.isEmpty()) | ||
| return null; | ||
| Translation2d closestObjectTranslation = null; | ||
| double closestObjectDistance = Double.MAX_VALUE; | ||
|
|
||
| for (Translation2d object : objects) { | ||
| final double currentObjectDistance = position.getDistance(object); | ||
| if (currentObjectDistance < closestObjectDistance) { | ||
| closestObjectDistance = currentObjectDistance; | ||
| closestObjectTranslation = object; | ||
| } | ||
| } | ||
| return closestObjectTranslation; | ||
| } | ||
|
|
||
| private void removeOldObjects() { | ||
| objectPositionsToDetectionTimestamp.entrySet().removeIf(entry -> hasObjectExpired(entry.getValue())); | ||
| } | ||
|
|
||
| private boolean hasObjectExpired(double timestamp) { | ||
| return Timer.getTimestamp() - timestamp > deletionThresholdSeconds; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| package frc.trigon.robot.misc.objectdetectioncamera; | ||
| package frc.trigon.robot.misc.objectDetection.objectdetectioncamera; | ||
|
|
||
| import edu.wpi.first.math.geometry.*; | ||
| import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
| import frc.trigon.lib.hardware.RobotHardwareStats; | ||
| import frc.trigon.robot.RobotContainer; | ||
| import frc.trigon.robot.misc.objectdetectioncamera.io.PhotonObjectDetectionCameraIO; | ||
| import frc.trigon.robot.misc.objectdetectioncamera.io.SimulationObjectDetectionCameraIO; | ||
| import frc.trigon.robot.misc.objectDetection.objectdetectioncamera.io.PhotonObjectDetectionCameraIO; | ||
| import frc.trigon.robot.misc.objectDetection.objectdetectioncamera.io.SimulationObjectDetectionCameraIO; | ||
| import frc.trigon.robot.misc.simulatedfield.SimulatedGamePieceConstants; | ||
| import org.littletonrobotics.junction.Logger; | ||
| import frc.trigon.lib.hardware.RobotHardwareStats; | ||
|
|
||
| /** | ||
| * An object detection camera is a class that represents a camera that detects objects other than apriltags, most likely game pieces. | ||
|
|
@@ -31,51 +31,52 @@ public void periodic() { | |
| } | ||
|
|
||
| /** | ||
| * Calculates the position of the best object on the field from the 3D rotation of the object relative to the camera. | ||
| * Calculates the position of the closest object on the field from its 3D rotation relative to the camera. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? |
||
| * This assumes the object is on the ground. | ||
| * Once it is known that the object is on the ground, | ||
| * one can simply find the transform from the camera to the ground and apply it to the object's rotation. | ||
| * | ||
| * @return the best object's 2D position on the field (z is assumed to be 0) | ||
| * @return the closest object's 2D position on the field (z is assumed to be 0) | ||
| */ | ||
| public Translation2d calculateBestObjectPositionOnField(SimulatedGamePieceConstants.GamePieceType targetGamePiece) { | ||
| public Translation2d calculateClosestObjectPositionOnField(SimulatedGamePieceConstants.GamePieceType targetGamePiece) { | ||
| final Translation2d[] targetObjectsTranslation = getObjectPositionsOnField(targetGamePiece); | ||
| final Translation2d currentRobotTranslation = RobotContainer.ROBOT_POSE_ESTIMATOR.getEstimatedRobotPose().getTranslation(); | ||
| if (targetObjectsTranslation.length == 0) | ||
| return null; | ||
| Translation2d bestObjectTranslation = targetObjectsTranslation[0]; | ||
| Translation2d closestObjectTranslation = targetObjectsTranslation[0]; | ||
| double closestObjectDistanceToRobot = currentRobotTranslation.getDistance(closestObjectTranslation); | ||
|
|
||
| for (int i = 1; i < targetObjectsTranslation.length; i++) { | ||
| final Translation2d currentObjectTranslation = targetObjectsTranslation[i]; | ||
| final double bestObjectDifference = currentRobotTranslation.getDistance(bestObjectTranslation); | ||
| final double currentObjectDifference = currentRobotTranslation.getDistance(currentObjectTranslation); | ||
| if (currentObjectDifference < bestObjectDifference) | ||
| bestObjectTranslation = currentObjectTranslation; | ||
| for (Translation2d currentObjectTranslation : targetObjectsTranslation) { | ||
| final double currentObjectDistanceToRobot = currentRobotTranslation.getDistance(currentObjectTranslation); | ||
| if (currentObjectDistanceToRobot < closestObjectDistanceToRobot) { | ||
| closestObjectTranslation = currentObjectTranslation; | ||
| closestObjectDistanceToRobot = currentObjectDistanceToRobot; | ||
| } | ||
| } | ||
ShmayaR marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return bestObjectTranslation; | ||
| return closestObjectTranslation; | ||
| } | ||
|
|
||
| public boolean hasTargets(SimulatedGamePieceConstants.GamePieceType targetGamePiece) { | ||
| return objectDetectionCameraInputs.hasTarget[targetGamePiece.id]; | ||
| public boolean hasObject(SimulatedGamePieceConstants.GamePieceType targetGamePiece) { | ||
| return objectDetectionCameraInputs.hasObject[targetGamePiece.id]; | ||
| } | ||
|
|
||
| public Translation2d[] getObjectPositionsOnField(SimulatedGamePieceConstants.GamePieceType targetGamePiece) { | ||
| final Rotation3d[] visibleObjectsRotations = getTargetObjectsRotations(targetGamePiece); | ||
| final Translation2d[] objectsPositionsOnField = new Translation2d[visibleObjectsRotations.length]; | ||
| final Rotation3d[] visibleObjectRotations = getObjectsRotations(targetGamePiece); | ||
| final Translation2d[] objectPositionsOnField = new Translation2d[visibleObjectRotations.length]; | ||
|
|
||
| for (int i = 0; i < visibleObjectsRotations.length; i++) | ||
| objectsPositionsOnField[i] = calculateObjectPositionFromRotation(visibleObjectsRotations[i]); | ||
| for (int i = 0; i < visibleObjectRotations.length; i++) | ||
| objectPositionsOnField[i] = calculateObjectPositionFromRotation(visibleObjectRotations[i]); | ||
|
|
||
| Logger.recordOutput("ObjectDetectionCamera/Visible" + targetGamePiece.name(), objectsPositionsOnField); | ||
| return objectsPositionsOnField; | ||
| Logger.recordOutput("ObjectDetectionCamera/Visible" + targetGamePiece.name(), objectPositionsOnField); | ||
| return objectPositionsOnField; | ||
| } | ||
|
|
||
| public Rotation3d[] getTargetObjectsRotations(SimulatedGamePieceConstants.GamePieceType targetGamePiece) { | ||
| public Rotation3d[] getObjectsRotations(SimulatedGamePieceConstants.GamePieceType targetGamePiece) { | ||
| return objectDetectionCameraInputs.visibleObjectRotations[targetGamePiece.id]; | ||
| } | ||
|
|
||
| /** | ||
| * Calculates the position of the object on the field from the 3D rotation of the object relative to the camera. | ||
| * Calculates the position of an object on the field from its 3D rotation relative to the camera. | ||
| * This assumes the object is on the ground. | ||
| * Once it is known that the object is on the ground, | ||
| * one can simply find the transform from the camera to the ground and apply it to the object's rotation. | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.