Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
infrared.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003-2010 The Paparazzi Team
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
23 #ifndef SUBSYSTEMS_SENSORS_INFRARED_H
24 #define SUBSYSTEMS_SENSORS_INFRARED_H
25 
26 #include "std.h"
27 #include "generated/airframe.h"
28 
29 /*
30  * Sensor installation
31  */
32 
33 #ifndef IR_IR1_SIGN
34 #define IR_IR1_SIGN 1
35 #endif /* IR_IR1_SIGN */
36 
37 #ifndef IR_IR2_SIGN
38 #define IR_IR2_SIGN 1
39 #endif /* IR_IR2_SIGN */
40 
41 #ifndef IR_TOP_SIGN
42 #define IR_TOP_SIGN 1
43 #endif /* IR_TOP_SIGN */
44 
45 #if defined IR_HORIZ_SENSOR_ALIGNED
46 /* IR1 on the lateral axis, IR2 on the longitudal axis */
47 #define IR_RollOfIrs(_ir1, _ir2) (_ir1)
48 #define IR_PitchOfIrs(_ir1, _ir2) (_ir2)
49 #elif IR_HORIZ_SENSOR_TILTED
50 /* IR1 rear-left -- front-right, IR2 rear-right -- front-left
51  IR1_SIGN and IR2_SIGN give positive values when it's warm on the right side
52 */
53 #define IR_RollOfIrs(_ir1, _ir2) (_ir1 + _ir2)
54 #define IR_PitchOfIrs(_ir1, _ir2) (-(_ir1) + _ir2)
55 #else
56 #ifndef SITL
57 #error "You have to define either HORIZ_SENSOR_ALIGNED or HORIZ_SENSOR_TILTED in the IR section"
58 #endif
59 #endif
60 /* Vertical sensor, TOP_SIGN gives positice values when it's warm on the bottom */
61 #ifndef IR_TopOfIr
62 #define IR_TopOfIr(_ir) (_ir)
63 #endif
64 
65 /*
66  * Default correction values
67  */
68 
69 #ifndef IR_LATERAL_CORRECTION
70 #define IR_LATERAL_CORRECTION 1.
71 #endif
72 
73 #ifndef IR_LONGITUDINAL_CORRECTION
74 #define IR_LONGITUDINAL_CORRECTION 1.
75 #endif
76 
77 #ifndef IR_VERTICAL_CORRECTION
78 #define IR_VERTICAL_CORRECTION 1.
79 #endif
80 
81 #ifndef IR_CORRECTION_LEFT
82 #define IR_CORRECTION_LEFT 1.
83 #endif
84 
85 #ifndef IR_CORRECTION_RIGHT
86 #define IR_CORRECTION_RIGHT 1.
87 #endif
88 
89 #ifndef IR_CORRECTION_UP
90 #define IR_CORRECTION_UP 1.
91 #endif
92 
93 #ifndef IR_CORRECTION_DOWN
94 #define IR_CORRECTION_DOWN 1.
95 #endif
96 
97 
98 /*
99  * Default neutral values
100  */
101 #ifndef IR_ROLL_NEUTRAL_DEFAULT
102 #define IR_ROLL_NEUTRAL_DEFAULT 0.0
103 #endif
104 
105 #ifndef IR_PITCH_NEUTRAL_DEFAULT
106 #define IR_PITCH_NEUTRAL_DEFAULT 0.0
107 #endif
108 
109 struct Infrared_raw {
110  /* the 3 channels of the sensor
111  */
115 };
116 
118 struct Infrared {
119  /* raw infrared values
120  */
122  /* neutrals in radians
123  */
127  /* roll, pitch, top unscaled reading
128  */
132  /* coefficients used to compensate
133  for sensors sensitivity
134  */
138  /* coefficients used to compensate
139  for masking
140  */
145 };
146 
147 extern struct Infrared infrared;
148 
149 #define UpdateIRValue(_v) { \
150  infrared.value.ir1 = (IR_IR1_SIGN)*_v.ir1; \
151  infrared.value.ir2 = (IR_IR2_SIGN)*_v.ir2; \
152  infrared.value.ir3 = (IR_TOP_SIGN)*_v.ir3; \
153  infrared.roll = infrared.lateral_correction * IR_RollOfIrs(infrared.value.ir1, infrared.value.ir2); \
154  infrared.pitch = infrared.longitudinal_correction * IR_PitchOfIrs(infrared.value.ir1, infrared.value.ir2); \
155  infrared.top = infrared.vertical_correction * IR_TopOfIr(infrared.value.ir3); \
156 }
157 
158 // initialization of the infrared structure
159 void infrared_struct_init(void);
160 
161 // implementation dependent functions
162 void infrared_init(void);
163 void infrared_update(void);
164 void infrared_event(void);
165 
166 #endif /* SUBSYSTEMS_SENSORS_INFRARED_H */
float roll_neutral
Definition: infrared.h:124
float longitudinal_correction
Definition: infrared.h:136
void infrared_init(void)
Definition: infrared_adc.c:55
int16_t ir2
Definition: infrared.h:113
void infrared_struct_init(void)
Initialisation of ir structure.
Definition: infrared.c:38
float pitch_neutral
Definition: infrared.h:125
float vertical_correction
Definition: infrared.h:137
float pitch_vneutral
Definition: infrared.h:126
float correction_left
Definition: infrared.h:141
Infrared structure.
Definition: infrared.h:118
float correction_down
Definition: infrared.h:144
void infrared_event(void)
Definition: infrared_adc.c:64
struct Infrared infrared
Definition: infrared.c:34
int16_t roll
Definition: infrared.h:129
signed short int16_t
Definition: types.h:17
float lateral_correction
Definition: infrared.h:135
float correction_right
Definition: infrared.h:142
struct Infrared_raw value
Definition: infrared.h:121
float correction_up
Definition: infrared.h:143
int16_t ir1
Definition: infrared.h:112
void infrared_update(void)
Definition: infrared_adc.c:59
int16_t pitch
Definition: infrared.h:130
int16_t top
Definition: infrared.h:131
int16_t ir3
Definition: infrared.h:114