events: combine gravity and forwards fusion sensors into a shared motionframe
This commit is contained in:
@@ -28,8 +28,7 @@ pub struct BikeStates {
|
|||||||
reference_fix: Option<Vector2<f64>>, // The first GPS value, which is used to make sense out of the EKF output which is in meters offset from this point
|
reference_fix: Option<Vector2<f64>>, // The first GPS value, which is used to make sense out of the EKF output which is in meters offset from this point
|
||||||
|
|
||||||
// State switches
|
// State switches
|
||||||
has_down: Breaker<bool>,
|
has_motion_frame: Breaker<bool>,
|
||||||
has_forwards: Breaker<bool>,
|
|
||||||
motion_state: Breaker<MotionState>,
|
motion_state: Breaker<MotionState>,
|
||||||
acquiring_data: Breaker<bool>,
|
acquiring_data: Breaker<bool>,
|
||||||
// FIXME: pub
|
// FIXME: pub
|
||||||
@@ -46,7 +45,6 @@ pub struct BikeStates {
|
|||||||
impl Debug for BikeStates {
|
impl Debug for BikeStates {
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
f.debug_struct("BikeStates")
|
f.debug_struct("BikeStates")
|
||||||
.field("has_down", &self.orientation.has_down())
|
|
||||||
.field("has_orientation", &self.orientation.is_ready())
|
.field("has_orientation", &self.orientation.is_ready())
|
||||||
.field("heading", &self.heading.heading())
|
.field("heading", &self.heading.heading())
|
||||||
.field("motion_state", &self.motion_state)
|
.field("motion_state", &self.motion_state)
|
||||||
@@ -106,10 +104,8 @@ impl BikeStates {
|
|||||||
self.kf.update_zupt();
|
self.kf.update_zupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.has_down.set(true);
|
|
||||||
|
|
||||||
if self.orientation.is_ready() {
|
if self.orientation.is_ready() {
|
||||||
self.has_forwards.set(true);
|
self.has_motion_frame.set(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,17 +114,12 @@ impl BikeStates {
|
|||||||
let last_motion = self.motion_state.value;
|
let last_motion = self.motion_state.value;
|
||||||
|
|
||||||
if let Some(true) = self.acquiring_data.read_tripped() {
|
if let Some(true) = self.acquiring_data.read_tripped() {
|
||||||
predictions.publish(Prediction::SensorStatus(SensorSource::ForwardsReference, SensorState::AcquiringFix)).await;
|
predictions.publish(Prediction::SensorStatus(SensorSource::MotionFrame, SensorState::AcquiringFix)).await;
|
||||||
predictions.publish(Prediction::SensorStatus(SensorSource::GravityReference, SensorState::AcquiringFix)).await;
|
|
||||||
predictions.publish(Prediction::SensorStatus(SensorSource::Location, SensorState::AcquiringFix)).await;
|
predictions.publish(Prediction::SensorStatus(SensorSource::Location, SensorState::AcquiringFix)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(true) = self.has_down.read_tripped() {
|
if let Some(true) = self.has_motion_frame.read_tripped() {
|
||||||
predictions.publish(Prediction::SensorStatus(SensorSource::GravityReference, SensorState::Online)).await
|
predictions.publish(Prediction::SensorStatus(SensorSource::MotionFrame, SensorState::Online)).await
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(true) = self.has_forwards.read_tripped() {
|
|
||||||
predictions.publish(Prediction::SensorStatus(SensorSource::ForwardsReference, SensorState::Online)).await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.has_gps_fix.read_tripped() {
|
match self.has_gps_fix.read_tripped() {
|
||||||
@@ -232,8 +223,7 @@ impl Default for BikeStates {
|
|||||||
last_stamp: Instant::now(),
|
last_stamp: Instant::now(),
|
||||||
speedo: Default::default(),
|
speedo: Default::default(),
|
||||||
heading: Default::default(),
|
heading: Default::default(),
|
||||||
has_down: Default::default(),
|
has_motion_frame: Default::default(),
|
||||||
has_forwards: Default::default(),
|
|
||||||
kf: Default::default(),
|
kf: Default::default(),
|
||||||
steady_timer: IdleClock::new(Duration::from_secs(3)),
|
steady_timer: IdleClock::new(Duration::from_secs(3)),
|
||||||
last_fix: Default::default(),
|
last_fix: Default::default(),
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ impl OrientationEstimator {
|
|||||||
self.forward = Some(Unit::new_unchecked(-unit_forward.into_inner()));
|
self.forward = Some(Unit::new_unchecked(-unit_forward.into_inner()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info!("Found forwards: {unit_forward:?} avg.norm={}", horiz.norm());
|
info!("Motion frame established with forwards={unit_forward:?} avg.norm={} down={:?} bias={:?}", horiz.norm(), self.down, self.sensor_bias);
|
||||||
self.forward = Some(unit_forward);
|
self.forward = Some(unit_forward);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,8 +78,7 @@ pub enum SensorSource {
|
|||||||
Wifi,
|
Wifi,
|
||||||
|
|
||||||
// Fusion outputs
|
// Fusion outputs
|
||||||
GravityReference,
|
MotionFrame,
|
||||||
ForwardsReference,
|
|
||||||
Location,
|
Location,
|
||||||
Cloud,
|
Cloud,
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ const SENSOR_IMAGES: &[SensorImage] = &[
|
|||||||
on: &images::IMU_ON, off: &images::IMU_OFF,
|
on: &images::IMU_ON, off: &images::IMU_OFF,
|
||||||
},
|
},
|
||||||
SensorImage {
|
SensorImage {
|
||||||
source: SensorSource::GravityReference,
|
source: SensorSource::MotionFrame,
|
||||||
on: &images::GRAVITY_LOCATED, off: &images::GRAVITY_MISSING,
|
on: &images::GRAVITY_LOCATED, off: &images::GRAVITY_MISSING,
|
||||||
},
|
},
|
||||||
SensorImage {
|
SensorImage {
|
||||||
|
|||||||
Reference in New Issue
Block a user