Skip to content

Commit

Permalink
geht wohl doch irgendwie... glück gehabt
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidma committed May 5, 2024
1 parent 033d63e commit 252fe4b
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 14 deletions.
1 change: 1 addition & 0 deletions crates/code_generation/src/cyclers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fn generate_database_struct() -> TokenStream {
#[derive(
Default,
serde::Serialize,
serde::Deserialize,
path_serde::PathSerialize,
path_serde::PathIntrospect,
)]
Expand Down
1 change: 1 addition & 0 deletions crates/code_generation/src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub fn generate_structs(structs: &Structs) -> TokenStream {
Debug,
Default,
serde::Serialize,
serde::Deserialize,
path_serde::PathSerialize,
path_serde::PathIntrospect,
)]
Expand Down
14 changes: 12 additions & 2 deletions crates/types/src/filtered_game_controller_state.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
use path_serde::{PathIntrospect, PathSerialize};
use path_serde::{PathDeserialize, PathIntrospect, PathSerialize};
use serde::{Deserialize, Serialize};
use spl_network_messages::{GamePhase, Penalty, SubState, Team};

use crate::{filtered_game_state::FilteredGameState, players::Players};

#[derive(Default, Clone, Copy, Debug, Serialize, Deserialize, PathSerialize, PathIntrospect)]
#[derive(
Default,
Clone,
Copy,
Debug,
Serialize,
Deserialize,
PathSerialize,
PathDeserialize,
PathIntrospect,
)]
pub struct FilteredGameControllerState {
pub game_state: FilteredGameState,
pub opponent_game_state: FilteredGameState,
Expand Down
7 changes: 5 additions & 2 deletions crates/types/src/filtered_whistle.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use std::time::SystemTime;

use path_serde::{PathIntrospect, PathSerialize};
use path_serde::{PathDeserialize, PathIntrospect, PathSerialize};
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Default, Deserialize, Serialize, PathSerialize, PathIntrospect)]
#[derive(
Clone, Debug, Default, Deserialize, Serialize, PathSerialize, PathDeserialize, PathIntrospect,
)]
pub struct FilteredWhistle {
pub is_detected: bool,
pub started_this_cycle: bool,
#[path_serde(leaf)]
pub last_detection: Option<SystemTime>,
}
6 changes: 4 additions & 2 deletions crates/types/src/game_controller_state.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use std::time::SystemTime;

use path_serde::{PathIntrospect, PathSerialize};
use path_serde::{PathDeserialize, PathIntrospect, PathSerialize};
use serde::{Deserialize, Serialize};
use spl_network_messages::{GamePhase, GameState, Penalty, SubState, Team};

use crate::players::Players;

#[derive(Clone, Copy, Debug, Serialize, Deserialize, PathSerialize, PathIntrospect)]
#[derive(
Clone, Copy, Debug, Serialize, Deserialize, PathSerialize, PathDeserialize, PathIntrospect,
)]
pub struct GameControllerState {
pub game_state: GameState,
pub game_phase: GamePhase,
Expand Down
11 changes: 10 additions & 1 deletion crates/types/src/penalty_shot_direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@ use path_serde::{PathDeserialize, PathIntrospect, PathSerialize};
use serde::{Deserialize, Serialize};

#[derive(
Clone, Copy, Debug, Deserialize, Serialize, PathSerialize, PathDeserialize, PathIntrospect,
Clone,
Copy,
Default,
Debug,
Deserialize,
Serialize,
PathSerialize,
PathDeserialize,
PathIntrospect,
)]
pub enum PenaltyShotDirection {
#[default]
NotMoving,
Left,
Right,
Expand Down
7 changes: 5 additions & 2 deletions crates/types/src/samples.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use std::sync::Arc;

use path_serde::{PathIntrospect, PathSerialize};
use path_serde::{PathDeserialize, PathIntrospect, PathSerialize};
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Default, Deserialize, Serialize, PathSerialize, PathIntrospect)]
#[derive(
Clone, Debug, Default, Deserialize, Serialize, PathSerialize, PathDeserialize, PathIntrospect,
)]
pub struct Samples {
pub rate: u32,
#[path_serde(leaf)]
pub channels_of_samples: Arc<Vec<Vec<f32>>>,
}
17 changes: 16 additions & 1 deletion crates/types/src/world_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ pub struct WorldState {
pub robot: RobotState,
}

#[derive(Clone, Copy, Debug, Serialize, Deserialize, PathSerialize, PathIntrospect)]
#[derive(
Clone, Copy, Debug, Serialize, Deserialize, PathSerialize, PathDeserialize, PathIntrospect,
)]
pub struct BallState {
pub ball_in_ground: Point2<Ground>,
pub ball_in_field: Point2<Field>,
Expand All @@ -39,6 +41,19 @@ pub struct BallState {
pub field_side: Side,
}

impl Default for BallState {
fn default() -> Self {
Self {
ball_in_ground: Point2::origin(),
ball_in_field: Point2::origin(),
ball_in_ground_velocity: Vector2::zeros(),
last_seen_ball: UNIX_EPOCH,
penalty_shot_direction: Default::default(),
field_side: Side::Left,
}
}
}

impl BallState {
pub fn new_at_center(ground_to_field: Isometry2<Ground, Field>) -> Self {
Self {
Expand Down
7 changes: 5 additions & 2 deletions crates/types/src/ycbcr422_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ use serde::{Deserialize, Serialize};

use coordinate_systems::Pixel;
use linear_algebra::Point2;
use path_serde::{PathIntrospect, PathSerialize};
use path_serde::{PathDeserialize, PathIntrospect, PathSerialize};

use crate::{
color::{Rgb, YCbCr422, YCbCr444},
jpeg::JpegImage,
};

#[derive(Clone, Debug, Default, Deserialize, Serialize, PathSerialize, PathIntrospect)]
#[derive(
Clone, Debug, Default, Deserialize, Serialize, PathSerialize, PathIntrospect, PathDeserialize,
)]
#[path_serde(add_leaf(jpeg: JpegImage))]
pub struct YCbCr422Image {
width_422: u32,
height: u32,
#[path_serde(leaf)]
buffer: Arc<Vec<YCbCr422>>,
}

Expand Down
4 changes: 2 additions & 2 deletions tools/behavior_simulator/src/cycler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use control::{

use framework::{AdditionalOutput, PerceptionInput};
use path_serde::{PathIntrospect, PathSerialize};
use serde::Serialize;
use serde::{Deserialize, Serialize};
use tokio::sync::Notify;
use types::messages::IncomingMessage;

Expand All @@ -28,7 +28,7 @@ use crate::{
},
};

#[derive(Clone, Default, Serialize, PathSerialize, PathIntrospect)]
#[derive(Clone, Default, Deserialize, Serialize, PathSerialize, PathIntrospect)]
pub struct Database {
pub main_outputs: MainOutputs,
pub additional_outputs: AdditionalOutputs,
Expand Down

0 comments on commit 252fe4b

Please sign in to comment.