build: move the int/stream type mapping into a simdata module shared by the build script

This commit is contained in:
2025-12-24 09:59:12 +01:00
parent 2630c97609
commit 83e4614d10
5 changed files with 54 additions and 22 deletions

View File

@@ -5,7 +5,7 @@ use enum_map::Enum;
use enumset::EnumSetType;
use nalgebra::{Vector2, Vector3};
use crate::ego::engine::MotionState;
use crate::{ego::engine::MotionState, simdata::StreamType};
#[derive(Clone, Copy, Default, Debug)]
pub enum Scene {
@@ -91,29 +91,26 @@ pub enum Notification {
#[derive(Debug, EnumSetType, Enum)]
pub enum SensorSource {
// Real hardware
IMU = 1,
GPS = 2,
IMU,
GPS,
// Fusion outputs
GravityReference = 100,
GravityReference,
ForwardsReference,
Location,
// Simulated sensors
Demo,
Simulation,
Annotations = 3
Annotations
}
impl TryFrom<i8> for SensorSource {
type Error = ();
fn try_from(value: i8) -> Result<Self, Self::Error> {
impl From<StreamType> for SensorSource {
fn from(value: StreamType) -> Self {
match value {
1 => Ok(SensorSource::IMU),
2 => Ok(SensorSource::GPS),
3 => Ok(SensorSource::Annotations),
_ => Err(())
StreamType::Annotations => Self::Annotations,
StreamType::GPS => Self::GPS,
StreamType::IMU => Self::IMU
}
}
}