WIP: Simple start project for mini simulator #126
@ -28,6 +28,12 @@ const PHASE_X: f32 = 0.0;
|
|||||||
const PHASE_Y: f32 = 0.1;
|
const PHASE_Y: f32 = 0.1;
|
||||||
const PHASE_Z: f32 = 0.2;
|
const PHASE_Z: f32 = 0.2;
|
||||||
|
|
||||||
|
const MGT_GEN_MAGNETIC_FIELD: MgmTuple = MgmTuple {
|
||||||
|
x: 0.03,
|
||||||
|
y: -0.03,
|
||||||
|
z: 0.03,
|
||||||
|
};
|
||||||
|
|
||||||
pub struct MagnetometerModel {
|
pub struct MagnetometerModel {
|
||||||
pub switch_state: SwitchState,
|
pub switch_state: SwitchState,
|
||||||
pub external_mag_field: Option<MgmTuple>,
|
pub external_mag_field: Option<MgmTuple>,
|
||||||
@ -111,8 +117,13 @@ impl PcduModel {
|
|||||||
|
|
||||||
impl Model for PcduModel {}
|
impl Model for PcduModel {}
|
||||||
|
|
||||||
// TODO: How to model this? And how to translate the dipole to the generated magnetic field?
|
// Simple model using i16 values.
|
||||||
pub struct Dipole {}
|
#[derive(Debug, Copy, Clone, PartialEq, Serialize)]
|
||||||
|
pub struct Dipole {
|
||||||
|
pub x: i16,
|
||||||
|
pub y: i16,
|
||||||
|
pub z: i16,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct MagnetorquerModel {
|
pub struct MagnetorquerModel {
|
||||||
switch_state: SwitchState,
|
switch_state: SwitchState,
|
||||||
@ -133,13 +144,19 @@ impl MagnetorquerModel {
|
|||||||
self.switch_state = switch_state;
|
self.switch_state = switch_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn calc_magnetic_field(&self, _: Dipole) -> MgmTuple {
|
||||||
|
// Simplified model: Just returns some fixed magnetic field for now.
|
||||||
|
// Later, we could make this more fancy by incorporating the commanded dipole.
|
||||||
|
MGT_GEN_MAGNETIC_FIELD
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn generate_output(&mut self, _: ()) {
|
pub async fn generate_output(&mut self, _: ()) {
|
||||||
if self.switch_state != SwitchState::On || !self.torquing {
|
if self.switch_state != SwitchState::On || !self.torquing {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO: Calculate generated magnetic field based on dipole.. some really simple model
|
self.gen_magnetic_field
|
||||||
// should suffice here for now.
|
.send(self.calc_magnetic_field(self.torque_dipole.expect("expected valid dipole")))
|
||||||
// self.gen_magnetic_field.send().await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user