1/*
2 * Arduino_skal.h
3 *
4 * Academic License - for use in teaching, academic research, and meeting
5 * course requirements at degree granting institutions only. Not for
6 * government, commercial, or other organizational use.
7 *
8 * Code generation for model "Arduino_skal".
9 *
10 * Model version : 1.1
11 * Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
12 * C++ source code generated on : Thu Apr 15 15:56:50 2021
13 *
14 * Target selection: grt.tlc
15 * Note: GRT includes extra infrastructure and instrumentation for prototyping
16 * Embedded hardware selection: Intel->x86-64 (Windows64)
17 * Code generation objective: Debugging
18 * Validation result: Not run
19 */
20
21#ifndef RTW_HEADER_Arduino_skal_h_
22#define RTW_HEADER_Arduino_skal_h_
23#include <cstring>
24#include <cfloat>
25#include <stddef.h>
26#include "rtwtypes.h"
27#include "rtw_continuous.h"
28#include "rtw_solver.h"
29#include "rt_logging.h"
30#include "Arduino_skal_types.h"
31
32/* Shared type includes */
33#include "multiword_types.h"
34#include "rt_nonfinite.h"
35
36/* Macros for accessing real-time model data structure */
37#ifndef rtmGetContStateDisabled
38#define rtmGetContStateDisabled(rtm) ((rtm)->contStateDisabled)
39#endif
40
41#ifndef rtmSetContStateDisabled
42#define rtmSetContStateDisabled(rtm, val) ((rtm)->contStateDisabled = (val))
43#endif
44
45#ifndef rtmGetContStates
46#define rtmGetContStates(rtm) ((rtm)->contStates)
47#endif
48
49#ifndef rtmSetContStates
50#define rtmSetContStates(rtm, val) ((rtm)->contStates = (val))
51#endif
52
53#ifndef rtmGetContTimeOutputInconsistentWithStateAtMajorStepFlag
54#define rtmGetContTimeOutputInconsistentWithStateAtMajorStepFlag(rtm) ((rtm)->CTOutputIncnstWithState)
55#endif
56
57#ifndef rtmSetContTimeOutputInconsistentWithStateAtMajorStepFlag
58#define rtmSetContTimeOutputInconsistentWithStateAtMajorStepFlag(rtm, val) ((rtm)->CTOutputIncnstWithState = (val))
59#endif
60
61#ifndef rtmGetDerivCacheNeedsReset
62#define rtmGetDerivCacheNeedsReset(rtm) ((rtm)->derivCacheNeedsReset)
63#endif
64
65#ifndef rtmSetDerivCacheNeedsReset
66#define rtmSetDerivCacheNeedsReset(rtm, val) ((rtm)->derivCacheNeedsReset = (val))
67#endif
68
69#ifndef rtmGetFinalTime
70#define rtmGetFinalTime(rtm) ((rtm)->Timing.tFinal)
71#endif
72
73#ifndef rtmGetIntgData
74#define rtmGetIntgData(rtm) ((rtm)->intgData)
75#endif
76
77#ifndef rtmSetIntgData
78#define rtmSetIntgData(rtm, val) ((rtm)->intgData = (val))
79#endif
80
81#ifndef rtmGetOdeF
82#define rtmGetOdeF(rtm) ((rtm)->odeF)
83#endif
84
85#ifndef rtmSetOdeF
86#define rtmSetOdeF(rtm, val) ((rtm)->odeF = (val))
87#endif
88
89#ifndef rtmGetOdeY
90#define rtmGetOdeY(rtm) ((rtm)->odeY)
91#endif
92
93#ifndef rtmSetOdeY
94#define rtmSetOdeY(rtm, val) ((rtm)->odeY = (val))
95#endif
96
97#ifndef rtmGetPeriodicContStateIndices
98#define rtmGetPeriodicContStateIndices(rtm) ((rtm)->periodicContStateIndices)
99#endif
100
101#ifndef rtmSetPeriodicContStateIndices
102#define rtmSetPeriodicContStateIndices(rtm, val) ((rtm)->periodicContStateIndices = (val))
103#endif
104
105#ifndef rtmGetPeriodicContStateRanges
106#define rtmGetPeriodicContStateRanges(rtm) ((rtm)->periodicContStateRanges)
107#endif
108
109#ifndef rtmSetPeriodicContStateRanges
110#define rtmSetPeriodicContStateRanges(rtm, val) ((rtm)->periodicContStateRanges = (val))
111#endif
112
113#ifndef rtmGetRTWLogInfo
114#define rtmGetRTWLogInfo(rtm) ((rtm)->rtwLogInfo)
115#endif
116
117#ifndef rtmGetZCCacheNeedsReset
118#define rtmGetZCCacheNeedsReset(rtm) ((rtm)->zCCacheNeedsReset)
119#endif
120
121#ifndef rtmSetZCCacheNeedsReset
122#define rtmSetZCCacheNeedsReset(rtm, val) ((rtm)->zCCacheNeedsReset = (val))
123#endif
124
125#ifndef rtmGetdX
126#define rtmGetdX(rtm) ((rtm)->derivs)
127#endif
128
129#ifndef rtmSetdX
130#define rtmSetdX(rtm, val) ((rtm)->derivs = (val))
131#endif
132
133#ifndef rtmGetErrorStatus
134#define rtmGetErrorStatus(rtm) ((rtm)->errorStatus)
135#endif
136
137#ifndef rtmSetErrorStatus
138#define rtmSetErrorStatus(rtm, val) ((rtm)->errorStatus = (val))
139#endif
140
141#ifndef rtmGetStopRequested
142#define rtmGetStopRequested(rtm) ((rtm)->Timing.stopRequestedFlag)
143#endif
144
145#ifndef rtmSetStopRequested
146#define rtmSetStopRequested(rtm, val) ((rtm)->Timing.stopRequestedFlag = (val))
147#endif
148
149#ifndef rtmGetStopRequestedPtr
150#define rtmGetStopRequestedPtr(rtm) (&((rtm)->Timing.stopRequestedFlag))
151#endif
152
153#ifndef rtmGetT
154#define rtmGetT(rtm) (rtmGetTPtr((rtm))[0])
155#endif
156
157#ifndef rtmGetTFinal
158#define rtmGetTFinal(rtm) ((rtm)->Timing.tFinal)
159#endif
160
161#ifndef rtmGetTPtr
162#define rtmGetTPtr(rtm) ((rtm)->Timing.t)
163#endif
164
165/* Block signals (default storage) */
166struct B_Arduino_skal_T {
167 real_T X0[4]; /* '<S1>/X0' */
168 real_T MemoryX[4]; /* '<S1>/MemoryX' */
169 real_T Gain; /* '<Root>/Gain' */
170 real_T Akxhatkk1[4]; /* '<S22>/A[k]*xhat[k|k-1]' */
171 real_T Step; /* '<Root>/Step' */
172 real_T Kr; /* '<Root>/Kr' */
173 real_T Sum5; /* '<Root>/Sum5' */
174 real_T Saturation; /* '<Root>/Saturation' */
175 real_T Bkuk[4]; /* '<S22>/B[k]*u[k]' */
176 real_T Add[4]; /* '<S22>/Add' */
177 real_T Ckxhatkk1[2]; /* '<S53>/C[k]*xhat[k|k-1]' */
178 real_T Dkuk[2]; /* '<S53>/D[k]*u[k]' */
179 real_T yhatkk1[2]; /* '<S53>/Add1' */
180 real_T Sum[2]; /* '<S53>/Sum' */
181 real_T Product3[4]; /* '<S53>/Product3' */
182 real_T P[16]; /* '<S51>/SqrtUsedFcn' */
183};
184
185/* Block states (default storage) for system '<Root>' */
186struct DW_Arduino_skal_T {
187 int_T MemoryX_IWORK; /* '<S1>/MemoryX' */
188 boolean_T MeasurementUpdate_MODE; /* '<S22>/MeasurementUpdate' */
189};
190
191/* Continuous states (default storage) */
192struct X_Arduino_skal_T {
193 real_T MemoryX_CSTATE[4]; /* '<S1>/MemoryX' */
194};
195
196/* State derivatives (default storage) */
197struct XDot_Arduino_skal_T {
198 real_T MemoryX_CSTATE[4]; /* '<S1>/MemoryX' */
199};
200
201/* State disabled */
202struct XDis_Arduino_skal_T {
203 boolean_T MemoryX_CSTATE[4]; /* '<S1>/MemoryX' */
204};
205
206#ifndef ODE3_INTG
207#define ODE3_INTG
208
209/* ODE3 Integration Data */
210struct ODE3_IntgData {
211 real_T *y; /* output */
212 real_T *f[3]; /* derivatives */
213};
214
215#endif
216
217/* Parameters (default storage) */
218struct P_Arduino_skal_T_ {
219 real_T K[4]; /* Variable: K
220 * Referenced by: '<Root>/Gain'
221 */
222 real_T Kr; /* Variable: Kr
223 * Referenced by: '<Root>/Kr'
224 */
225 real_T Lykyhatkk1_Y0; /* Expression: 0
226 * Referenced by: '<S53>/L*(y[k]-yhat[k|k-1])'
227 */
228 real_T Constant_Value[2]; /* Expression: [1,1]
229 * Referenced by: '<Root>/Constant'
230 */
231 real_T X0_Value[4]; /* Expression: pInitialization.X0
232 * Referenced by: '<S1>/X0'
233 */
234 real_T A_Value[16]; /* Expression: pInitialization.A
235 * Referenced by: '<S1>/A'
236 */
237 real_T B_Value[4]; /* Expression: pInitialization.B
238 * Referenced by: '<S1>/B'
239 */
240 real_T C_Value[8]; /* Expression: pInitialization.C
241 * Referenced by: '<S1>/C'
242 */
243 real_T CovarianceZ_Value[16]; /* Expression: pInitialization.Z
244 * Referenced by: '<S2>/CovarianceZ'
245 */
246 real_T KalmanGainL_Value[8]; /* Expression: pInitialization.L
247 * Referenced by: '<S2>/KalmanGainL'
248 */
249 real_T D_Value[2]; /* Expression: pInitialization.D
250 * Referenced by: '<S1>/D'
251 */
252 real_T Step_Time; /* Expression: 0
253 * Referenced by: '<Root>/Step'
254 */
255 real_T Step_Y0; /* Expression: 0
256 * Referenced by: '<Root>/Step'
257 */
258 real_T Step_YFinal; /* Expression: 0
259 * Referenced by: '<Root>/Step'
260 */
261 real_T Saturation_UpperSat; /* Expression: 11.5
262 * Referenced by: '<Root>/Saturation'
263 */
264 real_T Saturation_LowerSat; /* Expression: -11.5
265 * Referenced by: '<Root>/Saturation'
266 */
267 boolean_T isSqrtUsed_Value; /* Expression: pInitialization.isSqrtUsed
268 * Referenced by: '<S51>/isSqrtUsed'
269 */
270 boolean_T Enable_Value; /* Expression: true()
271 * Referenced by: '<S1>/Enable'
272 */
273};
274
275/* Real-time Model Data Structure */
276struct tag_RTM_Arduino_skal_T {
277 const char_T *errorStatus;
278 RTWLogInfo *rtwLogInfo;
279 RTWSolverInfo solverInfo;
280 X_Arduino_skal_T *contStates;
281 int_T *periodicContStateIndices;
282 real_T *periodicContStateRanges;
283 real_T *derivs;
284 boolean_T *contStateDisabled;
285 boolean_T zCCacheNeedsReset;
286 boolean_T derivCacheNeedsReset;
287 boolean_T CTOutputIncnstWithState;
288 real_T odeY[4];
289 real_T odeF[3][4];
290 ODE3_IntgData intgData;
291
292 /*
293 * Sizes:
294 * The following substructure contains sizes information
295 * for many of the model attributes such as inputs, outputs,
296 * dwork, sample times, etc.
297 */
298 struct {
299 int_T numContStates;
300 int_T numPeriodicContStates;
301 int_T numSampTimes;
302 } Sizes;
303
304 /*
305 * Timing:
306 * The following substructure contains information regarding
307 * the timing information for the model.
308 */
309 struct {
310 uint32_T clockTick0;
311 uint32_T clockTickH0;
312 time_T stepSize0;
313 uint32_T clockTick1;
314 uint32_T clockTickH1;
315 boolean_T firstInitCondFlag;
316 time_T tFinal;
317 SimTimeStep simTimeStep;
318 boolean_T stopRequestedFlag;
319 time_T *t;
320 time_T tArray[2];
321 } Timing;
322};
323
324/* Class declaration for model Arduino_skal */
325class Arduino_skalModelClass {
326 /* public data and function members */
327 public:
328 /* model initialize function */
329 void initialize();
330
331 /* model step function */
332 void step();
333
334 /* model terminate function */
335 void terminate();
336
337 /* Constructor */
338 Arduino_skalModelClass();
339
340 /* Destructor */
341 ~Arduino_skalModelClass();
342
343 /* Real-Time Model get method */
344 RT_MODEL_Arduino_skal_T * getRTM();
345
346 /* private data and function members */
347 private:
348 /* Tunable parameters */
349 static P_Arduino_skal_T Arduino_skal_P;
350
351 /* Block signals */
352 B_Arduino_skal_T Arduino_skal_B;
353
354 /* Block states */
355 DW_Arduino_skal_T Arduino_skal_DW;
356 X_Arduino_skal_T Arduino_skal_X; /* Block continuous states */
357
358 /* Real-Time Model */
359 RT_MODEL_Arduino_skal_T Arduino_skal_M;
360
361 /* Continuous states update member function*/
362 void rt_ertODEUpdateContinuousStates(RTWSolverInfo *si );
363
364 /* Derivatives member function */
365 void Arduino_skal_derivatives();
366};
367
368/*-
369 * These blocks were eliminated from the model due to optimizations:
370 *
371 * Block '<S45>/Data Type Duplicate' : Unused code path elimination
372 * Block '<S46>/Conversion' : Unused code path elimination
373 * Block '<S46>/Data Type Duplicate' : Unused code path elimination
374 * Block '<S47>/Conversion' : Unused code path elimination
375 * Block '<S47>/Data Type Duplicate' : Unused code path elimination
376 * Block '<S48>/Data Type Duplicate' : Unused code path elimination
377 * Block '<S2>/KalmanGainM' : Unused code path elimination
378 * Block '<S5>/Data Type Duplicate' : Unused code path elimination
379 * Block '<S6>/Data Type Duplicate' : Unused code path elimination
380 * Block '<S7>/Data Type Duplicate' : Unused code path elimination
381 * Block '<S8>/Data Type Duplicate' : Unused code path elimination
382 * Block '<S10>/Data Type Duplicate' : Unused code path elimination
383 * Block '<S11>/Data Type Duplicate' : Unused code path elimination
384 * Block '<S12>/Data Type Duplicate' : Unused code path elimination
385 * Block '<S13>/Conversion' : Unused code path elimination
386 * Block '<S13>/Data Type Duplicate' : Unused code path elimination
387 * Block '<S14>/Data Type Duplicate' : Unused code path elimination
388 * Block '<S15>/Data Type Duplicate' : Unused code path elimination
389 * Block '<S16>/Data Type Duplicate' : Unused code path elimination
390 * Block '<S18>/Data Type Duplicate' : Unused code path elimination
391 * Block '<S19>/Data Type Duplicate' : Unused code path elimination
392 * Block '<S1>/G' : Unused code path elimination
393 * Block '<S1>/H' : Unused code path elimination
394 * Block '<S1>/N' : Unused code path elimination
395 * Block '<S1>/P0' : Unused code path elimination
396 * Block '<S1>/Q' : Unused code path elimination
397 * Block '<S1>/R' : Unused code path elimination
398 * Block '<S43>/CheckSignalProperties' : Unused code path elimination
399 * Block '<S44>/CheckSignalProperties' : Unused code path elimination
400 * Block '<S45>/Conversion' : Eliminate redundant data type conversion
401 * Block '<S48>/Conversion' : Eliminate redundant data type conversion
402 * Block '<S18>/Conversion' : Eliminate redundant data type conversion
403 * Block '<S22>/Reshape' : Reshape block reduction
404 * Block '<S1>/ReshapeX0' : Reshape block reduction
405 * Block '<S1>/Reshapeu' : Reshape block reduction
406 * Block '<S1>/Reshapexhat' : Reshape block reduction
407 * Block '<S1>/Reshapey' : Reshape block reduction
408 */
409
410/*-
411 * The generated code includes comments that allow you to trace directly
412 * back to the appropriate location in the model. The basic format
413 * is <system>/block_name, where system is the system number (uniquely
414 * assigned by Simulink) and block_name is the name of the block.
415 *
416 * Use the MATLAB hilite_system command to trace the generated code back
417 * to the model. For example,
418 *
419 * hilite_system('<S3>') - opens system 3
420 * hilite_system('<S3>/Kp') - opens and selects block Kp which resides in S3
421 *
422 * Here is the system hierarchy for this model
423 *
424 * '<Root>' : 'Arduino_skal'
425 * '<S1>' : 'Arduino_skal/Kalman Filter'
426 * '<S2>' : 'Arduino_skal/Kalman Filter/CalculatePL'
427 * '<S3>' : 'Arduino_skal/Kalman Filter/CalculateYhat'
428 * '<S4>' : 'Arduino_skal/Kalman Filter/CovarianceOutputConfigurator'
429 * '<S5>' : 'Arduino_skal/Kalman Filter/DataTypeConversionA'
430 * '<S6>' : 'Arduino_skal/Kalman Filter/DataTypeConversionB'
431 * '<S7>' : 'Arduino_skal/Kalman Filter/DataTypeConversionC'
432 * '<S8>' : 'Arduino_skal/Kalman Filter/DataTypeConversionD'
433 * '<S9>' : 'Arduino_skal/Kalman Filter/DataTypeConversionEnable'
434 * '<S10>' : 'Arduino_skal/Kalman Filter/DataTypeConversionG'
435 * '<S11>' : 'Arduino_skal/Kalman Filter/DataTypeConversionH'
436 * '<S12>' : 'Arduino_skal/Kalman Filter/DataTypeConversionN'
437 * '<S13>' : 'Arduino_skal/Kalman Filter/DataTypeConversionP'
438 * '<S14>' : 'Arduino_skal/Kalman Filter/DataTypeConversionP0'
439 * '<S15>' : 'Arduino_skal/Kalman Filter/DataTypeConversionQ'
440 * '<S16>' : 'Arduino_skal/Kalman Filter/DataTypeConversionR'
441 * '<S17>' : 'Arduino_skal/Kalman Filter/DataTypeConversionReset'
442 * '<S18>' : 'Arduino_skal/Kalman Filter/DataTypeConversionX'
443 * '<S19>' : 'Arduino_skal/Kalman Filter/DataTypeConversionX0'
444 * '<S20>' : 'Arduino_skal/Kalman Filter/DataTypeConversionu'
445 * '<S21>' : 'Arduino_skal/Kalman Filter/MemoryP'
446 * '<S22>' : 'Arduino_skal/Kalman Filter/Observer'
447 * '<S23>' : 'Arduino_skal/Kalman Filter/ReducedQRN'
448 * '<S24>' : 'Arduino_skal/Kalman Filter/Reset'
449 * '<S25>' : 'Arduino_skal/Kalman Filter/Reshapeyhat'
450 * '<S26>' : 'Arduino_skal/Kalman Filter/ScalarExpansionP0'
451 * '<S27>' : 'Arduino_skal/Kalman Filter/ScalarExpansionQ'
452 * '<S28>' : 'Arduino_skal/Kalman Filter/ScalarExpansionR'
453 * '<S29>' : 'Arduino_skal/Kalman Filter/UseCurrentEstimator'
454 * '<S30>' : 'Arduino_skal/Kalman Filter/checkA'
455 * '<S31>' : 'Arduino_skal/Kalman Filter/checkB'
456 * '<S32>' : 'Arduino_skal/Kalman Filter/checkC'
457 * '<S33>' : 'Arduino_skal/Kalman Filter/checkD'
458 * '<S34>' : 'Arduino_skal/Kalman Filter/checkEnable'
459 * '<S35>' : 'Arduino_skal/Kalman Filter/checkG'
460 * '<S36>' : 'Arduino_skal/Kalman Filter/checkH'
461 * '<S37>' : 'Arduino_skal/Kalman Filter/checkN'
462 * '<S38>' : 'Arduino_skal/Kalman Filter/checkP0'
463 * '<S39>' : 'Arduino_skal/Kalman Filter/checkQ'
464 * '<S40>' : 'Arduino_skal/Kalman Filter/checkR'
465 * '<S41>' : 'Arduino_skal/Kalman Filter/checkReset'
466 * '<S42>' : 'Arduino_skal/Kalman Filter/checkX0'
467 * '<S43>' : 'Arduino_skal/Kalman Filter/checku'
468 * '<S44>' : 'Arduino_skal/Kalman Filter/checky'
469 * '<S45>' : 'Arduino_skal/Kalman Filter/CalculatePL/DataTypeConversionL'
470 * '<S46>' : 'Arduino_skal/Kalman Filter/CalculatePL/DataTypeConversionM'
471 * '<S47>' : 'Arduino_skal/Kalman Filter/CalculatePL/DataTypeConversionP'
472 * '<S48>' : 'Arduino_skal/Kalman Filter/CalculatePL/DataTypeConversionZ'
473 * '<S49>' : 'Arduino_skal/Kalman Filter/CalculatePL/Ground'
474 * '<S50>' : 'Arduino_skal/Kalman Filter/CalculateYhat/Ground'
475 * '<S51>' : 'Arduino_skal/Kalman Filter/CovarianceOutputConfigurator/decideOutput'
476 * '<S52>' : 'Arduino_skal/Kalman Filter/CovarianceOutputConfigurator/decideOutput/SqrtUsedFcn'
477 * '<S53>' : 'Arduino_skal/Kalman Filter/Observer/MeasurementUpdate'
478 * '<S54>' : 'Arduino_skal/Kalman Filter/ReducedQRN/Ground'
479 */
480#endif /* RTW_HEADER_Arduino_skal_h_ */
481