new lqr
This commit is contained in:
parent
aefed82ba4
commit
5515304b4f
292
simulink_export_no_kalman/Arduino_skal.cpp
Normal file
292
simulink_export_no_kalman/Arduino_skal.cpp
Normal file
@ -0,0 +1,292 @@
|
|||||||
|
//
|
||||||
|
// Academic License - for use in teaching, academic research, and meeting
|
||||||
|
// course requirements at degree granting institutions only. Not for
|
||||||
|
// government, commercial, or other organizational use.
|
||||||
|
//
|
||||||
|
// File: Arduino_skal.cpp
|
||||||
|
//
|
||||||
|
// Code generated for Simulink model 'Arduino_skal'.
|
||||||
|
//
|
||||||
|
// Model version : 1.1
|
||||||
|
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||||
|
// C/C++ source code generated on : Thu Apr 15 22:06:00 2021
|
||||||
|
//
|
||||||
|
// Target selection: ert.tlc
|
||||||
|
// Embedded hardware selection: AMD->x86-64 (Windows64)
|
||||||
|
// Code generation objectives:
|
||||||
|
// 1. Execution efficiency
|
||||||
|
// 2. RAM efficiency
|
||||||
|
// Validation result: Not run
|
||||||
|
//
|
||||||
|
#include "Arduino_skal.h"
|
||||||
|
|
||||||
|
// Private macros used by the generated code to access rtModel
|
||||||
|
#ifndef rtmIsMajorTimeStep
|
||||||
|
#define rtmIsMajorTimeStep(rtm) (((rtm)->Timing.simTimeStep) == MAJOR_TIME_STEP)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef rtmIsMinorTimeStep
|
||||||
|
#define rtmIsMinorTimeStep(rtm) (((rtm)->Timing.simTimeStep) == MINOR_TIME_STEP)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef rtmSetTPtr
|
||||||
|
#define rtmSetTPtr(rtm, val) ((rtm)->Timing.t = (val))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// private model entry point functions
|
||||||
|
extern void Arduino_skal_derivatives();
|
||||||
|
|
||||||
|
//
|
||||||
|
// This function updates continuous states using the ODE3 fixed-step
|
||||||
|
// solver algorithm
|
||||||
|
//
|
||||||
|
void Arduino_skalModelClass::rt_ertODEUpdateContinuousStates(RTWSolverInfo *si )
|
||||||
|
{
|
||||||
|
// Solver Matrices
|
||||||
|
static const real_T rt_ODE3_A[3] = {
|
||||||
|
1.0/2.0, 3.0/4.0, 1.0
|
||||||
|
};
|
||||||
|
|
||||||
|
static const real_T rt_ODE3_B[3][3] = {
|
||||||
|
{ 1.0/2.0, 0.0, 0.0 },
|
||||||
|
|
||||||
|
{ 0.0, 3.0/4.0, 0.0 },
|
||||||
|
|
||||||
|
{ 2.0/9.0, 1.0/3.0, 4.0/9.0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
time_T t = rtsiGetT(si);
|
||||||
|
time_T tnew = rtsiGetSolverStopTime(si);
|
||||||
|
time_T h = rtsiGetStepSize(si);
|
||||||
|
real_T *x = rtsiGetContStates(si);
|
||||||
|
ODE3_IntgData *id = static_cast<ODE3_IntgData *>(rtsiGetSolverData(si));
|
||||||
|
real_T *y = id->y;
|
||||||
|
real_T *f0 = id->f[0];
|
||||||
|
real_T *f1 = id->f[1];
|
||||||
|
real_T *f2 = id->f[2];
|
||||||
|
real_T hB[3];
|
||||||
|
int_T i;
|
||||||
|
int_T nXc = 4;
|
||||||
|
rtsiSetSimTimeStep(si,MINOR_TIME_STEP);
|
||||||
|
|
||||||
|
// Save the state values at time t in y, we'll use x as ynew.
|
||||||
|
(void) std::memcpy(y, x,
|
||||||
|
static_cast<uint_T>(nXc)*sizeof(real_T));
|
||||||
|
|
||||||
|
// Assumes that rtsiSetT and ModelOutputs are up-to-date
|
||||||
|
// f0 = f(t,y)
|
||||||
|
rtsiSetdX(si, f0);
|
||||||
|
Arduino_skal_derivatives();
|
||||||
|
|
||||||
|
// f(:,2) = feval(odefile, t + hA(1), y + f*hB(:,1), args(:)(*));
|
||||||
|
hB[0] = h * rt_ODE3_B[0][0];
|
||||||
|
for (i = 0; i < nXc; i++) {
|
||||||
|
x[i] = y[i] + (f0[i]*hB[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
rtsiSetT(si, t + h*rt_ODE3_A[0]);
|
||||||
|
rtsiSetdX(si, f1);
|
||||||
|
this->step();
|
||||||
|
Arduino_skal_derivatives();
|
||||||
|
|
||||||
|
// f(:,3) = feval(odefile, t + hA(2), y + f*hB(:,2), args(:)(*));
|
||||||
|
for (i = 0; i <= 1; i++) {
|
||||||
|
hB[i] = h * rt_ODE3_B[1][i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < nXc; i++) {
|
||||||
|
x[i] = y[i] + (f0[i]*hB[0] + f1[i]*hB[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
rtsiSetT(si, t + h*rt_ODE3_A[1]);
|
||||||
|
rtsiSetdX(si, f2);
|
||||||
|
this->step();
|
||||||
|
Arduino_skal_derivatives();
|
||||||
|
|
||||||
|
// tnew = t + hA(3);
|
||||||
|
// ynew = y + f*hB(:,3);
|
||||||
|
for (i = 0; i <= 2; i++) {
|
||||||
|
hB[i] = h * rt_ODE3_B[2][i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < nXc; i++) {
|
||||||
|
x[i] = y[i] + (f0[i]*hB[0] + f1[i]*hB[1] + f2[i]*hB[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
rtsiSetT(si, tnew);
|
||||||
|
rtsiSetSimTimeStep(si,MAJOR_TIME_STEP);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Model step function
|
||||||
|
void Arduino_skalModelClass::step()
|
||||||
|
{
|
||||||
|
real_T tmp[2];
|
||||||
|
real_T rtb_Saturation;
|
||||||
|
int32_T i;
|
||||||
|
if (rtmIsMajorTimeStep((&rtM))) {
|
||||||
|
// set solver stop time
|
||||||
|
rtsiSetSolverStopTime(&(&rtM)->solverInfo,(((&rtM)->Timing.clockTick0+1)*
|
||||||
|
(&rtM)->Timing.stepSize0));
|
||||||
|
} // end MajorTimeStep
|
||||||
|
|
||||||
|
// Update absolute time of base rate at minor time step
|
||||||
|
if (rtmIsMinorTimeStep((&rtM))) {
|
||||||
|
(&rtM)->Timing.t[0] = rtsiGetT(&(&rtM)->solverInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gain: '<Root>/Gain' incorporates:
|
||||||
|
// Integrator: '<Root>/Integrator1'
|
||||||
|
|
||||||
|
rtb_Saturation = ((-31.622776601683942 * rtX.Integrator1_CSTATE[0] +
|
||||||
|
-21.286439360075747 * rtX.Integrator1_CSTATE[1]) +
|
||||||
|
80.789376267003959 * rtX.Integrator1_CSTATE[2]) +
|
||||||
|
13.42463576551093 * rtX.Integrator1_CSTATE[3];
|
||||||
|
|
||||||
|
// Saturate: '<Root>/Saturation' incorporates:
|
||||||
|
// Gain: '<Root>/Gain'
|
||||||
|
// Step: '<Root>/Step'
|
||||||
|
// Sum: '<Root>/Sum5'
|
||||||
|
|
||||||
|
if (0.0 - rtb_Saturation > 11.5) {
|
||||||
|
rtb_Saturation = 11.5;
|
||||||
|
} else if (0.0 - rtb_Saturation < -11.5) {
|
||||||
|
rtb_Saturation = -11.5;
|
||||||
|
} else {
|
||||||
|
rtb_Saturation = 0.0 - rtb_Saturation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// End of Saturate: '<Root>/Saturation'
|
||||||
|
|
||||||
|
// Sum: '<Root>/Sum2' incorporates:
|
||||||
|
// Constant: '<Root>/vartejag'
|
||||||
|
// Gain: '<Root>/Gain6'
|
||||||
|
// Integrator: '<Root>/Integrator1'
|
||||||
|
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
tmp[i] = rtConstP.vartejag_Value[i] - (((rtConstP.Gain6_Gain[i + 2] *
|
||||||
|
rtX.Integrator1_CSTATE[1] + rtConstP.Gain6_Gain[i] *
|
||||||
|
rtX.Integrator1_CSTATE[0]) + rtConstP.Gain6_Gain[i + 4] *
|
||||||
|
rtX.Integrator1_CSTATE[2]) + rtConstP.Gain6_Gain[i + 6] *
|
||||||
|
rtX.Integrator1_CSTATE[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// End of Sum: '<Root>/Sum2'
|
||||||
|
for (i = 0; i < 4; i++) {
|
||||||
|
// Sum: '<Root>/Sum4' incorporates:
|
||||||
|
// Gain: '<Root>/Gain2'
|
||||||
|
// Gain: '<Root>/Gain3'
|
||||||
|
// Gain: '<Root>/Gain4'
|
||||||
|
// Integrator: '<Root>/Integrator1'
|
||||||
|
// Sum: '<Root>/Sum3'
|
||||||
|
|
||||||
|
rtDW.Sum4[i] = ((rtConstP.Gain2_Gain[i + 4] * tmp[1] + rtConstP.Gain2_Gain[i]
|
||||||
|
* tmp[0]) + rtConstP.Gain3_Gain[i] * rtb_Saturation) +
|
||||||
|
(rtConstP.Gain4_Gain[i + 12] * rtX.Integrator1_CSTATE[3] +
|
||||||
|
(rtConstP.Gain4_Gain[i + 8] * rtX.Integrator1_CSTATE[2] +
|
||||||
|
(rtConstP.Gain4_Gain[i + 4] * rtX.Integrator1_CSTATE[1] +
|
||||||
|
rtConstP.Gain4_Gain[i] * rtX.Integrator1_CSTATE[0])));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rtmIsMajorTimeStep((&rtM))) {
|
||||||
|
rt_ertODEUpdateContinuousStates(&(&rtM)->solverInfo);
|
||||||
|
|
||||||
|
// Update absolute time for base rate
|
||||||
|
// The "clockTick0" counts the number of times the code of this task has
|
||||||
|
// been executed. The absolute time is the multiplication of "clockTick0"
|
||||||
|
// and "Timing.stepSize0". Size of "clockTick0" ensures timer will not
|
||||||
|
// overflow during the application lifespan selected.
|
||||||
|
|
||||||
|
++(&rtM)->Timing.clockTick0;
|
||||||
|
(&rtM)->Timing.t[0] = rtsiGetSolverStopTime(&(&rtM)->solverInfo);
|
||||||
|
|
||||||
|
{
|
||||||
|
// Update absolute timer for sample time: [0.2s, 0.0s]
|
||||||
|
// The "clockTick1" counts the number of times the code of this task has
|
||||||
|
// been executed. The resolution of this integer timer is 0.2, which is the step size
|
||||||
|
// of the task. Size of "clockTick1" ensures timer will not overflow during the
|
||||||
|
// application lifespan selected.
|
||||||
|
|
||||||
|
(&rtM)->Timing.clockTick1++;
|
||||||
|
}
|
||||||
|
} // end MajorTimeStep
|
||||||
|
}
|
||||||
|
|
||||||
|
// Derivatives for root system: '<Root>'
|
||||||
|
void Arduino_skalModelClass::Arduino_skal_derivatives()
|
||||||
|
{
|
||||||
|
Arduino_skalModelClass::XDot *_rtXdot;
|
||||||
|
_rtXdot = ((XDot *) (&rtM)->derivs);
|
||||||
|
|
||||||
|
// Derivatives for Integrator: '<Root>/Integrator1'
|
||||||
|
_rtXdot->Integrator1_CSTATE[0] = rtDW.Sum4[0];
|
||||||
|
_rtXdot->Integrator1_CSTATE[1] = rtDW.Sum4[1];
|
||||||
|
_rtXdot->Integrator1_CSTATE[2] = rtDW.Sum4[2];
|
||||||
|
_rtXdot->Integrator1_CSTATE[3] = rtDW.Sum4[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Model initialize function
|
||||||
|
void Arduino_skalModelClass::initialize()
|
||||||
|
{
|
||||||
|
// Registration code
|
||||||
|
{
|
||||||
|
// Setup solver object
|
||||||
|
rtsiSetSimTimeStepPtr(&(&rtM)->solverInfo, &(&rtM)->Timing.simTimeStep);
|
||||||
|
rtsiSetTPtr(&(&rtM)->solverInfo, &rtmGetTPtr((&rtM)));
|
||||||
|
rtsiSetStepSizePtr(&(&rtM)->solverInfo, &(&rtM)->Timing.stepSize0);
|
||||||
|
rtsiSetdXPtr(&(&rtM)->solverInfo, &(&rtM)->derivs);
|
||||||
|
rtsiSetContStatesPtr(&(&rtM)->solverInfo, (real_T **) &(&rtM)->contStates);
|
||||||
|
rtsiSetNumContStatesPtr(&(&rtM)->solverInfo, &(&rtM)->Sizes.numContStates);
|
||||||
|
rtsiSetNumPeriodicContStatesPtr(&(&rtM)->solverInfo, &(&rtM)
|
||||||
|
->Sizes.numPeriodicContStates);
|
||||||
|
rtsiSetPeriodicContStateIndicesPtr(&(&rtM)->solverInfo, &(&rtM)
|
||||||
|
->periodicContStateIndices);
|
||||||
|
rtsiSetPeriodicContStateRangesPtr(&(&rtM)->solverInfo, &(&rtM)
|
||||||
|
->periodicContStateRanges);
|
||||||
|
rtsiSetErrorStatusPtr(&(&rtM)->solverInfo, (&rtmGetErrorStatus((&rtM))));
|
||||||
|
rtsiSetRTModelPtr(&(&rtM)->solverInfo, (&rtM));
|
||||||
|
}
|
||||||
|
|
||||||
|
rtsiSetSimTimeStep(&(&rtM)->solverInfo, MAJOR_TIME_STEP);
|
||||||
|
(&rtM)->intgData.y = (&rtM)->odeY;
|
||||||
|
(&rtM)->intgData.f[0] = (&rtM)->odeF[0];
|
||||||
|
(&rtM)->intgData.f[1] = (&rtM)->odeF[1];
|
||||||
|
(&rtM)->intgData.f[2] = (&rtM)->odeF[2];
|
||||||
|
(&rtM)->contStates = ((X *) &rtX);
|
||||||
|
rtsiSetSolverData(&(&rtM)->solverInfo, static_cast<void *>(&(&rtM)->intgData));
|
||||||
|
rtsiSetSolverName(&(&rtM)->solverInfo,"ode3");
|
||||||
|
rtmSetTPtr((&rtM), &(&rtM)->Timing.tArray[0]);
|
||||||
|
(&rtM)->Timing.stepSize0 = 0.2;
|
||||||
|
|
||||||
|
// InitializeConditions for Integrator: '<Root>/Integrator1'
|
||||||
|
rtX.Integrator1_CSTATE[0] = 0.0;
|
||||||
|
rtX.Integrator1_CSTATE[1] = 0.0;
|
||||||
|
rtX.Integrator1_CSTATE[2] = 0.0;
|
||||||
|
rtX.Integrator1_CSTATE[3] = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Arduino_skalModelClass::Arduino_skalModelClass() :
|
||||||
|
rtDW(),
|
||||||
|
rtX(),
|
||||||
|
rtM()
|
||||||
|
{
|
||||||
|
// Currently there is no constructor body generated.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
Arduino_skalModelClass::~Arduino_skalModelClass()
|
||||||
|
{
|
||||||
|
// Currently there is no destructor body generated.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Real-Time Model get method
|
||||||
|
Arduino_skalModelClass::RT_MODEL * Arduino_skalModelClass::getRTM()
|
||||||
|
{
|
||||||
|
return (&rtM);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// File trailer for generated code.
|
||||||
|
//
|
||||||
|
// [EOF]
|
||||||
|
//
|
228
simulink_export_no_kalman/Arduino_skal.h
Normal file
228
simulink_export_no_kalman/Arduino_skal.h
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
//
|
||||||
|
// Academic License - for use in teaching, academic research, and meeting
|
||||||
|
// course requirements at degree granting institutions only. Not for
|
||||||
|
// government, commercial, or other organizational use.
|
||||||
|
//
|
||||||
|
// File: Arduino_skal.h
|
||||||
|
//
|
||||||
|
// Code generated for Simulink model 'Arduino_skal'.
|
||||||
|
//
|
||||||
|
// Model version : 1.1
|
||||||
|
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||||
|
// C/C++ source code generated on : Thu Apr 15 22:06:00 2021
|
||||||
|
//
|
||||||
|
// Target selection: ert.tlc
|
||||||
|
// Embedded hardware selection: AMD->x86-64 (Windows64)
|
||||||
|
// Code generation objectives:
|
||||||
|
// 1. Execution efficiency
|
||||||
|
// 2. RAM efficiency
|
||||||
|
// Validation result: Not run
|
||||||
|
//
|
||||||
|
#ifndef RTW_HEADER_Arduino_skal_h_
|
||||||
|
#define RTW_HEADER_Arduino_skal_h_
|
||||||
|
#include <cstring>
|
||||||
|
#include "rtwtypes.h"
|
||||||
|
#include "rtw_continuous.h"
|
||||||
|
#include "rtw_solver.h"
|
||||||
|
|
||||||
|
// Model Code Variants
|
||||||
|
|
||||||
|
// Macros for accessing real-time model data structure
|
||||||
|
#ifndef rtmGetErrorStatus
|
||||||
|
#define rtmGetErrorStatus(rtm) ((rtm)->errorStatus)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef rtmSetErrorStatus
|
||||||
|
#define rtmSetErrorStatus(rtm, val) ((rtm)->errorStatus = (val))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef rtmGetStopRequested
|
||||||
|
#define rtmGetStopRequested(rtm) ((rtm)->Timing.stopRequestedFlag)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef rtmSetStopRequested
|
||||||
|
#define rtmSetStopRequested(rtm, val) ((rtm)->Timing.stopRequestedFlag = (val))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef rtmGetStopRequestedPtr
|
||||||
|
#define rtmGetStopRequestedPtr(rtm) (&((rtm)->Timing.stopRequestedFlag))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef rtmGetT
|
||||||
|
#define rtmGetT(rtm) (rtmGetTPtr((rtm))[0])
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef rtmGetTPtr
|
||||||
|
#define rtmGetTPtr(rtm) ((rtm)->Timing.t)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ODE3_INTG
|
||||||
|
#define ODE3_INTG
|
||||||
|
|
||||||
|
// ODE3 Integration Data
|
||||||
|
struct ODE3_IntgData {
|
||||||
|
real_T *y; // output
|
||||||
|
real_T *f[3]; // derivatives
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Class declaration for model Arduino_skal
|
||||||
|
class Arduino_skalModelClass {
|
||||||
|
// public data and function members
|
||||||
|
public:
|
||||||
|
// Block signals and states (default storage) for system '<Root>'
|
||||||
|
struct DW {
|
||||||
|
real_T Sum4[4]; // '<Root>/Sum4'
|
||||||
|
};
|
||||||
|
|
||||||
|
// Continuous states (default storage)
|
||||||
|
struct X {
|
||||||
|
real_T Integrator1_CSTATE[4]; // '<Root>/Integrator1'
|
||||||
|
};
|
||||||
|
|
||||||
|
// State derivatives (default storage)
|
||||||
|
struct XDot {
|
||||||
|
real_T Integrator1_CSTATE[4]; // '<Root>/Integrator1'
|
||||||
|
};
|
||||||
|
|
||||||
|
// State disabled
|
||||||
|
struct XDis {
|
||||||
|
boolean_T Integrator1_CSTATE[4]; // '<Root>/Integrator1'
|
||||||
|
};
|
||||||
|
|
||||||
|
// Constant parameters (default storage)
|
||||||
|
struct ConstP {
|
||||||
|
// Expression: [100;200]
|
||||||
|
// Referenced by: '<Root>/vartejag'
|
||||||
|
|
||||||
|
real_T vartejag_Value[2];
|
||||||
|
|
||||||
|
// Expression: A
|
||||||
|
// Referenced by: '<Root>/Gain4'
|
||||||
|
|
||||||
|
real_T Gain4_Gain[16];
|
||||||
|
|
||||||
|
// Expression: C
|
||||||
|
// Referenced by: '<Root>/Gain6'
|
||||||
|
|
||||||
|
real_T Gain6_Gain[8];
|
||||||
|
|
||||||
|
// Expression: L
|
||||||
|
// Referenced by: '<Root>/Gain2'
|
||||||
|
|
||||||
|
real_T Gain2_Gain[8];
|
||||||
|
|
||||||
|
// Expression: B
|
||||||
|
// Referenced by: '<Root>/Gain3'
|
||||||
|
|
||||||
|
real_T Gain3_Gain[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
// Real-time Model Data Structure
|
||||||
|
struct RT_MODEL {
|
||||||
|
const char_T *errorStatus;
|
||||||
|
RTWSolverInfo solverInfo;
|
||||||
|
X *contStates;
|
||||||
|
int_T *periodicContStateIndices;
|
||||||
|
real_T *periodicContStateRanges;
|
||||||
|
real_T *derivs;
|
||||||
|
boolean_T *contStateDisabled;
|
||||||
|
boolean_T zCCacheNeedsReset;
|
||||||
|
boolean_T derivCacheNeedsReset;
|
||||||
|
boolean_T CTOutputIncnstWithState;
|
||||||
|
real_T odeY[4];
|
||||||
|
real_T odeF[3][4];
|
||||||
|
ODE3_IntgData intgData;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Sizes:
|
||||||
|
// The following substructure contains sizes information
|
||||||
|
// for many of the model attributes such as inputs, outputs,
|
||||||
|
// dwork, sample times, etc.
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int_T numContStates;
|
||||||
|
int_T numPeriodicContStates;
|
||||||
|
int_T numSampTimes;
|
||||||
|
} Sizes;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Timing:
|
||||||
|
// The following substructure contains information regarding
|
||||||
|
// the timing information for the model.
|
||||||
|
|
||||||
|
struct {
|
||||||
|
uint32_T clockTick0;
|
||||||
|
time_T stepSize0;
|
||||||
|
uint32_T clockTick1;
|
||||||
|
SimTimeStep simTimeStep;
|
||||||
|
boolean_T stopRequestedFlag;
|
||||||
|
time_T *t;
|
||||||
|
time_T tArray[2];
|
||||||
|
} Timing;
|
||||||
|
};
|
||||||
|
|
||||||
|
// model initialize function
|
||||||
|
void initialize();
|
||||||
|
|
||||||
|
// model step function
|
||||||
|
void step();
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Arduino_skalModelClass();
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~Arduino_skalModelClass();
|
||||||
|
|
||||||
|
// Real-Time Model get method
|
||||||
|
Arduino_skalModelClass::RT_MODEL * getRTM();
|
||||||
|
|
||||||
|
// private data and function members
|
||||||
|
private:
|
||||||
|
// Block signals and states
|
||||||
|
DW rtDW;
|
||||||
|
X rtX; // Block continuous states
|
||||||
|
|
||||||
|
// Real-Time Model
|
||||||
|
RT_MODEL rtM;
|
||||||
|
|
||||||
|
// Continuous states update member function
|
||||||
|
void rt_ertODEUpdateContinuousStates(RTWSolverInfo *si );
|
||||||
|
|
||||||
|
// Derivatives member function
|
||||||
|
void Arduino_skal_derivatives();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Constant parameters (default storage)
|
||||||
|
extern const Arduino_skalModelClass::ConstP rtConstP;
|
||||||
|
|
||||||
|
//-
|
||||||
|
// These blocks were eliminated from the model due to optimizations:
|
||||||
|
//
|
||||||
|
// Block '<Root>/Kr' : Eliminated nontunable gain of 1
|
||||||
|
|
||||||
|
|
||||||
|
//-
|
||||||
|
// The generated code includes comments that allow you to trace directly
|
||||||
|
// back to the appropriate location in the model. The basic format
|
||||||
|
// is <system>/block_name, where system is the system number (uniquely
|
||||||
|
// assigned by Simulink) and block_name is the name of the block.
|
||||||
|
//
|
||||||
|
// Use the MATLAB hilite_system command to trace the generated code back
|
||||||
|
// to the model. For example,
|
||||||
|
//
|
||||||
|
// hilite_system('<S3>') - opens system 3
|
||||||
|
// hilite_system('<S3>/Kp') - opens and selects block Kp which resides in S3
|
||||||
|
//
|
||||||
|
// Here is the system hierarchy for this model
|
||||||
|
//
|
||||||
|
// '<Root>' : 'Arduino_skal'
|
||||||
|
|
||||||
|
#endif // RTW_HEADER_Arduino_skal_h_
|
||||||
|
|
||||||
|
//
|
||||||
|
// File trailer for generated code.
|
||||||
|
//
|
||||||
|
// [EOF]
|
||||||
|
//
|
58
simulink_export_no_kalman/Arduino_skal_data.cpp
Normal file
58
simulink_export_no_kalman/Arduino_skal_data.cpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
//
|
||||||
|
// Academic License - for use in teaching, academic research, and meeting
|
||||||
|
// course requirements at degree granting institutions only. Not for
|
||||||
|
// government, commercial, or other organizational use.
|
||||||
|
//
|
||||||
|
// File: Arduino_skal_data.cpp
|
||||||
|
//
|
||||||
|
// Code generated for Simulink model 'Arduino_skal'.
|
||||||
|
//
|
||||||
|
// Model version : 1.1
|
||||||
|
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||||
|
// C/C++ source code generated on : Thu Apr 15 22:06:00 2021
|
||||||
|
//
|
||||||
|
// Target selection: ert.tlc
|
||||||
|
// Embedded hardware selection: AMD->x86-64 (Windows64)
|
||||||
|
// Code generation objectives:
|
||||||
|
// 1. Execution efficiency
|
||||||
|
// 2. RAM efficiency
|
||||||
|
// Validation result: Not run
|
||||||
|
//
|
||||||
|
#include "Arduino_skal.h"
|
||||||
|
|
||||||
|
// Constant parameters (default storage)
|
||||||
|
const Arduino_skalModelClass::ConstP rtConstP = {
|
||||||
|
// Expression: [100;200]
|
||||||
|
// Referenced by: '<Root>/vartejag'
|
||||||
|
|
||||||
|
{ 100.0, 200.0 },
|
||||||
|
|
||||||
|
// Expression: A
|
||||||
|
// Referenced by: '<Root>/Gain4'
|
||||||
|
|
||||||
|
{ 0.0, 0.0, 0.0, 0.0, 1.0, -0.20780947085442231, 0.0, -0.52810302415000854,
|
||||||
|
0.0, 13.239785742831822, 0.0, 58.601480177829842, 0.0, 0.0, 1.0, 0.0 },
|
||||||
|
|
||||||
|
// Expression: C
|
||||||
|
// Referenced by: '<Root>/Gain6'
|
||||||
|
|
||||||
|
{ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0 },
|
||||||
|
|
||||||
|
// Expression: L
|
||||||
|
// Referenced by: '<Root>/Gain2'
|
||||||
|
|
||||||
|
{ 116.63033952875418, 3387.8673967111704, -1.4473912197449676,
|
||||||
|
-115.34372132703447, -1.0534041975488044, -48.223441605702455,
|
||||||
|
117.16185100039935, 3490.0480780568214 },
|
||||||
|
|
||||||
|
// Expression: B
|
||||||
|
// Referenced by: '<Root>/Gain3'
|
||||||
|
|
||||||
|
{ 0.0, 2.078094708544223, 0.0, 5.2810302415000852 }
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// File trailer for generated code.
|
||||||
|
//
|
||||||
|
// [EOF]
|
||||||
|
//
|
BIN
simulink_export_no_kalman/buildInfo.mat
Normal file
BIN
simulink_export_no_kalman/buildInfo.mat
Normal file
Binary file not shown.
BIN
simulink_export_no_kalman/build_exception.mat
Normal file
BIN
simulink_export_no_kalman/build_exception.mat
Normal file
Binary file not shown.
BIN
simulink_export_no_kalman/codeInfo.mat
Normal file
BIN
simulink_export_no_kalman/codeInfo.mat
Normal file
Binary file not shown.
BIN
simulink_export_no_kalman/codedescriptor.dmr
Normal file
BIN
simulink_export_no_kalman/codedescriptor.dmr
Normal file
Binary file not shown.
14
simulink_export_no_kalman/defines.txt
Normal file
14
simulink_export_no_kalman/defines.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
MODEL=Arduino_skal
|
||||||
|
NUMST=2
|
||||||
|
NCSTATES=4
|
||||||
|
HAVESTDIO
|
||||||
|
MODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0
|
||||||
|
CLASSIC_INTERFACE=0
|
||||||
|
ALLOCATIONFCN=0
|
||||||
|
TID01EQ=1
|
||||||
|
TERMFCN=0
|
||||||
|
ONESTEPFCN=1
|
||||||
|
MAT_FILE=0
|
||||||
|
MULTI_INSTANCE_CODE=1
|
||||||
|
INTEGER_CODE=0
|
||||||
|
MT=0
|
102
simulink_export_no_kalman/ert_main.cpp
Normal file
102
simulink_export_no_kalman/ert_main.cpp
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
//
|
||||||
|
// Academic License - for use in teaching, academic research, and meeting
|
||||||
|
// course requirements at degree granting institutions only. Not for
|
||||||
|
// government, commercial, or other organizational use.
|
||||||
|
//
|
||||||
|
// File: ert_main.cpp
|
||||||
|
//
|
||||||
|
// Code generated for Simulink model 'Arduino_skal'.
|
||||||
|
//
|
||||||
|
// Model version : 1.1
|
||||||
|
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||||
|
// C/C++ source code generated on : Thu Apr 15 22:06:00 2021
|
||||||
|
//
|
||||||
|
// Target selection: ert.tlc
|
||||||
|
// Embedded hardware selection: AMD->x86-64 (Windows64)
|
||||||
|
// Code generation objectives:
|
||||||
|
// 1. Execution efficiency
|
||||||
|
// 2. RAM efficiency
|
||||||
|
// Validation result: Not run
|
||||||
|
//
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h> // This ert_main.c example uses printf/fflush
|
||||||
|
#include "Arduino_skal.h" // Model's header file
|
||||||
|
#include "rtwtypes.h"
|
||||||
|
|
||||||
|
static Arduino_skalModelClass rtObj; // Instance of model class
|
||||||
|
|
||||||
|
//
|
||||||
|
// Associating rt_OneStep with a real-time clock or interrupt service routine
|
||||||
|
// is what makes the generated code "real-time". The function rt_OneStep is
|
||||||
|
// always associated with the base rate of the model. Subrates are managed
|
||||||
|
// by the base rate from inside the generated code. Enabling/disabling
|
||||||
|
// interrupts and floating point context switches are target specific. This
|
||||||
|
// example code indicates where these should take place relative to executing
|
||||||
|
// the generated code step function. Overrun behavior should be tailored to
|
||||||
|
// your application needs. This example simply sets an error status in the
|
||||||
|
// real-time model and returns from rt_OneStep.
|
||||||
|
//
|
||||||
|
void rt_OneStep(void);
|
||||||
|
void rt_OneStep(void)
|
||||||
|
{
|
||||||
|
static boolean_T OverrunFlag = false;
|
||||||
|
|
||||||
|
// Disable interrupts here
|
||||||
|
|
||||||
|
// Check for overrun
|
||||||
|
if (OverrunFlag) {
|
||||||
|
rtmSetErrorStatus(rtObj.getRTM(), "Overrun");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OverrunFlag = true;
|
||||||
|
|
||||||
|
// Save FPU context here (if necessary)
|
||||||
|
// Re-enable timer or interrupt here
|
||||||
|
// Set model inputs here
|
||||||
|
|
||||||
|
// Step the model for base rate
|
||||||
|
rtObj.step();
|
||||||
|
|
||||||
|
// Get model outputs here
|
||||||
|
|
||||||
|
// Indicate task complete
|
||||||
|
OverrunFlag = false;
|
||||||
|
|
||||||
|
// Disable interrupts here
|
||||||
|
// Restore FPU context here (if necessary)
|
||||||
|
// Enable interrupts here
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// The example "main" function illustrates what is required by your
|
||||||
|
// application code to initialize, execute, and terminate the generated code.
|
||||||
|
// Attaching rt_OneStep to a real-time clock is target specific. This example
|
||||||
|
// illustrates how you do this relative to initializing the model.
|
||||||
|
//
|
||||||
|
int_T main(int_T argc, const char *argv[])
|
||||||
|
{
|
||||||
|
// Unused arguments
|
||||||
|
(void)(argc);
|
||||||
|
(void)(argv);
|
||||||
|
|
||||||
|
// Initialize model
|
||||||
|
rtObj.initialize();
|
||||||
|
|
||||||
|
// Simulating the model step behavior (in non real-time) to
|
||||||
|
// simulate model behavior at stop time.
|
||||||
|
|
||||||
|
while ((rtmGetErrorStatus(rtObj.getRTM()) == (NULL)) && !rtmGetStopRequested
|
||||||
|
(rtObj.getRTM())) {
|
||||||
|
rt_OneStep();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable rt_OneStep() here
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// File trailer for generated code.
|
||||||
|
//
|
||||||
|
// [EOF]
|
||||||
|
//
|
BIN
simulink_export_no_kalman/make_exception.mat
Normal file
BIN
simulink_export_no_kalman/make_exception.mat
Normal file
Binary file not shown.
2
simulink_export_no_kalman/modelsources.txt
Normal file
2
simulink_export_no_kalman/modelsources.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Arduino_skal.cpp
|
||||||
|
|
4
simulink_export_no_kalman/rtw_proj.tmw
Normal file
4
simulink_export_no_kalman/rtw_proj.tmw
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Simulink Coder project for Arduino_skal using . MATLAB root = C:\Program Files\MATLAB\R2021a. SimStruct date: 15-Nov-2020 02:10:14
|
||||||
|
This file is generated by Simulink Coder for use by the make utility
|
||||||
|
to determine when to rebuild objects when the name of the current Simulink Coder project changes.
|
||||||
|
The rtwinfomat located at: ..\slprj\ert\Arduino_skal\tmwinternal\binfo.mat
|
106
simulink_export_no_kalman/rtwtypes.h
Normal file
106
simulink_export_no_kalman/rtwtypes.h
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
//
|
||||||
|
// Academic License - for use in teaching, academic research, and meeting
|
||||||
|
// course requirements at degree granting institutions only. Not for
|
||||||
|
// government, commercial, or other organizational use.
|
||||||
|
//
|
||||||
|
// File: rtwtypes.h
|
||||||
|
//
|
||||||
|
// Code generated for Simulink model 'Arduino_skal'.
|
||||||
|
//
|
||||||
|
// Model version : 1.1
|
||||||
|
// Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
|
||||||
|
// C/C++ source code generated on : Thu Apr 15 22:06:00 2021
|
||||||
|
//
|
||||||
|
// Target selection: ert.tlc
|
||||||
|
// Embedded hardware selection: AMD->x86-64 (Windows64)
|
||||||
|
// Code generation objectives:
|
||||||
|
// 1. Execution efficiency
|
||||||
|
// 2. RAM efficiency
|
||||||
|
// Validation result: Not run
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef RTWTYPES_H
|
||||||
|
#define RTWTYPES_H
|
||||||
|
|
||||||
|
// Logical type definitions
|
||||||
|
#if (!defined(__cplusplus))
|
||||||
|
#ifndef false
|
||||||
|
#define false (0U)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef true
|
||||||
|
#define true (1U)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//=======================================================================*
|
||||||
|
// Target hardware information
|
||||||
|
// Device type: AMD->x86-64 (Windows64)
|
||||||
|
// Number of bits: char: 8 short: 16 int: 32
|
||||||
|
// long: 32 long long: 64
|
||||||
|
// native word size: 64
|
||||||
|
// Byte ordering: LittleEndian
|
||||||
|
// Signed integer division rounds to: Zero
|
||||||
|
// Shift right on a signed integer as arithmetic shift: on
|
||||||
|
// =======================================================================
|
||||||
|
|
||||||
|
//=======================================================================*
|
||||||
|
// Fixed width word size data types: *
|
||||||
|
// int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
|
||||||
|
// uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
|
||||||
|
// real32_T, real64_T - 32 and 64 bit floating point numbers *
|
||||||
|
// =======================================================================
|
||||||
|
typedef signed char int8_T;
|
||||||
|
typedef unsigned char uint8_T;
|
||||||
|
typedef short int16_T;
|
||||||
|
typedef unsigned short uint16_T;
|
||||||
|
typedef int int32_T;
|
||||||
|
typedef unsigned int uint32_T;
|
||||||
|
typedef long long int64_T;
|
||||||
|
typedef unsigned long long uint64_T;
|
||||||
|
typedef float real32_T;
|
||||||
|
typedef double real64_T;
|
||||||
|
|
||||||
|
//===========================================================================*
|
||||||
|
// Generic type definitions: boolean_T, char_T, byte_T, int_T, uint_T, *
|
||||||
|
// real_T, time_T, ulong_T, ulonglong_T. *
|
||||||
|
// ===========================================================================
|
||||||
|
typedef double real_T;
|
||||||
|
typedef double time_T;
|
||||||
|
typedef unsigned char boolean_T;
|
||||||
|
typedef int int_T;
|
||||||
|
typedef unsigned int uint_T;
|
||||||
|
typedef unsigned long ulong_T;
|
||||||
|
typedef unsigned long long ulonglong_T;
|
||||||
|
typedef char char_T;
|
||||||
|
typedef unsigned char uchar_T;
|
||||||
|
typedef char_T byte_T;
|
||||||
|
|
||||||
|
//=======================================================================*
|
||||||
|
// Min and Max: *
|
||||||
|
// int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
|
||||||
|
// uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
|
||||||
|
// =======================================================================
|
||||||
|
#define MAX_int8_T ((int8_T)(127))
|
||||||
|
#define MIN_int8_T ((int8_T)(-128))
|
||||||
|
#define MAX_uint8_T ((uint8_T)(255U))
|
||||||
|
#define MAX_int16_T ((int16_T)(32767))
|
||||||
|
#define MIN_int16_T ((int16_T)(-32768))
|
||||||
|
#define MAX_uint16_T ((uint16_T)(65535U))
|
||||||
|
#define MAX_int32_T ((int32_T)(2147483647))
|
||||||
|
#define MIN_int32_T ((int32_T)(-2147483647-1))
|
||||||
|
#define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU))
|
||||||
|
#define MAX_int64_T ((int64_T)(9223372036854775807LL))
|
||||||
|
#define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL))
|
||||||
|
#define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFULL))
|
||||||
|
|
||||||
|
// Block D-Work pointer type
|
||||||
|
typedef void * pointer_T;
|
||||||
|
|
||||||
|
#endif // RTWTYPES_H
|
||||||
|
|
||||||
|
//
|
||||||
|
// File trailer for generated code.
|
||||||
|
//
|
||||||
|
// [EOF]
|
||||||
|
//
|
BIN
simulink_export_no_kalman/rtwtypeschksum.mat
Normal file
BIN
simulink_export_no_kalman/rtwtypeschksum.mat
Normal file
Binary file not shown.
6
simulink_export_no_kalman/tmwinternal/simulink_cache.xml
Normal file
6
simulink_export_no_kalman/tmwinternal/simulink_cache.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<MF0 version="1.1" packageUris="http://schema.mathworks.com/mf0/SlCache/19700101">
|
||||||
|
<slcache.FileAttributes type="slcache.FileAttributes" uuid="25501367-5862-4c38-9446-3a10b71f5dfd">
|
||||||
|
<checksum>jUWCD6upU5eKEHQT+1NwAiXXhPHl8CuLumYkuZ/nhqUqt9Bgq71EB7eSu+x+mM96egeRAwLhm/aq3c0y4CL1kg==</checksum>
|
||||||
|
</slcache.FileAttributes>
|
||||||
|
</MF0>
|
BIN
simulink_export_no_kalman/tmwinternal/tr
Normal file
BIN
simulink_export_no_kalman/tmwinternal/tr
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user