This commit is contained in:
parent
db814189a0
commit
f813bcf948
@ -28,6 +28,12 @@ const PHASE_X: f32 = 0.0;
|
||||
const PHASE_Y: f32 = 0.1;
|
||||
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 switch_state: SwitchState,
|
||||
pub external_mag_field: Option<MgmTuple>,
|
||||
@ -111,8 +117,13 @@ impl PcduModel {
|
||||
|
||||
impl Model for PcduModel {}
|
||||
|
||||
// TODO: How to model this? And how to translate the dipole to the generated magnetic field?
|
||||
pub struct Dipole {}
|
||||
// Simple model using i16 values.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize)]
|
||||
pub struct Dipole {
|
||||
pub x: i16,
|
||||
pub y: i16,
|
||||
pub z: i16,
|
||||
}
|
||||
|
||||
pub struct MagnetorquerModel {
|
||||
switch_state: SwitchState,
|
||||
@ -133,13 +144,19 @@ impl MagnetorquerModel {
|
||||
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, _: ()) {
|
||||
if self.switch_state != SwitchState::On || !self.torquing {
|
||||
return;
|
||||
}
|
||||
// TODO: Calculate generated magnetic field based on dipole.. some really simple model
|
||||
// should suffice here for now.
|
||||
// self.gen_magnetic_field.send().await;
|
||||
self.gen_magnetic_field
|
||||
.send(self.calc_magnetic_field(self.torque_dipole.expect("expected valid dipole")))
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user