gmt_dos_systems_agws/lib.rs
1/*!
2# GMT AGWS Integrated Model
3
4A [gmt_dos-actors] [system] that models the optical paths from the AGWS guide stars through the GMT to the Shack-Hartmann wavefront sensors (WFS) 48x48 and 24x24.
5The model includes [kernels] that compute the WFS centroids from the frames of the cameras, transform the centroids in commmands for M1 and M2 segments and apply temporal filters to the commands.
6
7## Examples
8
9 1. Building an optical model for the 3 AGWS 48x48 Shack-Hartmann wavefront sensors:
10```
11use gmt_dos_clients_crseo::{
12 OpticalModelBuilder,
13 sensors::builders::CameraBuilder,
14 calibration::Reconstructor};
15use gmt_dos_systems_agws::builder::shack_hartmann::ShackHartmannBuilder;
16
17let sh48 = ShackHartmannBuilder::<Reconstructor>::sh48().use_calibration_src();
18let omb = OpticalModelBuilder::<CameraBuilder>::from(&sh48);
19println!("{}", omb.clone().build()?);
20# Ok::<(),Box<dyn std::error::Error>>(())
21```
22
23 2. Building an optical model for the AGWS 24x24 Shack-Hartmann wavefront sensor:
24```
25use gmt_dos_clients_crseo::{
26 OpticalModelBuilder,
27 sensors::builders::CameraBuilder,
28 calibration::Reconstructor};
29use gmt_dos_systems_agws::builder::shack_hartmann::ShackHartmannBuilder;
30
31let sh24 = ShackHartmannBuilder::<Reconstructor>::sh24().use_calibration_src();
32let omb = OpticalModelBuilder::<CameraBuilder>::from(&sh24);
33println!("{}", omb.clone().build()?);
34# Ok::<(),Box<dyn std::error::Error>>(())
35```
36 3. Building the default AGWS systems: one 24x24 and three 48x48 SH WFSs
37 ```
38use gmt_dos_systems_agws::Agws;
39
40let agws = Agws::<5000,5>::builder().build()?;
41# Ok::<(),Box<dyn std::error::Error>>(())
42 ```
43
44[gmt_dos-actors]: https://docs.rs/gmt_dos-actors
45[system]: https://docs.rs/gmt_dos-actors/system
46*/
47
48pub mod agws;
49pub mod builder;
50pub mod kernels;
51#[cfg(feature = "qp")]
52pub mod qp;
53#[doc(inline)]
54pub use agws::Agws;
55#[doc(inline)]
56pub use builder::AgwsBuilder;
57
58#[cfg(test)]
59mod tests {
60
61 use builder::shack_hartmann::ShackHartmannBuilder;
62
63 use gmt_dos_clients_io::optics::{Frame, Host};
64 use interface::{Update, Write};
65 use skyangle::Conversion;
66
67 #[cfg(feature = "qp")]
68 use crate::qp::ActiveOptics;
69
70 use super::*;
71
72 #[test]
73 fn builder() {
74 let _ = Agws::<1, 1>::builder().build();
75 }
76
77 #[cfg(feature = "qp")]
78 #[test]
79 fn aco_builder() {
80 let _ = Agws::<1, 1, ActiveOptics<1, 41, 41, 27, 271>>::builder().build();
81 }
82
83 #[tokio::test(flavor = "multi_thread")]
84 async fn sh24() {
85 let mut agws = Agws::<1, 1>::builder()
86 .sh24(ShackHartmannBuilder::sh24().use_calibration_src())
87 .build()
88 .unwrap();
89 println!("{}", agws.sh24.client().lock().await);
90 agws.sh24_pointing((4f64.from_arcmin() + 4000f64.from_mas(), 180f64.to_radians()))
91 .await;
92 agws.sh24.client().lock().await.update();
93 let frame =
94 <_ as Write<Frame<Host>>>::write(&mut *agws.sh24.client().lock().await).unwrap();
95 let n_px = 24 * 12;
96 let _: complot::Heatmap = ((frame.as_arc().as_slice(), (n_px, n_px)), None).into();
97 }
98}