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
cam_roll.c
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2003-2011 Pascal Brisset, Antoine Drouin
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  */
28 #include <math.h>
29 #include "cam.h"
30 #include "subsystems/nav.h"
31 #include "autopilot.h"
32 #include "generated/flight_plan.h"
33 #include "estimator.h"
34 #include "inter_mcu.h"
35 
36 #ifndef CAM_PHI_MAX
37 #define CAM_PHI_MAX RadOfDeg(45)
38 #endif
39 
40 float cam_roll_phi; /* radian */
41 float phi_c; /* radian */
42 float theta_c; /* have to be defined for telemetry message */
43 
45 
46 #ifdef MOBILE_CAM
47 
48 #define MODE_MANUAL 0
49 #define MODE_STABILIZED 1
50 
52 bool_t cam_roll_switch;
53 
54 void cam_init( void ) {
55  cam_roll_switch = 0;
56 #if defined VIDEO_SWITCH_PIN && !(defined SITL)
57  IO0DIR |= _BV(VIDEO_SWITCH_PIN);
58  IO0CLR = _BV(VIDEO_SWITCH_PIN);
59 #endif
60 }
61 
62 void cam_periodic( void ) {
63  switch (cam_roll_mode) {
64  case MODE_STABILIZED:
66  break;
67  case MODE_MANUAL:
69  break;
70  default:
71  phi_c = 0;
72  }
73  ap_state->commands[COMMAND_CAM_ROLL] = TRIM_PPRZ(phi_c * MAX_PPRZ / CAM_PHI_MAX);
74 }
75 
76 #endif // MOBILE_CAM
float estimator_phi
roll angle in rad, + = right
Definition: estimator.c:49
float theta_c
Definition: cam_roll.c:42
struct ap_state * ap_state
Definition: inter_mcu.c:35
bool_t cam_roll_switch
void cam_periodic(void)
For CAM_MODE_AC_TARGET mode.
Definition: cam.c:107
float phi_c
Definition: cam_roll.c:41
float target_x
Definition: cam_roll.c:44
float target_y
Definition: cam_roll.c:44
#define CAM_PHI_MAX
Definition: cam_roll.c:37
#define IO0CLR
Definition: LPC21xx.h:304
#define IO0DIR
Definition: LPC21xx.h:303
float target_alt
Definition: cam_roll.c:44
unsigned char uint8_t
Definition: types.h:14
void cam_init(void)
Definition: cam.c:103
uint8_t cam_roll_mode
State estimation, fusioning sensors.
Pan/Tilt camera API.
float cam_roll_phi
Definition: cam_roll.c:40
#define MODE_MANUAL
Definition: autopilot.h:71
#define MAX_PPRZ
Definition: paparazzi.h:8
#define TRIM_PPRZ(pprz)
Definition: paparazzi.h:11