Add all flags and remap channels in target mapping
Added everything needed to have target mapping working from input to
output with the engineering room log.
Signed-off-by: milind-u <milind.upadhyay@gmail.com>
Change-Id: Ifedb3b4cd3d0cede8f1f9599e3bdb0b43e795f74
diff --git a/y2023/vision/BUILD b/y2023/vision/BUILD
index a0b0ce5..724bdc0 100644
--- a/y2023/vision/BUILD
+++ b/y2023/vision/BUILD
@@ -43,6 +43,8 @@
],
data = [
"//y2023:aos_config",
+ "//y2023/constants:constants.json",
+ "//y2023/vision:maps",
],
target_compatible_with = ["@platforms//os:linux"],
visibility = ["//y2023:__subpackages__"],
@@ -58,6 +60,7 @@
"//frc971/vision:target_mapper",
"//third_party:opencv",
"//y2023/constants:constants_fbs",
+ "//y2023/constants:simulated_constants_sender",
],
)
diff --git a/y2023/vision/aprilrobotics.cc b/y2023/vision/aprilrobotics.cc
index b132f85..caa3aae 100644
--- a/y2023/vision/aprilrobotics.cc
+++ b/y2023/vision/aprilrobotics.cc
@@ -6,7 +6,7 @@
debug, false,
"If true, dump a ton of debug and crash on the first valid detection.");
-DEFINE_double(min_decision_margin, 30.0,
+DEFINE_double(min_decision_margin, 75.0,
"Minimum decision margin (confidence) for an apriltag detection");
namespace y2023 {
diff --git a/y2023/vision/aprilrobotics.h b/y2023/vision/aprilrobotics.h
index bbc1661..840ec71 100644
--- a/y2023/vision/aprilrobotics.h
+++ b/y2023/vision/aprilrobotics.h
@@ -18,8 +18,6 @@
#include "third_party/apriltag/tag16h5.h"
#include "y2023/constants/constants_generated.h"
-DECLARE_int32(team_number);
-
namespace y2023 {
namespace vision {
diff --git a/y2023/vision/maps/README.md b/y2023/vision/maps/README.md
new file mode 100644
index 0000000..eed093a
--- /dev/null
+++ b/y2023/vision/maps/README.md
@@ -0,0 +1,5 @@
+Targets have positive Z axis pointing into the board, positive X to the right when looking at the board,
+and positive Y is down when looking at the board.
+This means that you will get an identity rotation from the camera to target
+frame when the target is upright, flat, and centered in the camera's view for an upright camera.
+For 2023 cameras, the target needs to be upside down for the identity rotation because the cameras are flipped.
diff --git a/y2023/vision/maps/target_map.json b/y2023/vision/maps/target_map.json
index 2aa1995..8d971f3 100644
--- a/y2023/vision/maps/target_map.json
+++ b/y2023/vision/maps/target_map.json
@@ -1,7 +1,3 @@
-/* Targets have positive Z axis pointing into the board, positive X to the right
- when looking at the board, and positive Y is down when looking at the board.
- This means that you will get an identity rotation from the camera to target
- frame when the target is upright, flat, and centered in the camera's view.*/
{
"target_poses": [
{
diff --git a/y2023/vision/target_mapping.cc b/y2023/vision/target_mapping.cc
index b41d7d5..a941923 100644
--- a/y2023/vision/target_mapping.cc
+++ b/y2023/vision/target_mapping.cc
@@ -12,12 +12,20 @@
#include "opencv2/highgui.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc.hpp"
+#include "y2023/constants/simulated_constants_sender.h"
#include "y2023/vision/aprilrobotics.h"
#include "y2023/vision/vision_util.h"
-DEFINE_string(json_path, "target_map.json",
+DEFINE_string(json_path, "y2023/vision/maps/target_map.json",
"Specify path for json with initial pose guesses.");
-DECLARE_int32(team_number);
+DEFINE_string(constants_path, "y2023/constants/constants.json",
+ "Path to the constant file");
+DEFINE_string(output_dir, "y2023/vision/maps",
+ "Directory to write solved target map to");
+DEFINE_string(field_name, "charged_up",
+ "Field name, for the output json filename and flatbuffer field");
+DEFINE_int32(team_number, 7971,
+ "Use the calibration for a node with this team number");
namespace y2023 {
namespace vision {
@@ -112,10 +120,19 @@
for (size_t i = 1; i <= kNumPis; i++) {
reader.RemapLoggedChannel(absl::StrFormat("/pi%u/camera", i),
"frc971.vision.TargetMap");
+ reader.RemapLoggedChannel(absl::StrFormat("/pi%u/camera", i),
+ "foxglove.ImageAnnotations");
+ reader.RemapLoggedChannel(absl::StrFormat("/pi%u/constants", i),
+ "y2023.Constants");
}
+ reader.RemapLoggedChannel("/imu/constants", "y2023.Constants");
+
reader.Register();
+ SendSimulationConstants(reader.event_loop_factory(), FLAGS_team_number,
+ FLAGS_constants_path);
+
std::vector<std::unique_ptr<AprilRoboticsDetector>> detectors;
const aos::Node *pi1 =
@@ -160,7 +177,7 @@
DataAdapter::MatchTargetDetections(timestamped_target_detections);
frc971::vision::TargetMapper mapper(FLAGS_json_path, target_constraints);
- mapper.Solve("charged_up");
+ mapper.Solve(FLAGS_field_name, FLAGS_output_dir);
// Clean up all the pointers
for (auto &detector_ptr : detectors) {