9个稳定版本 (4个主要版本)

4.1.0 2024年5月3日
4.0.0 2024年3月13日
3.1.1 2024年2月1日
3.0.0 2023年9月15日
0.1.0 2023年3月10日

#5 in #gmt

每月43次下载
3 个crate 中使用

MIT 许可证

535KB
10K SLoC

gmt_dos-clients_m1-ctrl

Crates.io Documentation

GMT M1控制系统客户端


lib.rs:

M1控制系统

GMT M1控制系统的gmt_dos-actors客户端。

示例

单个段

// 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 gmt_dos_clients::{interface::Size, 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)]
1: hp_setpoint("RBM")[RBM<S1>]
-> hardpoints[HardpointsForces<S1>]
-> loadcell
1: hardpoints[HardpointsForces<S1>]
-> plant[RBM<S1>]$
1: actuators[ActuatorAppliedForces<S1>]
-> plant[HardpointsMotion<S1>]!
-> loadcell
10: actuators_setpoint("Actuators")[ActuatorCommandForces<S1>] -> actuators
10: loadcell[BarycentricForce<S1>]! -> actuators
};

依赖项

~67MB
~1M SLoC