2013-05-29 20:54:53 -03:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2012-06-13 16:00:20 -03:00
|
|
|
|
|
|
|
/// @file AP_Camera.h
|
|
|
|
/// @brief Photo or video camera manager, with EEPROM-backed storage of constants.
|
|
|
|
|
|
|
|
#ifndef AP_CAMERA_H
|
|
|
|
#define AP_CAMERA_H
|
|
|
|
|
2012-12-12 15:48:01 -04:00
|
|
|
#include <AP_Param.h>
|
2012-06-13 16:00:20 -03:00
|
|
|
#include <AP_Common.h>
|
|
|
|
#include <GCS_MAVLink.h>
|
2012-12-17 11:03:51 -04:00
|
|
|
#include <AP_Relay.h>
|
2012-06-13 16:00:20 -03:00
|
|
|
|
2012-12-06 04:46:09 -04:00
|
|
|
#define AP_CAMERA_TRIGGER_TYPE_SERVO 0
|
|
|
|
#define AP_CAMERA_TRIGGER_TYPE_RELAY 1
|
|
|
|
|
|
|
|
#define AP_CAMERA_TRIGGER_DEFAULT_TRIGGER_TYPE AP_CAMERA_TRIGGER_TYPE_SERVO // default is to use servo to trigger camera
|
|
|
|
|
|
|
|
#define AP_CAMERA_TRIGGER_DEFAULT_DURATION 10 // default duration servo or relay is held open in 10ths of a second (i.e. 10 = 1 second)
|
|
|
|
|
|
|
|
#define AP_CAMERA_SERVO_ON_PWM 1300 // default PWM value to move servo to when shutter is activated
|
|
|
|
#define AP_CAMERA_SERVO_OFF_PWM 1100 // default PWM value to move servo to when shutter is deactivated
|
|
|
|
|
2012-06-13 16:00:20 -03:00
|
|
|
/// @class Camera
|
|
|
|
/// @brief Object managing a Photo or video camera
|
2012-08-17 03:09:29 -03:00
|
|
|
class AP_Camera {
|
2012-06-13 16:00:20 -03:00
|
|
|
|
|
|
|
public:
|
2012-08-17 03:09:29 -03:00
|
|
|
/// Constructor
|
|
|
|
///
|
2012-12-17 11:03:51 -04:00
|
|
|
AP_Camera(AP_Relay *obj_relay) :
|
2013-09-24 11:25:54 -03:00
|
|
|
_trigger_counter(0) // count of number of cycles shutter has been held open
|
2012-08-17 03:09:29 -03:00
|
|
|
{
|
2012-12-12 17:43:41 -04:00
|
|
|
AP_Param::setup_object_defaults(this, var_info);
|
2012-12-17 11:03:51 -04:00
|
|
|
_apm_relay = obj_relay;
|
2012-08-17 03:09:29 -03:00
|
|
|
}
|
2012-06-13 16:00:20 -03:00
|
|
|
|
2012-08-17 03:09:29 -03:00
|
|
|
// single entry point to take pictures
|
|
|
|
void trigger_pic();
|
2012-06-13 16:00:20 -03:00
|
|
|
|
2012-08-17 03:09:29 -03:00
|
|
|
// de-activate the trigger after some delay, but without using a delay() function
|
2012-12-06 04:46:09 -04:00
|
|
|
// should be called at 50hz from main program
|
2012-08-17 03:09:29 -03:00
|
|
|
void trigger_pic_cleanup();
|
2012-06-13 16:00:20 -03:00
|
|
|
|
2012-08-17 03:09:29 -03:00
|
|
|
// MAVLink methods
|
|
|
|
void configure_msg(mavlink_message_t* msg);
|
|
|
|
void control_msg(mavlink_message_t* msg);
|
2012-06-13 16:00:20 -03:00
|
|
|
|
2013-10-11 07:29:01 -03:00
|
|
|
// set camera trigger distance in a mission
|
|
|
|
void set_trigger_distance(uint32_t distance_m) { _trigg_dist.set(distance_m); }
|
|
|
|
|
2013-07-09 19:31:25 -03:00
|
|
|
// Update location of vehicle and return true if a picture should be taken
|
|
|
|
bool update_location(const struct Location &loc);
|
2013-06-24 09:39:50 -03:00
|
|
|
|
2012-08-17 03:09:29 -03:00
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
2012-06-13 16:00:20 -03:00
|
|
|
|
|
|
|
private:
|
2012-12-06 04:46:09 -04:00
|
|
|
AP_Int8 _trigger_type; // 0:Servo,1:Relay,2:Servo and turn off throttle,3:Servo when 3m from waypoint,4:transistor
|
|
|
|
AP_Int8 _trigger_duration; // duration in 10ths of a second that the camera shutter is held open
|
|
|
|
AP_Int16 _servo_on_pwm; // PWM value to move servo to when shutter is activated
|
|
|
|
AP_Int16 _servo_off_pwm; // PWM value to move servo to when shutter is deactivated
|
|
|
|
uint8_t _trigger_counter; // count of number of cycles shutter has been held open
|
2012-12-17 11:03:51 -04:00
|
|
|
AP_Relay *_apm_relay; // pointer to relay object from the base class Relay. The subclasses could be AP_Relay_APM1 or AP_Relay_APM2
|
2012-06-13 16:00:20 -03:00
|
|
|
|
2012-08-17 03:09:29 -03:00
|
|
|
void servo_pic(); // Servo operated camera
|
|
|
|
void relay_pic(); // basic relay activation
|
2013-07-09 19:31:25 -03:00
|
|
|
|
2013-06-24 09:39:50 -03:00
|
|
|
AP_Float _trigg_dist; // distance between trigger points (meters)
|
|
|
|
struct Location _last_location;
|
2012-06-13 16:00:20 -03:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* AP_CAMERA_H */
|