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