COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
sutra_rtc.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 // This file is part of COMPASS <https://anr-compass.github.io/compass/>
3 //
4 // Copyright (C) 2011-2019 COMPASS Team <https://github.com/ANR-COMPASS>
5 // All rights reserved.
6 // Distributed under GNU - LGPL
7 //
8 // COMPASS is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser
9 // General Public License as published by the Free Software Foundation, either version 3 of the License,
10 // or any later version.
11 //
12 // COMPASS: End-to-end AO simulation tool using GPU acceleration
13 // The COMPASS platform was designed to meet the need of high-performance for the simulation of AO systems.
14 //
15 // The final product includes a software package for simulating all the critical subcomponents of AO,
16 // particularly in the context of the ELT and a real-time core based on several control approaches,
17 // with performances consistent with its integration into an instrument. Taking advantage of the specific
18 // hardware architecture of the GPU, the COMPASS tool allows to achieve adequate execution speeds to
19 // conduct large simulation campaigns called to the ELT.
20 //
21 // The COMPASS platform can be used to carry a wide variety of simulations to both testspecific components
22 // of AO of the E-ELT (such as wavefront analysis device with a pyramid or elongated Laser star), and
23 // various systems configurations such as multi-conjugate AO.
24 //
25 // COMPASS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
26 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 // See the GNU Lesser General Public License for more details.
28 //
29 // You should have received a copy of the GNU Lesser General Public License along with COMPASS.
30 // If not, see <https://www.gnu.org/licenses/lgpl-3.0.txt>.
31 // -----------------------------------------------------------------------------
32 
41 
42 #ifndef _SUTRA_RTC_H_
43 #define _SUTRA_RTC_H_
44 
45 #include <sutra_centroider_bpcog.h>
46 #include <sutra_centroider_cog.h>
47 #include <sutra_centroider_corr.h>
49 #include <sutra_centroider_pyr.h>
50 #include <sutra_centroider_tcog.h>
51 #include <sutra_centroider_wcog.h>
52 #include <sutra_controller_cured.h>
54 #include <sutra_controller_geo.h>
55 //#include <sutra_controller_kalman.h>
56 #include <sutra_controller_ls.h>
57 #include <sutra_controller_mv.h>
58 
59 template <typename Tin, typename T, typename Tout>
60 class SutraRtc {
61  public:
62  vector<SutraCentroider<Tin, T> *> d_centro;
63  vector<SutraController<T, Tout> *> d_control;
64 
65  public:
68  int add_centroider(CarmaContext *context, long nvalid, float offset,
69  float scale, bool filter_TT, long device,
70  std::string typec);
71 
72  int add_centroider(CarmaContext *context, long nvalid, float offset,
73  float scale, bool filter_TT, long device,
74  std::string typec, SutraWfs *wfs);
75 
76  int add_controller(CarmaContext *context, int nvalid, int nslope, int nactu,
77  float delay, long device, std::string typec,
78  SutraDms *dms = nullptr, int *idx_dms = nullptr,
79  int ndm = 0, int *idx_centro = nullptr, int ncentro = 0,
80  int Nphi = 0, bool wfs_direction = false, int nstates = 0);
81 
82  int remove_centroider(int ncentro);
83  int remove_controller(int ncontrol);
84 
85  int do_imat(int ncntrl, SutraDms *ydms);
86 
87  int do_imat_basis(int ncntrl, SutraDms *ydm, int nModes, T *m2v,
88  T *pushAmpl);
89 
90  int do_imat_geom(int ncntrl, SutraDms *ydm, int type);
91 
93 
95  int do_calibrate_img(int ncntrl);
96  int do_centroids();
97  int do_centroids(int ncntrl);
98  int do_centroids(int ncntrl, bool noise);
99  int do_centroids_geom(int ncntrl);
100  int do_centroids_ref(int ncntrl);
101  int do_control(int ncntrl);
102  int do_clipping(int ncntrl);
103  int apply_control(int ncntrl, bool compVoltage = true);
104  int comp_voltage(int ncntrl);
105  int remove_ref(int ncntrl);
106  int set_centroids_ref(float *centroids_ref);
107 
108  private:
109  template <typename Q = T>
110  typename std::enable_if<std::is_same<Q, float>::value, int>::type
111  do_imat_impl(int ncntrl, SutraDms *ydm, std::true_type);
112  int do_imat_impl(int ncntrl, SutraDms *ydm, std::false_type);
113 
114  template <typename Q = T>
115  typename std::enable_if<std::is_same<Q, float>::value, int>::type
116  do_imat_basis_impl(int ncntrl, SutraDms *ydm, int nModes, T *m2v,
117  T *pushAmpl, std::true_type);
118  int do_imat_basis_impl(int ncntrl, SutraDms *ydm, int nModes, T *m2v,
119  T *pushAmpl, std::false_type);
120  template <typename Q = T>
121  typename std::enable_if<std::is_same<Q, float>::value, int>::type
122  do_imat_geom_impl(int ncntrl, SutraDms *ydm, int type, std::true_type);
123  int do_imat_geom_impl(int ncntrl, SutraDms *ydm, int type, std::false_type);
124 
125  template <typename Q = T>
126  typename std::enable_if<std::is_same<Q, float>::value, int>::type
127  do_centroids_geom_impl(int ncntrl, std::true_type);
128  int do_centroids_geom_impl(int ncntrl, std::false_type);
129 
130  template <typename Q = T>
131  typename std::enable_if<!std::is_same<Q, half>::value, int>::type
132  add_centroider_impl(CarmaContext *context, long nvalid, float offset,
133  float scale, bool filter_TT, long device,
134  std::string typec, SutraWfs *wfs, std::false_type);
135  int add_centroider_impl(CarmaContext *context, long nvalid, float offset,
136  float scale, bool filter_TT, long device,
137  std::string typec, SutraWfs *wfs, std::true_type);
138 
139  template <typename Q = T>
140  typename std::enable_if<!std::is_same<Q, half>::value, int>::type
141  add_controller_impl(CarmaContext *context,
143  int nvalid, int nslope, int nactu, float delay,
144  long device, std::string typec, SutraDms *dms,
145  int *idx_dms, int ndm, int *idx_centro, int ncentro,
146  int Nphi, bool wfs_direction, int nstates,
147  std::false_type);
148  int add_controller_impl(CarmaContext *context,
150  int nvalid, int nslope, int nactu, float delay,
151  long device, std::string typec, SutraDms *dms,
152  int *idx_dms, int ndm, int *idx_centro, int ncentro,
153  int Nphi, bool wfs_direction, int nstates,
154  std::true_type);
155 };
156 
157 #endif // _SUTRA_RTC_H_
SutraRtc::comp_voltage
int comp_voltage(int ncntrl)
sutra_controller_geo.h
SutraRtc::comp_images_imat
int comp_images_imat(SutraDms *ydm)
SutraRtc::do_centroids_geom
int do_centroids_geom(int ncntrl)
sutra_centroider_tcog.h
SutraDms
Definition: sutra_dm.h:164
SutraRtc::d_centro
vector< SutraCentroider< Tin, T > * > d_centro
Definition: sutra_rtc.h:62
sutra_controller_ls.h
SutraRtc::add_controller
int add_controller(CarmaContext *context, int nvalid, int nslope, int nactu, float delay, long device, std::string typec, SutraDms *dms=nullptr, int *idx_dms=nullptr, int ndm=0, int *idx_centro=nullptr, int ncentro=0, int Nphi=0, bool wfs_direction=false, int nstates=0)
SutraRtc::set_centroids_ref
int set_centroids_ref(float *centroids_ref)
sutra_controller_generic.h
SutraWfs
this class provides the wfs features to COMPASS
Definition: sutra_wfs.h:60
sutra_controller_mv.h
SutraRtc::remove_ref
int remove_ref(int ncntrl)
SutraRtc::do_centroids
int do_centroids(int ncntrl)
SutraRtc::do_calibrate_img
int do_calibrate_img()
SutraRtc::remove_centroider
int remove_centroider(int ncentro)
sutra_controller_cured.h
SutraRtc::apply_control
int apply_control(int ncntrl, bool compVoltage=true)
sutra_centroider_cog.h
CarmaContext
this class provides the context in which CarmaObj are created
Definition: carma_context.h:104
SutraRtc::remove_controller
int remove_controller(int ncontrol)
SutraRtc::add_centroider
int add_centroider(CarmaContext *context, long nvalid, float offset, float scale, bool filter_TT, long device, std::string typec)
sutra_centroider_corr.h
SutraRtc::do_clipping
int do_clipping(int ncntrl)
SutraRtc::do_calibrate_img
int do_calibrate_img(int ncntrl)
SutraRtc::do_centroids
int do_centroids()
sutra_centroider_pyr.h
SutraRtc::do_imat
int do_imat(int ncntrl, SutraDms *ydms)
sutra_centroider_wcog.h
SutraRtc::d_control
vector< SutraController< T, Tout > * > d_control
Definition: sutra_rtc.h:63
SutraRtc::do_control
int do_control(int ncntrl)
SutraRtc::~SutraRtc
~SutraRtc()
SutraRtc::do_centroids
int do_centroids(int ncntrl, bool noise)
SutraRtc
this class provides the rtc features to COMPASS
Definition: sutra_rtc.h:60
SutraRtc::add_centroider
int add_centroider(CarmaContext *context, long nvalid, float offset, float scale, bool filter_TT, long device, std::string typec, SutraWfs *wfs)
SutraRtc::do_imat_basis
int do_imat_basis(int ncntrl, SutraDms *ydm, int nModes, T *m2v, T *pushAmpl)
SutraRtc::do_centroids_ref
int do_centroids_ref(int ncntrl)
sutra_centroider_maskedPix.h
SutraRtc::do_imat_geom
int do_imat_geom(int ncntrl, SutraDms *ydm, int type)
SutraController< T, Tout >
SutraRtc::SutraRtc
SutraRtc()