Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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 "modules/core/commmands.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  command_set(COMMAND_CAM_ROLL, TRIM_PPRZ(phi_c * MAX_PPRZ / CAM_PHI_MAX));
75 }
76 
77 #endif // MOBILE_CAM
Core autopilot interface common to all firmwares.
void cam_periodic(void)
For CAM_MODE_AC_TARGET mode.
Definition: cam.c:129
void cam_init(void)
Definition: cam.c:119
Pan/Tilt camera API.
float cam_roll_phi
Definition: cam_roll.c:40
float target_x
Definition: cam_roll.c:44
#define CAM_PHI_MAX
Definition: cam_roll.c:37
float target_y
Definition: cam_roll.c:44
float phi_c
Definition: cam_roll.c:41
float theta_c
Definition: cam_roll.c:42
float target_alt
Definition: cam_roll.c:44
uint8_t cam_roll_mode
float phi
in radians
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition: state.h:1143
Fixedwing Navigation library.
#define MAX_PPRZ
Definition: paparazzi.h:8
#define TRIM_PPRZ(pprz)
Definition: paparazzi.h:11
#define MODE_MANUAL
Default RC mode.
API to get/set the generic vehicle states.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98