Paparazzi UAS  v5.15_devel-112-g521f3cf
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules 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"
31 #include "autopilot.h"
32 #include "generated/flight_plan.h"
33 #include "state.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 
51 #ifndef CAM_ROLL_START_MODE
52 #define CAM_ROLL_START_MODE MODE_MANUAL
53 #endif
54 
56 
57 void cam_init(void)
58 {
59  cam_roll_mode = CAM_ROLL_START_MODE;
60 }
61 
62 void cam_periodic(void)
63 {
64  switch (cam_roll_mode) {
65  case MODE_STABILIZED:
67  break;
68  case MODE_MANUAL:
70  break;
71  default:
72  phi_c = 0;
73  }
74  imcu_set_command(COMMAND_CAM_ROLL, TRIM_PPRZ(phi_c * MAX_PPRZ / CAM_PHI_MAX));
75 }
76 
77 #endif // MOBILE_CAM
Communication between fbw and ap processes.
float phi
in radians
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition: state.h:1143
float theta_c
Definition: cam_roll.c:42
#define MODE_MANUAL
Default RC mode.
void cam_periodic(void)
For CAM_MODE_AC_TARGET mode.
Definition: cam.c:129
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
Core autopilot interface common to all firmwares.
float target_alt
Definition: cam_roll.c:44
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
void cam_init(void)
Definition: cam.c:119
uint8_t cam_roll_mode
Pan/Tilt camera API.
float cam_roll_phi
Definition: cam_roll.c:40
#define MAX_PPRZ
Definition: paparazzi.h:8
#define TRIM_PPRZ(pprz)
Definition: paparazzi.h:11