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
rotorcraft_cam.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009-2012 Gautier Hattenberger <gautier.hattenberger@laas.fr>,
3  * Antoine Drouin <poinix@gmail.com>
4  *
5  * This file is part of paparazzi.
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, write to
19  * the Free Software Foundation, 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22 
38 #ifndef ROTORCRAFT_CAM_H
39 #define ROTORCRAFT_CAM_H
40 
41 #include "generated/airframe.h"
42 #include "generated/flight_plan.h"
43 #include "math/pprz_algebra_int.h"
44 #include "std.h"
45 #include "led.h"
46 
47 #define ROTORCRAFT_CAM_MODE_NONE 0
48 #define ROTORCRAFT_CAM_MODE_MANUAL 1
49 #define ROTORCRAFT_CAM_MODE_HEADING 2
50 #define ROTORCRAFT_CAM_MODE_WP 3
51 
53 #ifndef ROTORCRAFT_CAM_DEFAULT_MODE
54 #define ROTORCRAFT_CAM_DEFAULT_MODE ROTORCRAFT_CAM_MODE_NONE
55 #endif
56 
63 #ifndef ROTORCRAFT_CAM_ON
64 #ifdef CAM_SWITCH_LED
65 #define ROTORCRAFT_CAM_ON LED_OFF(CAM_SWITCH_LED)
66 #else
67 #define ROTORCRAFT_CAM_ON {}
68 #endif
69 #endif
70 #ifndef ROTORCRAFT_CAM_OFF
71 #ifdef CAM_SWITCH_LED
72 #define ROTORCRAFT_CAM_OFF LED_ON(CAM_SWITCH_LED)
73 #else
74 #define ROTORCRAFT_CAM_OFF {}
75 #endif
76 #endif
77 
81 #ifdef ROTORCRAFT_CAM_TILT_SERVO
82 #define ROTORCRAFT_CAM_USE_TILT 1
83 #else
84 #define ROTORCRAFT_CAM_USE_TILT 0
85 #endif
86 
89 #if defined ROTORCRAFT_CAM_TILT_ANGLE_MIN && defined ROTORCRAFT_CAM_TILT_ANGLE_MAX && defined ROTORCRAFT_CAM_USE_TILT
90 #define CAM_TA_MIN ANGLE_BFP_OF_REAL(ROTORCRAFT_CAM_TILT_ANGLE_MIN)
91 #define CAM_TA_MAX ANGLE_BFP_OF_REAL(ROTORCRAFT_CAM_TILT_ANGLE_MAX)
92 #define ROTORCRAFT_CAM_USE_TILT_ANGLES 1
93 #endif
94 
98 #ifndef ROTORCRAFT_CAM_USE_PAN
99 #define ROTORCRAFT_CAM_USE_PAN 1
100 #endif
101 
105 #ifndef ROTORCRAFT_CAM_TRACK_WP
106 #ifdef WP_CAM
107 #define ROTORCRAFT_CAM_TRACK_WP WP_CAM
108 #endif
109 #endif
110 
112 
116 
117 extern void rotorcraft_cam_init(void);
118 extern void rotorcraft_cam_periodic(void);
119 
123 #define rotorcraft_cam_SetCamMode(_v) { \
124  rotorcraft_cam_mode = _v; \
125  if (rotorcraft_cam_mode == ROTORCRAFT_CAM_MODE_NONE) { ROTORCRAFT_CAM_OFF; } \
126  else { ROTORCRAFT_CAM_ON; } \
127 }
128 
133 #ifndef ROTORCRAFT_CAM_STICK_TILT_INC
134 #define ROTORCRAFT_CAM_STICK_TILT_INC RadOfDeg(10.)
135 #endif
136 #ifndef ROTORCRAFT_CAM_STICK_PAN_INC
137 #define ROTORCRAFT_CAM_STICK_PAN_INC RadOfDeg(20.)
138 #endif
139 
140 #define ROTORCRAFT_CAM_STICK_PARSE(_dl_buffer) { \
141  rotorcraft_cam_tilt += (int16_t)((ANGLE_BFP_OF_REAL(ROTORCRAFT_CAM_STICK_TILT_INC)/127.)*(float)DL_ROTORCRAFT_CAM_STICK_tilt(_dl_buffer)); \
142  rotorcraft_cam_pan += (int16_t)((ANGLE_BFP_OF_REAL(ROTORCRAFT_CAM_STICK_PAN_INC)/127.)*(float)DL_ROTORCRAFT_CAM_STICK_pan(dl_buffer)); \
143  INT32_COURSE_NORMALIZE(rotorcraft_cam_pan); \
144 }
145 
146 #endif /* ROTORCRAFT_CAM_H */
147 
int16_t rotorcraft_cam_tilt_pwm
void rotorcraft_cam_periodic(void)
signed short int16_t
Definition: types.h:17
void rotorcraft_cam_init(void)
int16_t rotorcraft_cam_pan
unsigned char uint8_t
Definition: types.h:14
int16_t rotorcraft_cam_tilt
arch independent LED (Light Emitting Diodes) API
uint8_t rotorcraft_cam_mode
WP control.
Paparazzi fixed point algebra.