|
|
|
@ -338,17 +338,27 @@ void AP_Camera::send_feedback(mavlink_channel_t chan)
@@ -338,17 +338,27 @@ void AP_Camera::send_feedback(mavlink_channel_t chan)
|
|
|
|
|
altitude_rel = current_loc.alt - ahrs.get_home().alt; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ant_ned = camera_pos_rotation(ant_offset); |
|
|
|
|
mavlink_msg_camera_feedback_send( |
|
|
|
|
chan, |
|
|
|
|
AP::gps().time_epoch_usec(), |
|
|
|
|
0, 0, _image_index, |
|
|
|
|
current_loc.lat, current_loc.lng, |
|
|
|
|
altitude*1e-2f, altitude_rel*1e-2f, |
|
|
|
|
ahrs.roll_sensor*1e-2f, ahrs.pitch_sensor*1e-2f, ahrs.yaw_sensor*1e-2f, |
|
|
|
|
ant_ned.x, ant_ned.y, ant_ned.z, |
|
|
|
|
0.0f, CAMERA_FEEDBACK_PHOTO, _camera_trigger_logged); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Vector3f AP_Camera::camera_pos_rotation(Vector3f offset) |
|
|
|
|
{ |
|
|
|
|
Matrix3f Tbn; // dcm rotation matrix to rotate body frame to north
|
|
|
|
|
Vector3f cam_pos_ned; |
|
|
|
|
|
|
|
|
|
const AP_AHRS &ahrs = AP::ahrs(); |
|
|
|
|
Tbn = ahrs.get_rotation_body_to_ned(); |
|
|
|
|
cam_pos_ned = Tbn * (offset); |
|
|
|
|
return cam_pos_ned; |
|
|
|
|
} |
|
|
|
|
/* update; triggers by distance moved
|
|
|
|
|
*/ |
|
|
|
|
void AP_Camera::update() |
|
|
|
@ -390,6 +400,7 @@ void AP_Camera::update()
@@ -390,6 +400,7 @@ void AP_Camera::update()
|
|
|
|
|
take_picture(); |
|
|
|
|
|
|
|
|
|
_last_location = current_loc; |
|
|
|
|
ant_ned = camera_pos_rotation(ant_offset); |
|
|
|
|
_last_photo_time = tnow; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -402,6 +413,7 @@ void AP_Camera::feedback_pin_isr(uint8_t pin, bool high, uint32_t timestamp_us)
@@ -402,6 +413,7 @@ void AP_Camera::feedback_pin_isr(uint8_t pin, bool high, uint32_t timestamp_us)
|
|
|
|
|
if(timestamp_us - last_timestamp_us > _min_time_interval * 1000){ |
|
|
|
|
last_timestamp_us = timestamp_us; |
|
|
|
|
_feedback_timestamp_us = timestamp_us; |
|
|
|
|
ant_ned = camera_pos_rotation(ant_offset); |
|
|
|
|
_camera_trigger_count++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -416,6 +428,7 @@ void AP_Camera::feedback_pin_timer(void)
@@ -416,6 +428,7 @@ void AP_Camera::feedback_pin_timer(void)
|
|
|
|
|
if (pin_state == trigger_polarity && |
|
|
|
|
_last_pin_state != trigger_polarity) { |
|
|
|
|
_feedback_timestamp_us = AP_HAL::micros(); |
|
|
|
|
ant_ned = camera_pos_rotation(ant_offset); |
|
|
|
|
_camera_trigger_count++; |
|
|
|
|
} |
|
|
|
|
_last_pin_state = pin_state; |
|
|
|
@ -460,14 +473,14 @@ void AP_Camera::log_picture()
@@ -460,14 +473,14 @@ void AP_Camera::log_picture()
|
|
|
|
|
if (!using_feedback_pin()) { |
|
|
|
|
gcs().send_message(MSG_CAMERA_FEEDBACK); |
|
|
|
|
if (logger->should_log(log_camera_bit)) { |
|
|
|
|
logger->Write_Camera(current_loc); |
|
|
|
|
logger->Write_Camera(current_loc,ant_ned); |
|
|
|
|
last_pos_lat = current_loc.lat; |
|
|
|
|
last_pos_lng = current_loc.lng; |
|
|
|
|
_image_index_log++; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (logger->should_log(log_camera_bit)) { |
|
|
|
|
logger->Write_Trigger(current_loc); |
|
|
|
|
logger->Write_Trigger(current_loc,ant_ned); |
|
|
|
|
last_pos_lat = current_loc.lat; |
|
|
|
|
last_pos_lng = current_loc.lng; |
|
|
|
|
_image_index_log++; |
|
|
|
@ -507,7 +520,7 @@ void AP_Camera::update_trigger()
@@ -507,7 +520,7 @@ void AP_Camera::update_trigger()
|
|
|
|
|
if (logger->should_log(log_camera_bit)) { |
|
|
|
|
uint32_t tdiff = AP_HAL::micros() - timestamp32; |
|
|
|
|
uint64_t timestamp = AP_HAL::micros64(); |
|
|
|
|
logger->Write_Camera(current_loc, timestamp - tdiff); |
|
|
|
|
logger->Write_Camera(current_loc,ant_ned, timestamp - tdiff); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|