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

Automatic Callibration (Der dessen name nicht genannt werden darf) #695

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
306 changes: 262 additions & 44 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,17 @@ hula-types = { path = "tools/hula/types" }
hulk = { path = "crates/hulk" }
i2cdev = "0.5.1"
image = "0.24.4"
imageproc = "0.23.0"
indicatif = "0.17.2"
itertools = "0.10.5"
itertools = "0.11.0"
ittapi = "0.3.3"
kinematics = { path = "crates/kinematics" }
once_cell = "1.19.0"
lazy_static = "1.4.0"
levenberg-marquardt = "0.13.0"
libc = "0.2.137"
log = "0.4.17"
lstsq = "0.5.0"
mlua = { version = "0.8.7", features = ["luajit", "serialize", "parking_lot"] }
motionfile = { path = "crates/motionfile" }
nalgebra = { version = "0.32.2", features = ["serde", "serde-serialize"] }
Expand Down
4 changes: 4 additions & 0 deletions crates/calibration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ license.workspace = true
homepage.workspace = true

[dependencies]
image = { workspace = true }
imageproc = { workspace = true }
levenberg-marquardt = { workspace = true }
nalgebra = { workspace = true }
projection = { workspace = true }
serde = { workspace = true }
serialize_hierarchy = { workspace = true }
thiserror = { workspace = true }
types = { workspace = true }
13 changes: 9 additions & 4 deletions crates/calibration/src/lines.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
use nalgebra::Point2;
use projection::Projection;
use serde::{Deserialize, Serialize};
use serialize_hierarchy::SerializeHierarchy;
use types::{
camera_matrix::CameraMatrix,
line::{Line, Line2},
};

#[derive(Clone)]
pub struct Lines {
#[derive(Clone, Debug, Deserialize, Serialize, SerializeHierarchy)]
pub struct GoalBoxCalibrationLines {
#[serialize_hierarchy(leaf)]
pub border_line: Line2,
#[serialize_hierarchy(leaf)]
pub goal_box_line: Line2,
#[serialize_hierarchy(leaf)]
pub connecting_line: Line2,
}

impl Lines {
impl GoalBoxCalibrationLines {
pub fn to_projected(&self, matrix: &CameraMatrix) -> Result<Self, LinesError> {
Ok(Lines {
Ok(GoalBoxCalibrationLines {
border_line: project_line_and_map_error(matrix, self.border_line, "border line")?,
goal_box_line: project_line_and_map_error(matrix, self.goal_box_line, "goal box line")?,
connecting_line: project_line_and_map_error(
Expand Down
4 changes: 2 additions & 2 deletions crates/calibration/src/measurement.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use types::{camera_matrix::CameraMatrix, camera_position::CameraPosition};

use crate::lines::Lines;
use crate::lines::GoalBoxCalibrationLines;

#[derive(Clone)]
pub struct Measurement {
pub position: CameraPosition,
pub matrix: CameraMatrix,
pub lines: Lines,
pub lines: GoalBoxCalibrationLines,
}
3 changes: 2 additions & 1 deletion crates/hulk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ homepage.workspace = true
[dependencies]
audio = { workspace = true }
bincode = { workspace = true }
calibration = { workspace = true }
color-eyre = { workspace = true }
communication = { workspace = true, features = ["server"] }
control = { workspace = true }
framework = { workspace = true }
geometry = { workspace = true }
hardware = { workspace = true }
ittapi = { workspace = true }
ittapi = { workspace = true }
nalgebra = { workspace = true }
serde = { workspace = true }
serialize_hierarchy = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/hulk/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fn main() -> Result<()> {
nodes: vec![
"vision::ball_detection",
"vision::camera_matrix_extractor",
"vision::calibration_line_detection",
"vision::feet_detection",
"vision::field_border_detection",
"vision::field_color_detection",
Expand Down
44 changes: 43 additions & 1 deletion crates/types/src/parameters.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::ops::{Index, Range};
use std::{path::PathBuf, time::Duration};

use nalgebra::{Point2, Vector2, Vector3, Vector4};
use nalgebra::{Point2, Point3, Vector2, Vector3, Vector4};
use serde::{Deserialize, Serialize};
use serialize_hierarchy::SerializeHierarchy;

Expand Down Expand Up @@ -363,3 +363,45 @@ pub struct FallProtectionParameters {
pub arm_stiffness: f32,
pub leg_stiffness: f32,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize, SerializeHierarchy)]
pub struct ProjectedLimbs {
pub torso_bounding_polygon: Vec<Point3<f32>>,
pub lower_arm_bounding_polygon: Vec<Point3<f32>>,
pub upper_arm_bounding_polygon: Vec<Point3<f32>>,
pub knee_bounding_polygon: Vec<Point3<f32>>,
pub foot_bounding_polygon: Vec<Point3<f32>>,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize, SerializeHierarchy)]
pub struct RobotDetection {
pub enable: bool,
pub amount_of_segments_factor: f32,
pub amount_score_exponent: f32,
pub cluster_cone_radius: f32,
pub cluster_distance_score_range: Range<f32>,
pub detection_box_width: f32,
pub ignore_ball_segments: bool,
pub ignore_line_segments: bool,
pub luminance_score_exponent: f32,
pub maximum_cluster_distance: f32,
pub minimum_cluster_score: f32,
pub minimum_consecutive_segments: usize,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize, SerializeHierarchy)]
pub struct PenaltyShotDirectionEstimation {
pub moving_distance_threshold: f32,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize, SerializeHierarchy)]
pub struct CalibrationLineDetection {
pub enable: bool,
pub canny_low_threshold: f32,
pub canny_high_threshold: f32,
pub gaussian_sigma: f32,
pub maximum_number_of_lines: usize,
pub ransac_iterations: usize,
pub ransac_maximum_distance: f32,
pub ransac_maximum_gap: f32,
}
4 changes: 4 additions & 0 deletions crates/vision/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ homepage.workspace = true

[dependencies]
approx = { workspace = true }
calibration = { workspace = true }
color-eyre = { workspace = true }
compiled-nn = { workspace = true }
context_attribute = { workspace = true }
Expand All @@ -15,7 +16,10 @@ filtering = { workspace = true }
framework = { workspace = true }
geometry = { workspace = true }
hardware = { workspace = true }
image = { workspace = true }
imageproc = { workspace = true }
itertools = { workspace = true }
lstsq = { workspace = true }
nalgebra = { workspace = true }
ordered-float = { workspace = true }
projection = { workspace = true }
Expand Down
Loading