Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cam.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005- Pascal Brisset, Antoine Drouin
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
27 #ifndef CAM_H
28 #define CAM_H
29 
30 #include <inttypes.h>
31 #include "inter_mcu.h"
32 
33 #define CAM_MODE_OFF 0 /* Do nothing */
34 #define CAM_MODE_ANGLES 1 /* Input: servo angles */
35 #define CAM_MODE_NADIR 2 /* Input: () */
36 #define CAM_MODE_XY_TARGET 3 /* Input: target_x, target_y */
37 #define CAM_MODE_WP_TARGET 4 /* Input: waypoint no */
38 #define CAM_MODE_AC_TARGET 5 /* Input: ac id */
39 #define CAM_MODE_STABILIZED 6 // Stabilized mode, input: camera angles from the pan and tilt radio channels, output pointing coordinates.
40 #define CAM_MODE_RC 7 // Manual mode, input: camera angles from the pan and tilt radio channels, output servo positions.
41 
42 //FIXME: use radians
43 #ifndef CAM_PAN_MAX
44 #define CAM_PAN_MAX 90
45 #endif
46 #ifndef CAM_PAN_MIN
47 #define CAM_PAN_MIN -90
48 #endif
49 #ifndef CAM_TILT_MAX
50 #define CAM_TILT_MAX 90
51 #endif
52 #ifndef CAM_TILT_MIN
53 #define CAM_TILT_MIN -90
54 #endif
55 
56 extern uint8_t cam_mode;
57 extern uint8_t cam_lock;
58 
59 extern float cam_phi_c, cam_theta_c;
60 
61 extern float cam_pan_c, cam_tilt_c;
62 /* pan (move left and right), tilt (move up and down) */
68 extern uint8_t cam_target_wp;
71 extern uint8_t cam_target_ac;
74 void cam_periodic( void );
75 void cam_init( void );
76 
78 #define cam_SetPanCommand(x) { ap_state->commands[COMMAND_CAM_PAN] = cam_pan_command = x;}
80 #define cam_SetTiltCommand(x) { ap_state->commands[COMMAND_CAM_TILT] = cam_tilt_command = x;}
81 
82 #ifdef TEST_CAM
83 extern float test_cam_estimator_x;
84 extern float test_cam_estimator_y;
85 extern float test_cam_estimator_z;
86 extern float test_cam_estimator_phi;
87 extern float test_cam_estimator_theta;
88 extern float test_cam_estimator_hspeed_dir;
89 #endif // TEST_CAM
90 
91 #if defined(COMMAND_CAM_PWR_SW) || defined(VIDEO_TX_SWITCH)
92 
93 extern bool_t video_tx_state;
94 #define VIDEO_TX_ON() { video_tx_state = 1; 0; }
95 #define VIDEO_TX_OFF() { video_tx_state = 0; 0; }
96 
97 #endif
98 
99 #define SEND_CAM(_trans, _dev) { \
100  int16_t x = cam_target_x; \
101  int16_t y = cam_target_y; \
102  int16_t phi = DegOfRad(cam_phi_c); \
103  int16_t theta = DegOfRad(cam_theta_c); \
104  DOWNLINK_SEND_CAM(_trans, _dev, &phi, &theta, &x, &y); \
105 }
106 
107 #endif // CAM_H
float cam_target_alt
Definition: cam.c:84
void cam_init(void)
Definition: cam.c:114
uint8_t cam_target_ac
For CAM_MODE_WP_TARGET mode.
Definition: cam.c:86
float cam_tilt_c
Definition: cam.c:79
float cam_target_y
Definition: cam.c:84
uint8_t cam_target_wp
For CAM_MODE_XY_TARGET mode.
Definition: cam.c:85
float cam_theta_c
Definition: cam.c:82
uint8_t cam_lock
Definition: cam.c:92
float cam_pan_c
Definition: cam.c:73
signed short int16_t
Definition: types.h:17
uint8_t cam_mode
Definition: cam.c:91
float cam_phi_c
Definition: cam.c:81
unsigned char uint8_t
Definition: types.h:14
void cam_periodic(void)
For CAM_MODE_AC_TARGET mode.
Definition: cam.c:123
float cam_target_x
Radians, for CAM_MODE_ANGLES mode.
Definition: cam.c:84
int16_t cam_pan_command
Definition: cam.c:94
int16_t cam_tilt_command
Definition: cam.c:95