Browse Source

AP_Camera: added CAM_TRIGG_DIST parameter

for triggering every N meters of GPS distance travelled
master
Andrew Tridgell 12 years ago
parent
commit
169b5a30a5
  1. 28
      libraries/AP_Camera/AP_Camera.cpp
  2. 5
      libraries/AP_Camera/AP_Camera.h

28
libraries/AP_Camera/AP_Camera.cpp

@ -41,6 +41,13 @@ const AP_Param::GroupInfo AP_Camera::var_info[] PROGMEM = { @@ -41,6 +41,13 @@ const AP_Param::GroupInfo AP_Camera::var_info[] PROGMEM = {
// @User: Standard
AP_GROUPINFO("SERVO_OFF", 3, AP_Camera, _servo_off_pwm, AP_CAMERA_SERVO_OFF_PWM),
// @Param: TRIGG_DIST
// @DisplayName: Camera trigger distance
// @Description: Distance in meters between camera triggers. If this value is non-zero then the camera will trigger whenever the GPS position changes by this number of meters regardless of what mode the APM is in
// @User: Standard
// @Range: 0 1000
AP_GROUPINFO("TRIGG_DIST", 4, AP_Camera, _trigg_dist, 0),
AP_GROUPEND
};
@ -209,3 +216,24 @@ AP_Camera::control_msg(mavlink_message_t* msg) @@ -209,3 +216,24 @@ AP_Camera::control_msg(mavlink_message_t* msg)
}
// update location, for triggering by GPS distance moved
void AP_Camera::update_location(const struct Location &loc)
{
if (_trigg_dist == 0.0f) {
return;
}
if (_last_location.lat == 0 && _last_location.lng == 0) {
_last_location = loc;
return;
}
if (_last_location.lat == loc.lat && _last_location.lng == loc.lng) {
// we haven't moved - this can happen as update_location() may
// be called without a new GPS fix
return;
}
if (get_distance(&loc, &_last_location) < _trigg_dist) {
return;
}
_last_location = loc;
trigger_pic();
}

5
libraries/AP_Camera/AP_Camera.h

@ -54,6 +54,8 @@ public: @@ -54,6 +54,8 @@ public:
void configure_msg(mavlink_message_t* msg);
void control_msg(mavlink_message_t* msg);
void update_location(const struct Location &loc);
static const struct AP_Param::GroupInfo var_info[];
private:
@ -70,6 +72,9 @@ private: @@ -70,6 +72,9 @@ private:
void throttle_pic(); // pictures blurry? use this trigger. Turns off the throttle until for # of cycles of medium loop then takes the picture and re-enables the throttle.
void distance_pic(); // pictures blurry? use this trigger. Turns off the throttle until closer to waypoint then takes the picture and re-enables the throttle.
void transistor_pic(); // hacked the circuit to run a transistor? use this trigger to send output.
AP_Float _trigg_dist; // distance between trigger points (meters)
struct Location _last_location;
};

Loading…
Cancel
Save