10 stable releases (4 major)
4.1.1 | Oct 30, 2024 |
---|---|
4.1.0 | May 3, 2024 |
4.0.0 | Mar 13, 2024 |
3.1.1 | Feb 1, 2024 |
0.1.0 | Mar 10, 2023 |
#4 in #gmt
151 downloads per month
Used in 3 crates
3MB
11K
SLoC
gmt_dos-clients_m1-ctrl
A client for the GMT M1 control system.
lib.rs
:
M1 control system
A gmt_dos-actors client for the GMT M1 control system.
Examples
Single segment
// Dependencies:
// * tokio
// * gmt_dos_actors
// * gmt_dos_clients
// * gmt_dos_clients_io
// * gmt_dos_clients_fem
// * gmt-fem
// * gmt_dos_clients_m1_ctrl
// Environment variables:
// * FEM_REPO
use gmt_dos_actors::actorscript;
use interface::Size;
use gmt_dos_clients::{Logging, Signal, Signals};
use gmt_dos_clients_fem::{fem_io::actors_inputs::*, fem_io::actors_outputs::*};
use gmt_dos_clients_fem::{DiscreteModalSolver, ExponentialMatrix};
use gmt_dos_clients_io::gmt_m1::segment::{
ActuatorAppliedForces, ActuatorCommandForces, BarycentricForce, HardpointsForces,
HardpointsMotion, RBM,
};
use gmt_dos_clients_m1_ctrl::{Actuators, Calibration, Hardpoints, LoadCells};
use gmt_fem::FEM;
const S1: u8 = 1;
let sim_sampling_frequency = 1000;
let sim_duration = 10_usize; // second
let n_step = sim_sampling_frequency * sim_duration;
let mut whole_fem = FEM::from_env()?;
let m1_calibration = Calibration::new(&mut whole_fem);
let plant = DiscreteModalSolver::<ExponentialMatrix>::from_fem(whole_fem)
.sampling(sim_sampling_frequency as f64)
.proportional_damping(2. / 100.)
.including_m1(Some(vec![1]))?
.outs::<OSSM1Lcl>()
.use_static_gain_compensation()
.build()?;
let rbm_fun = |i| (-1f64).powi(i as i32) * (1 + (i % 3)) as f64;
let hp_setpoint = (0..6).fold(Signals::new(6, n_step), |signals, i| {
signals.channel(
i,
Signal::Sigmoid {
amplitude: rbm_fun(i) * 1e-6,
sampling_frequency_hz: sim_sampling_frequency as f64,
},
)
});
// Hardpoints
let hardpoints = Hardpoints::new(
m1_calibration.stiffness,
m1_calibration.rbm_2_hp[S1 as usize - 1],
);
// Loadcells
let loadcell = LoadCells::new(
m1_calibration.stiffness,
m1_calibration.lc_2_cg[S1 as usize - 1],
);
// Actuators
let actuators = Actuators::<S1>::new();
let actuators_setpoint = Signals::new(
Size::<ActuatorCommandForces<S1>>::len(&Actuators::<S1>::new()),
n_step,
);
actorscript! {
#[model(state=completed)]
#[labels(hp_setpoint="RBM",actuators_setpoint="Actuators")]
1: hp_setpoint[RBM<S1>]
-> hardpoints[HardpointsForces<S1>]
-> loadcell
1: hardpoints[HardpointsForces<S1>]
-> plant[RBM<S1>]$
1: actuators[ActuatorAppliedForces<S1>]
-> plant[HardpointsMotion<S1>]!
-> loadcell
10: actuators_setpoint[ActuatorCommandForces<S1>] -> actuators
10: loadcell[BarycentricForce<S1>]! -> actuators
};
Dependencies
~69MB
~1M SLoC