Josh Henderson
4 years ago
committed by
Andrew Tridgell
4 changed files with 101 additions and 3 deletions
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
#include "AP_Camera.h" |
||||
#include <AP_Logger/AP_Logger.h> |
||||
|
||||
// Write a Camera packet
|
||||
void AP_Camera::Write_CameraInfo(enum LogMessages msg, uint64_t timestamp_us) |
||||
{ |
||||
const AP_AHRS &ahrs = AP::ahrs(); |
||||
|
||||
int32_t altitude, altitude_rel, altitude_gps; |
||||
if (current_loc.relative_alt) { |
||||
altitude = current_loc.alt+ahrs.get_home().alt; |
||||
altitude_rel = current_loc.alt; |
||||
} else { |
||||
altitude = current_loc.alt; |
||||
altitude_rel = current_loc.alt - ahrs.get_home().alt; |
||||
} |
||||
const AP_GPS &gps = AP::gps(); |
||||
if (gps.status() >= AP_GPS::GPS_OK_FIX_3D) { |
||||
altitude_gps = gps.location().alt; |
||||
} else { |
||||
altitude_gps = 0; |
||||
} |
||||
|
||||
const struct log_Camera pkt{ |
||||
LOG_PACKET_HEADER_INIT(static_cast<uint8_t>(msg)), |
||||
time_us : timestamp_us?timestamp_us:AP_HAL::micros64(), |
||||
gps_time : gps.time_week_ms(), |
||||
gps_week : gps.time_week(), |
||||
latitude : current_loc.lat, |
||||
longitude : current_loc.lng, |
||||
altitude : altitude, |
||||
altitude_rel: altitude_rel, |
||||
altitude_gps: altitude_gps, |
||||
roll : (int16_t)ahrs.roll_sensor, |
||||
pitch : (int16_t)ahrs.pitch_sensor, |
||||
yaw : (uint16_t)ahrs.yaw_sensor |
||||
}; |
||||
AP::logger().WriteCriticalBlock(&pkt, sizeof(pkt)); |
||||
} |
||||
|
||||
// Write a Camera packet
|
||||
void AP_Camera::Write_Camera(uint64_t timestamp_us) |
||||
{ |
||||
Write_CameraInfo(LOG_CAMERA_MSG, timestamp_us); |
||||
} |
||||
|
||||
// Write a Trigger packet
|
||||
void AP_Camera::Write_Trigger(void) |
||||
{ |
||||
Write_CameraInfo(LOG_TRIGGER_MSG, 0); |
||||
} |
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
#pragma once |
||||
|
||||
#include <AP_Logger/LogStructure.h> |
||||
|
||||
#define LOG_IDS_FROM_CAMERA \ |
||||
LOG_CAMERA_MSG, \
|
||||
LOG_TRIGGER_MSG |
||||
|
||||
// @LoggerMessage: CAM,TRIG
|
||||
// @Description: Camera shutter information
|
||||
// @Field: TimeUS: Time since system startup
|
||||
// @Field: GPSTime: milliseconds since start of GPS week
|
||||
// @Field: GPSWeek: weeks since 5 Jan 1980
|
||||
// @Field: Lat: current latitude
|
||||
// @Field: Lng: current longitude
|
||||
// @Field: Alt: current altitude
|
||||
// @Field: RelAlt: current altitude relative to home
|
||||
// @Field: GPSAlt: altitude as reported by GPS
|
||||
// @Field: Roll: current vehicle roll
|
||||
// @Field: Pitch: current vehicle pitch
|
||||
// @Field: Yaw: current vehicle yaw
|
||||
struct PACKED log_Camera { |
||||
LOG_PACKET_HEADER; |
||||
uint64_t time_us; |
||||
uint32_t gps_time; |
||||
uint16_t gps_week; |
||||
int32_t latitude; |
||||
int32_t longitude; |
||||
int32_t altitude; |
||||
int32_t altitude_rel; |
||||
int32_t altitude_gps; |
||||
int16_t roll; |
||||
int16_t pitch; |
||||
uint16_t yaw; |
||||
}; |
||||
|
||||
#define LOG_STRUCTURE_FROM_CAMERA \ |
||||
{ LOG_CAMERA_MSG, sizeof(log_Camera), \
|
||||
"CAM", "QIHLLeeeccC","TimeUS,GPSTime,GPSWeek,Lat,Lng,Alt,RelAlt,GPSAlt,Roll,Pitch,Yaw", "s--DUmmmddd", "F--GGBBBBBB" }, \
|
||||
{ LOG_TRIGGER_MSG, sizeof(log_Camera), \
|
||||
"TRIG", "QIHLLeeeccC","TimeUS,GPSTime,GPSWeek,Lat,Lng,Alt,RelAlt,GPSAlt,Roll,Pitch,Yaw", "s--DUmmmddd", "F--GGBBBBBB" }, |
Loading…
Reference in new issue