the PCDU handler is already required
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good
This commit is contained in:
@ -15,7 +15,7 @@ use satrs_minisim::{
|
||||
|
||||
use crate::time::current_millis;
|
||||
|
||||
// Earth magnetic field varies between -30 uT and 30 uT
|
||||
// Earth magnetic field varies between roughly -30 uT and 30 uT
|
||||
const AMPLITUDE_MGM_UT: f32 = 30.0;
|
||||
// Lets start with a simple frequency here.
|
||||
const FREQUENCY_MGM: f32 = 1.0;
|
||||
@ -26,14 +26,9 @@ const PHASE_Z: f32 = 0.2;
|
||||
|
||||
/// Simple model for a magnetometer where the measure magnetic fields are modeled with sine waves.
|
||||
///
|
||||
/// Please note that that a more realistic MGM model wouold include the following components
|
||||
/// which are not included here to simplify the model:
|
||||
///
|
||||
/// 1. It would probably generate signed [i16] values which need to be converted to SI units
|
||||
/// because it is a digital sensor
|
||||
/// 2. It would sample the magnetic field at a high fixed rate. This might not be possible for
|
||||
/// a general purpose OS, but self self-sampling at a relatively high rate (20-40 ms) might
|
||||
/// stil lbe possible.
|
||||
/// An ideal sensor would sample the magnetic field at a high fixed rate. This might not be
|
||||
/// possible for a general purpose OS, but self self-sampling at a relatively high rate (20-40 ms)
|
||||
/// might still be possible and is probably sufficient for many OBSW needs.
|
||||
pub struct MagnetometerModel<ReplyProvider: MgmReplyProvider> {
|
||||
pub switch_state: SwitchStateBinary,
|
||||
pub periodicity: Duration,
|
||||
|
@ -236,6 +236,7 @@ pub mod acs {
|
||||
y: -30.0,
|
||||
z: 30.0,
|
||||
};
|
||||
pub const ALL_ONES_SENSOR_VAL: i16 = 0xffff_u16 as i16;
|
||||
|
||||
pub mod lis3mdl {
|
||||
use super::*;
|
||||
@ -264,27 +265,39 @@ pub mod acs {
|
||||
|
||||
impl MgmLis3MdlReply {
|
||||
pub fn new(common: MgmReplyCommon) -> Self {
|
||||
let mut raw_reply: [u8; 7] = [0; 7];
|
||||
let raw_x: i16 = (common.sensor_values.x
|
||||
/ (GAUSS_TO_MICROTESLA_FACTOR as f32 * FIELD_LSB_PER_GAUSS_4_SENS))
|
||||
.round() as i16;
|
||||
let raw_y: i16 = (common.sensor_values.y
|
||||
/ (GAUSS_TO_MICROTESLA_FACTOR as f32 * FIELD_LSB_PER_GAUSS_4_SENS))
|
||||
.round() as i16;
|
||||
let raw_z: i16 = (common.sensor_values.z
|
||||
/ (GAUSS_TO_MICROTESLA_FACTOR as f32 * FIELD_LSB_PER_GAUSS_4_SENS))
|
||||
.round() as i16;
|
||||
// The first byte is a dummy byte.
|
||||
raw_reply[1..3].copy_from_slice(&raw_x.to_be_bytes());
|
||||
raw_reply[3..5].copy_from_slice(&raw_y.to_be_bytes());
|
||||
raw_reply[5..7].copy_from_slice(&raw_z.to_be_bytes());
|
||||
Self {
|
||||
common,
|
||||
raw: MgmLis3RawValues {
|
||||
x: raw_x,
|
||||
y: raw_y,
|
||||
z: raw_z,
|
||||
match common.switch_state {
|
||||
SwitchStateBinary::Off => Self {
|
||||
common,
|
||||
raw: MgmLis3RawValues {
|
||||
x: ALL_ONES_SENSOR_VAL,
|
||||
y: ALL_ONES_SENSOR_VAL,
|
||||
z: ALL_ONES_SENSOR_VAL,
|
||||
},
|
||||
},
|
||||
SwitchStateBinary::On => {
|
||||
let mut raw_reply: [u8; 7] = [0; 7];
|
||||
let raw_x: i16 = (common.sensor_values.x
|
||||
/ (GAUSS_TO_MICROTESLA_FACTOR as f32 * FIELD_LSB_PER_GAUSS_4_SENS))
|
||||
.round() as i16;
|
||||
let raw_y: i16 = (common.sensor_values.y
|
||||
/ (GAUSS_TO_MICROTESLA_FACTOR as f32 * FIELD_LSB_PER_GAUSS_4_SENS))
|
||||
.round() as i16;
|
||||
let raw_z: i16 = (common.sensor_values.z
|
||||
/ (GAUSS_TO_MICROTESLA_FACTOR as f32 * FIELD_LSB_PER_GAUSS_4_SENS))
|
||||
.round() as i16;
|
||||
// The first byte is a dummy byte.
|
||||
raw_reply[1..3].copy_from_slice(&raw_x.to_be_bytes());
|
||||
raw_reply[3..5].copy_from_slice(&raw_y.to_be_bytes());
|
||||
raw_reply[5..7].copy_from_slice(&raw_z.to_be_bytes());
|
||||
Self {
|
||||
common,
|
||||
raw: MgmLis3RawValues {
|
||||
x: raw_x,
|
||||
y: raw_y,
|
||||
z: raw_z,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user