Skip to content
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

Line with SerializedHierarchy #793

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/calibration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ levenberg-marquardt = { workspace = true }
linear_algebra = { workspace = true }
nalgebra = { workspace = true }
projection = { workspace = true }
serde = { workspace = true }
serialize_hierarchy = { workspace = true }
thiserror = { workspace = true }
types = { workspace = true }
10 changes: 6 additions & 4 deletions crates/calibration/src/lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ use coordinate_systems::{Ground, Pixel};
use geometry::line::{Line, Line2};
use linear_algebra::Point2;
use projection::Projection;
use serde::{Deserialize, Serialize};
use serialize_hierarchy::SerializeHierarchy;
use types::camera_matrix::CameraMatrix;

#[derive(Clone)]
#[derive(Clone, Default, Debug, Deserialize, Serialize, SerializeHierarchy)]
pub struct Lines<Frame> {
pub border_line: Line2<Frame>,
pub goal_box_line: Line2<Frame>,
Expand Down Expand Up @@ -39,9 +41,9 @@ fn project_line_and_map_error(
line: Line2<Pixel>,
which: &str,
) -> Result<Line2<Ground>, LinesError> {
Ok(Line(
project_point_and_map_error(matrix, line.0, format!("{which} point 0"))?,
project_point_and_map_error(matrix, line.1, format!("{which} point 1"))?,
Ok(Line::new(
project_point_and_map_error(matrix, line.first, format!("{which} point 0"))?,
project_point_and_map_error(matrix, line.second, format!("{which} point 1"))?,
))
}

Expand Down
4 changes: 3 additions & 1 deletion crates/calibration/src/measurement.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use coordinate_systems::Pixel;
use serde::{Deserialize, Serialize};
use serialize_hierarchy::SerializeHierarchy;
use types::{camera_matrix::CameraMatrix, camera_position::CameraPosition};

use crate::lines::Lines;

#[derive(Clone)]
#[derive(Clone, Debug, Default, Deserialize, Serialize, SerializeHierarchy)]
pub struct Measurement {
pub position: CameraPosition,
pub matrix: CameraMatrix,
Expand Down
4 changes: 2 additions & 2 deletions crates/calibration/src/residuals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ impl Residuals {
.signed_acute_angle_to_orthogonal(projected_lines.connecting_line);
let distance_between_parallel_line_start_points = projected_lines
.border_line
.distance_to_point(projected_lines.goal_box_line.0);
.distance_to_point(projected_lines.goal_box_line.first);
let distance_between_parallel_line_center_points = projected_lines
.border_line
.distance_to_point(projected_lines.goal_box_line.center());
let distance_between_parallel_line_end_points = projected_lines
.border_line
.distance_to_point(projected_lines.goal_box_line.1);
.distance_to_point(projected_lines.goal_box_line.second);

Ok(Residuals {
border_to_connecting_angle,
Expand Down
4 changes: 2 additions & 2 deletions crates/control/src/behavior/defend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ fn block_on_line(
) -> Pose2<Field> {
let is_ball_in_front_of_defense_line = defense_line_x < ball_position.x();
if is_ball_in_front_of_defense_line {
let defense_line = Line(
let defense_line = Line::new(
point![defense_line_x, defense_line_y_range.start],
point![defense_line_x, defense_line_y_range.end],
);
let ball_target_line = Line(ball_position, target);
let ball_target_line = Line::new(ball_position, target);
let intersection_point = defense_line.intersection(&ball_target_line);
let defense_position = point![
intersection_point.x(),
Expand Down
2 changes: 1 addition & 1 deletion crates/control/src/behavior/intercept_ball.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn execute(
return None;
}

let ball_line = Line(
let ball_line = Line::new(
ball.ball_in_ground,
ball.ball_in_ground + ball.ball_in_ground_velocity,
);
Expand Down
10 changes: 5 additions & 5 deletions crates/control/src/camera_matrix_calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ fn project_penalty_area_on_images(
.ok()?;

Some(vec![
Line(penalty_top_left, penalty_top_right),
Line(penalty_bottom_left, penalty_bottom_right),
Line(penalty_bottom_left, penalty_top_left),
Line(penalty_bottom_right, penalty_top_right),
Line(corner_left, corner_right),
Line::new(penalty_top_left, penalty_top_right),
Line::new(penalty_bottom_left, penalty_bottom_right),
Line::new(penalty_bottom_left, penalty_top_left),
Line::new(penalty_bottom_right, penalty_top_right),
Line::new(corner_left, corner_right),
])
}
Loading
Loading