This project provides a tool used to optimize the position and angle of a camera on an FRC robot to maximize accurate vision target detection. Users provide the constaints for camera location, a path to follow from pathplanner, and a tag set for vision targets. The tool then simulates various camera positions and angles to determine the optimal setup for the robot's vision system.
- Define camera location constraints (x, y, z, pitch, yaw, distance)
- Input pathplanner paths for robot movement simulation
- Specify vision target tag sets via AprilTagFieldLayout JSON files
- Clone the repository:
git clone https://github.com/1757WestwoodRobotics/camera-pose-finder- Install dependencies:
uv sync - Construct a constraints file in JSON format specifying camera locations and angles to test.
An example file exists at constraints_multi.json.
-
Construct a apriltag field layout JSON file specifying the vision targets. An example file exists at
2025-reefscape-no-barge.json. -
Open this project in PathPlanner and construct an auto routine that uses one or more paths.
-
Run the optimizer with the following command:
uv run src/main.py --constraints path/to/constraints.json --path name_of_auto_routine --tags path/to/apriltag/fieldlayout.jsonFor example
uv run src/main.py --constraints constraints_multi.json --path "dual approach" --tags 2025-reefscape-no-barge.jsonA couple of additional arguments exists:
--mapgenerates an image visualization of the "score" across all possible camera angles--map-resolutioncan be used to specify with what resolution to render the map. The default is to take a sample every 5 degrees
--plotoptimalwhen combined with--mapwill also compute the complete optimal camera location and plot it on the generated map--seperatecan be used to generate seperate results for each camera's angles, compared to the overall optimal. This may be faster if there are many cameras to test
By default, upon completing any ideal computation, a wpilog file will be created. This file can be opened in AdvantageScope to visualize the results of the optimization. It is reccomended to view each camera pose as a camera override.