1
/*
2
* File: GlobalPosition_demo_ec.c
3
*
4
* Code generated for Simulink model 'GlobalPosition_demo_ec'.
5
*
6
* Model version : 1.25
7
* Simulink Coder version : 9.0 (R2018b) 24-May-2018
8
* C/C++ source code generated on : Tue Oct 29 09:31:22 2019
9
*
10
* Target selection: ert.tlc
11
* Embedded hardware selection: Intel->x86-64 (Windows64)
12
* Code generation objectives:
13
* 1. Execution efficiency
14
* 2. RAM efficiency
15
* Validation result: Not run
16
*/
17
18
#include "GlobalPosition_demo_ec.h"
19
20
/* Macros for accessing real-time model data structure */
21
#ifndef
rtmGetErrorStatus
22
# define
rtmGetErrorStatus
(
rtm
) (
*
((
rtm
)->
errorStatus
))
23
#endif
24
25
#ifndef
rtmSetErrorStatus
26
# define
rtmSetErrorStatus
(
rtm
,
val
) (
*
((
rtm
)->
errorStatus
) = (
val
))
27
#endif
28
29
#ifndef
rtmGetErrorStatusPointer
30
# define
rtmGetErrorStatusPointer
(
rtm
) (
rtm
)->
errorStatus
31
#endif
32
33
#ifndef
rtmSetErrorStatusPointer
34
# define
rtmSetErrorStatusPointer
(
rtm
,
val
) ((
rtm
)->
errorStatus
= (
val
))
35
#endif
36
37
P_GlobalPosition_demo_ec_T
GlobalPosition_demo_ec_P
=
{
38
/* Expression: 0
39
* Referenced by: '
<S1>/Unit Delay
'
40
*/
41
0.0,
42
43
/* Expression: 0
44
* Referenced by: '
<S1>/Unit Delay1
'
45
*/
46
0.0
47
}
;
48
49
/* System initialize for referenced model: 'GlobalPosition_demo_ec' */
50
void
GlobalPosition_demo_ec_Init
(
DW_GlobalPosition_demo_ec_f_T
*
localDW
)
51
{
52
/* InitializeConditions for UnitDelay: '
<S1>/Unit Delay
' */
53
localDW
->
UnitDelay_DSTATE
=
54
GlobalPosition_demo_ec_P
.
UnitDelay_InitialCondition
;
55
56
/* InitializeConditions for UnitDelay: '
<S1>/Unit Delay1
' */
57
localDW
->
UnitDelay1_DSTATE
=
58
GlobalPosition_demo_ec_P
.
UnitDelay1_InitialCondition
;
59
}
60
61
/* Output and update for referenced model: 'GlobalPosition_demo_ec' */
62
void
GlobalPosition_demo_ec
(
const
int32_T
*
rtu_sensorBus_driveEncoder
,
const
63
real_T
*
rtu_sensorBus_gyroAngleRad
,
real_T
rty_posGlobal
[2],
64
DW_GlobalPosition_demo_ec_f_T
*
localDW
)
65
{
66
real_T
rtb_s_k
;
67
real_T
rtb_xPosGlobal
;
68
69
/* Product: '
<S1>/conv_way
' incorporates:
70
* Constant: '
<S1>/WHEEL_SIZE_DEG
'
71
* Constant: '
<S1>/WHEEL_SIZE_DEG1
'
72
* DataTypeConversion: '
<S1>/DataTypeConversion
'
73
*/
74
rtb_s_k
= (
real_T
)
*
rtu_sensorBus_driveEncoder
*
rtP_WHEEL_SIZE_DEG
*
75
rtP_MOTOR_DRIVE_TRANSMISSION_RATIO
;
76
77
/* Sum: '
<S1>/Add
' incorporates:
78
* Product: '
<S1>/Product2
'
79
* Trigonometry: '
<S1>/Trigonometric Function1
'
80
* UnitDelay: '
<S1>/Unit Delay
'
81
*/
82
rtb_xPosGlobal
=
cos
(
*
rtu_sensorBus_gyroAngleRad
)
*
rtb_s_k
+
83
localDW
->
UnitDelay_DSTATE
;
84
85
/* Sum: '
<S1>/Add1
' incorporates:
86
* Product: '
<S1>/Product3
'
87
* Trigonometry: '
<S1>/Trigonometric Function
'
88
* UnitDelay: '
<S1>/Unit Delay1
'
89
*/
90
rtb_s_k
=
sin
(
*
rtu_sensorBus_gyroAngleRad
)
*
rtb_s_k
+
91
localDW
->
UnitDelay1_DSTATE
;
92
93
/* SignalConversion: '
<Root>/TmpSignal ConversionAtposGlobalInport1
' */
94
rty_posGlobal
[0] =
rtb_xPosGlobal
;
95
rty_posGlobal
[1] =
rtb_s_k
;
96
97
/* Update for UnitDelay: '
<S1>/Unit Delay
' */
98
localDW
->
UnitDelay_DSTATE
=
rtb_xPosGlobal
;
99
100
/* Update for UnitDelay: '
<S1>/Unit Delay1
' */
101
localDW
->
UnitDelay1_DSTATE
=
rtb_s_k
;
102
}
103
104
/* Model initialize function */
105
void
GlobalPosition_demo__initialize
(
const
char_T
*
*
rt_errorStatus
,
106
RT_MODEL_GlobalPosition_demo__T
*
const
GlobalPosition_demo_ec_M
)
107
{
108
/* Registration code */
109
110
/* initialize error status */
111
rtmSetErrorStatusPointer
(
GlobalPosition_demo_ec_M
,
rt_errorStatus
);
112
}
113
114
/*
115
* File trailer for generated code.
116
*
117
* [EOF]
118
*/
119