The VisAO Camera
reconstructor.h
Go to the documentation of this file.
1 /************************************************************
2 * reconstructor.h
3 *
4 * Author: Jared R. Males (jrmales@email.arizona.edu)
5 *
6 * Declarations for a class to perform real-time reconstruction of wavefronts.
7 *
8 * Developed as part of the Magellan Adaptive Optics system.
9 ************************************************************/
10 
11 /** \file reconstructor.h
12  * \author Jared R. Males
13  * \brief Declarations for a class to perform real-time reconstruction of wavefronts.
14  *
15  *
16 */
17 
18 #ifndef __reconstructor_h__
19 #define __reconstructor_h__
20 
21 #include "VisAOApp_standalone.h"
22 #include "../lib/sharedim_stack.h"
23 #include <math.h>
24 
25 #include "recmat.h"
26 #include "fir_filter.h"
27 #include "rmsAccumulator.h"
28 
29 #define PING_IN_FIFO 0
30 #define FS_PING_FIFO 1
31 
32 ///The size of each telemetry vector
33 #define REC_TELEM_N 19
34 /*
35 0 - WFE
36 1 - filtered WFE
37 2 - Tip
38 3 - Tilt
39 4 - raw strehl
40 5 - calibrated strehl
41 6 - filtered strehl
42 7 - filtered calibrated strehl
43 8 - fitered tip
44 9 - filtered tilt
45 10 - ho1 WFE
46 11 - filtered ho1 wfe
47 12 - ho2 WFE
48 13 - filtered ho2 WFE
49 14 - WFE temporal variance of WFE (165 frame avg)
50 15 - Tip temporal variance (165 frame avg)
51 16 - Tilt temporal variance (165 frame avg)
52 17 - HO1 temporal variance (165 frame avg)
53 18 - HO2 temporal variance (165 frame avg)
54 */
55 namespace VisAO
56 {
57 
58 ///The VisAO reconstructor
59 /** This class provides a framework for a reconstructing wavefronts from slopes computed elsewhere, nominally
60  * by the BCU39 and provided by the framegrabber39 process. Receives pings from the framegrabber39 process when a new frame arrives.
61  * Sends pings to the frameselector process.
62  *
63  * See \ref VisAOApp_standalone for command line arguments. There are no additional command line arguments for reconstructor.
64  *
65  * This is a standalone VisAOApp, so it doesn't depend on MsgD.
66  *
67  * The following configuration values are optional:
68  * - <b>ping_fifo_path</b> <tt>string</tt> [fifos] - path, relative to VISAO_ROOT, specifying where to create the input and output pings
69  * - <b>bcu39_shmem_key</b> <tt>int</tt> [DATA_framegrabber39] - shared memory key for the framegrabber 39 frames circular buffer
70  * - <b>strehls_shmem_key</b> <tt>int</tt> [DATA_strehls] - shared memory key for the Strehls circular buffer
71  * - <b>num_strehls</b> <tt>int</tt> [2500] - number of Strehls to store in the Strehls circular buffer
72  * - <b>rec_tech</b> <tt>int</tt> [REC_ATLAS] - if 0 (REC_ATLAS), then the CPU is used for reconstruction. if 1 (REC_GPU) then the GPU is used for reconstruction.
73  * - <b>tel_diam</b> <tt>double</tt> [6.5] - primary diamter
74  * - <b>median_r0</b> <tt>double</tt> [8.0] - median Fried parameter
75  * - <b>median_r0_lam</b> <tt>double</tt> [0.55] - wavelength at which median Fried parameter
76  * - <b>fitting_A</b> <tt>double</tt> [0.232555] - fitting error A coefficient (Males et al, SPIE, 2012)
77  * - <b>fitting_B</b> <tt>double</tt> [-0.840466] - fitting error B coefficient (Males et al, SPIE, 2012)
78  * - <b>reflection_gain</b> <tt>double</tt> [2.] - gain to go from surface to phase WFE. (normally 2, but it's 4 on the CRO due to double pass)
79  *
80  */
81 
83 {
84  public:
85  reconstructor(int argc, char **argv) throw (AOException);
86  reconstructor(std::string, const std::string &conffile) throw (AOException);
87 
88  //~reconstructor();
89 
90  protected:
91  ///Processes the config file
92  void Create();
93 
94  recmat rmat;
95  int valid_recmat;
96 
97  std::string recFileName;
98 
99  int n_modes;
100  int ho_middle;
101 
102  int slopes_shmem_key; ///< The key for the shared memory for slopes
103  sharedim_stack<unsigned char> slopes_sis; ///< The shared memory ring buffer for slopes storage
104  sharedim<unsigned char> slopes_sim; ///< Shared memory image of slopes (a vector actually)
105 
106 
107  sharedim_stack<float> strehl_sis; ///<Shared memory ring buffer for strehl data
108  sharedim<float> * strehl_sim; ///<Shared memory image, from ring buffer, for strehl data
109  sharedim<float> strehl_simavg; ///<Shared memory image, from ring buffer, for strehl data
110 
111  float lambda;
112  float lamgain;
113 
114  std::string filter_name;
115  fir_filter fir;
116 
117  float cal_a;
118  float cal_b;
119 
120  float sumv;
121  float rawstrehl;
122  float filtstrehl;
123 
124  float filt_tip;
125  float tilt_tilt;
126  float tt_wfe;
127  float ho1_wfe;
128  float ho2_wfe;
129  float filt_tt_wfe;
130  float filt_ho1_wfe;
131  float filt_ho2_wfe;
132  float rms_tt_wfe;
133  float rms_ho1_wfe;
134  float rms_ho2_wfe;
135 
136  rmsAccumulator<float> rmsAccum;
137 
138  float * strehldata;
139  float * wfedata;
140 
141  float *slopes; ///Pointer to the slopes vector.
142 
144  int num_strehls;
145 
146  std::string ping_fifo_path;
147 
148  pthread_mutex_t reconMutex;
149 
152 
153  bool FSPing_enabled;
154 
155  public:
156 
157  int set_matint(std::string matintfile);
158 
159  int set_lambda(float lam);
160  float get_lambda(){ return lambda;}
161 
162  int set_filter(std::string fname);
163  std::string get_filter(){ return filter_name;}
164 
165  int set_cal_a(float a);
166  float get_cal_a(){return cal_a;}
167  int set_cal_b(float b);
168  float get_cal_b(){return cal_b;}
169 
170  int reconstruct();
171 
172  virtual int Run();
173 
174  std::string local_command(std::string com);
175  std::string script_command(std::string com);
176 
177  std::string common_command(std::string com, int cmode);
178 
179  public:
180  ///Update the reconstructor Status Board shared memory.
181  virtual int update_statusboard();
182 };
183 
184 //read the ping fifo channel
185 void frame_ready(int signum, siginfo_t *siginf, void *ucont);
186 
187 } //namespace VisAO
188 
189 #endif //__reconstructor_h__
Definition: recmat.h:40
int strehls_shmem_key
Pointer to the slopes vector.
The standalone VisAO application, does not interface with the AO Supervisor.
Declarations for the standalone VisAO application.
Declarations for a class to manage a reconstructor matrix.
virtual int Run()
The application main loop, to be re-implemented in derived classes.
virtual int update_statusboard()
Update the reconstructor Status Board shared memory.
FIR digital filter class declarations.
sharedim< float > * strehl_sim
Shared memory image, from ring buffer, for strehl data.
void Create()
Processes the config file.
sharedim_stack< float > strehl_sis
Shared memory ring buffer for strehl data.
sharedim< unsigned char > slopes_sim
Shared memory image of slopes (a vector actually)
sharedim_stack< unsigned char > slopes_sis
The shared memory ring buffer for slopes storage.
std::string local_command(std::string com)
Called by __local_command after control state logic.
std::string script_command(std::string com)
Called by __script_command after control state logic.
The namespace of VisAO software.
The VisAO reconstructor.
Definition: reconstructor.h:82
int slopes_shmem_key
The key for the shared memory for slopes.
sharedim< float > strehl_simavg
Shared memory image, from ring buffer, for strehl data.