|
|
|
@ -38,6 +38,13 @@
@@ -38,6 +38,13 @@
|
|
|
|
|
|
|
|
|
|
#include <AP_Logger/AP_Logger.h> |
|
|
|
|
#include <GCS_MAVLink/GCS.h> |
|
|
|
|
|
|
|
|
|
#if HAL_WITH_UAVCAN |
|
|
|
|
#include <AP_BoardConfig/AP_BoardConfig_CAN.h> |
|
|
|
|
#include <AP_UAVCAN/AP_UAVCAN.h> |
|
|
|
|
#include <AP_Camera/AP_Camera.h> |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
extern const AP_HAL::HAL& hal; |
|
|
|
|
|
|
|
|
|
// optionally log all NMEA data for debug purposes
|
|
|
|
@ -153,6 +160,35 @@ int32_t AP_GPS_NMEA::_parse_decimal_100(const char *p)
@@ -153,6 +160,35 @@ int32_t AP_GPS_NMEA::_parse_decimal_100(const char *p)
|
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint32_t AP_GPS_NMEA::_parse_decimal_1000(const char *p) |
|
|
|
|
{ |
|
|
|
|
char *endptr = nullptr; |
|
|
|
|
long ret = 1000 * strtol(p, &endptr, 10); |
|
|
|
|
if (ret >= (long)INT32_MAX) { |
|
|
|
|
return INT32_MAX; |
|
|
|
|
} |
|
|
|
|
if (ret <= (long)INT32_MIN) { |
|
|
|
|
return INT32_MIN; |
|
|
|
|
} |
|
|
|
|
if (endptr == nullptr || *endptr != '.') { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isdigit(endptr[1])) { |
|
|
|
|
ret += 100 * DIGIT_TO_VAL(endptr[1]); |
|
|
|
|
if (isdigit(endptr[2])) { |
|
|
|
|
ret += 10 * DIGIT_TO_VAL(endptr[2]); |
|
|
|
|
if (isdigit(endptr[3])) { |
|
|
|
|
ret += DIGIT_TO_VAL(endptr[3]); |
|
|
|
|
if (isdigit(endptr[4])) { |
|
|
|
|
ret += (DIGIT_TO_VAL(endptr[4]) >= 5); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
parse a NMEA latitude/longitude degree value. The result is in degrees*1e7 |
|
|
|
|
*/ |
|
|
|
@ -253,25 +289,49 @@ bool AP_GPS_NMEA::_term_complete()
@@ -253,25 +289,49 @@ bool AP_GPS_NMEA::_term_complete()
|
|
|
|
|
switch (_sentence_type) { |
|
|
|
|
case _GPS_SENTENCE_MARK: |
|
|
|
|
case _GPS_SENTENCE_EVENT: |
|
|
|
|
if(get_new_mark){
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%d, %.4f, %f , %f , %f\n",gps_mark.week,gps_mark.second,gps_mark.lat,gps_mark.lon,gps_mark.hgt);
|
|
|
|
|
if (get_new_mark) |
|
|
|
|
{ |
|
|
|
|
gcs().send_text(MAV_SEVERITY_INFO, "%d, %.4f, %f , %f , %f\n", gps_mark.week, gps_mark.second, gps_mark.lat, gps_mark.lon, gps_mark.hgt); |
|
|
|
|
get_new_mark = false; |
|
|
|
|
AP_Logger *logger = AP_Logger::get_singleton(); |
|
|
|
|
|
|
|
|
|
if ( logger!=nullptr ) |
|
|
|
|
#if HAL_WITH_UAVCAN |
|
|
|
|
uint8_t can_num_drivers = AP::can().get_num_drivers(); |
|
|
|
|
for (uint8_t i = 0; i < can_num_drivers; i++) |
|
|
|
|
{ |
|
|
|
|
AP_UAVCAN *uavcan = AP_UAVCAN::get_uavcan(i); |
|
|
|
|
if (uavcan != nullptr) |
|
|
|
|
{ |
|
|
|
|
Vector3d llh = Vector3d(gps_mark.lat,gps_mark.lon, gps_mark.hgt); |
|
|
|
|
Vector3f sigma = Vector3f(gps_mark.lat_sigma,gps_mark.lon_sigma, gps_mark.hgt_sigma); |
|
|
|
|
AP::logger().Write_RTK_Mark_Pos( |
|
|
|
|
gps_mark.week, |
|
|
|
|
gps_mark.second, |
|
|
|
|
llh, |
|
|
|
|
gps_mark.undulation, |
|
|
|
|
sigma, |
|
|
|
|
gps_mark.diff_age, |
|
|
|
|
gps_mark.sol_age |
|
|
|
|
); |
|
|
|
|
ppk_pos_data_t ppk_pos; |
|
|
|
|
memset(&ppk_pos,0,sizeof(ppk_pos_data_t)); |
|
|
|
|
ppk_pos.week = gps_mark.week; |
|
|
|
|
ppk_pos.weekms = gps_mark.second; |
|
|
|
|
ppk_pos.latitude_deg_1e7 = (int32_t)(gps_mark.lat * (int32_t)10000000UL); |
|
|
|
|
ppk_pos.longitude_deg_1e7 = (int32_t)(gps_mark.lon * (int32_t)10000000UL); |
|
|
|
|
ppk_pos.height_abs_cm = gps_mark.hgt * 100; |
|
|
|
|
AP_Camera *camera = AP::camera(); |
|
|
|
|
if (camera != nullptr) |
|
|
|
|
{ |
|
|
|
|
ppk_pos.index =camera->get_image_index(); |
|
|
|
|
} |
|
|
|
|
uavcan->set_zr_ppk_pos(ppk_pos); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
AP_Logger *logger = AP_Logger::get_singleton(); |
|
|
|
|
|
|
|
|
|
if (logger != nullptr) |
|
|
|
|
{ |
|
|
|
|
Vector3d llh = Vector3d(gps_mark.lat, gps_mark.lon, gps_mark.hgt); |
|
|
|
|
Vector3f sigma = Vector3f(gps_mark.lat_sigma, gps_mark.lon_sigma, gps_mark.hgt_sigma); |
|
|
|
|
AP::logger().Write_RTK_Mark_Pos( |
|
|
|
|
gps_mark.week, |
|
|
|
|
gps_mark.second, |
|
|
|
|
llh, |
|
|
|
|
gps_mark.undulation, |
|
|
|
|
sigma, |
|
|
|
|
gps_mark.diff_age, |
|
|
|
|
gps_mark.sol_age); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -492,11 +552,7 @@ bool AP_GPS_NMEA::_term_complete()
@@ -492,11 +552,7 @@ bool AP_GPS_NMEA::_term_complete()
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if 1 |
|
|
|
|
static uint32_t cnt; |
|
|
|
|
cnt++; |
|
|
|
|
// if ((_sentence_type == _GPS_SENTENCE_MARK || _sentence_type == _GPS_SENTENCE_EVENT ))
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%d,t:%d, n:%d,%d: %s",cnt,_sentence_type,_term_number,_term[0],_term);
|
|
|
|
|
// rtk event mark decode
|
|
|
|
|
|
|
|
|
|
if ((_sentence_type == _GPS_SENTENCE_MARK || _sentence_type == _GPS_SENTENCE_EVENT )) { |
|
|
|
|
switch (_sentence_type + _term_number) { |
|
|
|
|
// operational status
|
|
|
|
@ -504,66 +560,54 @@ cnt++;
@@ -504,66 +560,54 @@ cnt++;
|
|
|
|
|
case _GPS_SENTENCE_MARK + 5: // week
|
|
|
|
|
case _GPS_SENTENCE_EVENT + 5: // week
|
|
|
|
|
gps_mark.week = atol(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%s:%d",_term,gps_mark.week);
|
|
|
|
|
break;
|
|
|
|
|
case _GPS_SENTENCE_MARK + 6: // second
|
|
|
|
|
case _GPS_SENTENCE_EVENT + 6: // second
|
|
|
|
|
gps_mark.second = atof(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%s:%f",_term,gps_mark.second);
|
|
|
|
|
gps_mark.second = _parse_decimal_1000(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "event:%s:%ld,%ld",_term,gps_mark.second,_parse_decimal_100(_term));
|
|
|
|
|
break; |
|
|
|
|
case _GPS_SENTENCE_MARK + 12: // lat
|
|
|
|
|
case _GPS_SENTENCE_EVENT + 22: // lat
|
|
|
|
|
gps_mark.lat = atof(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%s:%f",_term,gps_mark.lat);
|
|
|
|
|
break; |
|
|
|
|
case _GPS_SENTENCE_MARK + 13: // lon
|
|
|
|
|
case _GPS_SENTENCE_EVENT + 23: |
|
|
|
|
gps_mark.lon = atof(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%s:%f",_term,gps_mark.lon);
|
|
|
|
|
break; |
|
|
|
|
case _GPS_SENTENCE_MARK + 14: // hgt
|
|
|
|
|
case _GPS_SENTENCE_EVENT + 24: |
|
|
|
|
gps_mark.hgt = atof(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%s:%f",_term,gps_mark.lon);
|
|
|
|
|
break; |
|
|
|
|
case _GPS_SENTENCE_MARK + 15: // undulation
|
|
|
|
|
case _GPS_SENTENCE_EVENT + 25: |
|
|
|
|
gps_mark.undulation = atof(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%d,%s",_term_number,_term);
|
|
|
|
|
break; |
|
|
|
|
case _GPS_SENTENCE_MARK + 17: // lat_sigma
|
|
|
|
|
case _GPS_SENTENCE_EVENT + 27: |
|
|
|
|
gps_mark.lat_sigma = atof(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%d,%s",_term_number,_term);
|
|
|
|
|
break; |
|
|
|
|
case _GPS_SENTENCE_MARK + 18: // lon_sigma
|
|
|
|
|
case _GPS_SENTENCE_EVENT + 28: |
|
|
|
|
gps_mark.lon_sigma = atof(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%d,%s",_term_number,_term);
|
|
|
|
|
break; |
|
|
|
|
case _GPS_SENTENCE_MARK + 19: // hgt_sigma
|
|
|
|
|
case _GPS_SENTENCE_EVENT + 29: |
|
|
|
|
gps_mark.hgt_sigma = atof(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%d,%s",_term_number,_term);
|
|
|
|
|
break; |
|
|
|
|
case _GPS_SENTENCE_MARK + 21: // diff_age
|
|
|
|
|
case _GPS_SENTENCE_EVENT + 31: |
|
|
|
|
gps_mark.diff_age = atof(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%d,%s",_term_number,_term);
|
|
|
|
|
break; |
|
|
|
|
case _GPS_SENTENCE_MARK + 22: // sol_age
|
|
|
|
|
case _GPS_SENTENCE_EVENT + 32: |
|
|
|
|
gps_mark.sol_age = atof(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%d,%s",_term_number,_term);
|
|
|
|
|
break; |
|
|
|
|
case _GPS_SENTENCE_MARK + 23: // SVs
|
|
|
|
|
case _GPS_SENTENCE_EVENT + 33: |
|
|
|
|
gps_mark.SVs = atol(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "%d,%s",_term_number,_term);
|
|
|
|
|
case _GPS_SENTENCE_MARK + 24: // solnSVs
|
|
|
|
|
case _GPS_SENTENCE_EVENT + 34: |
|
|
|
|
gps_mark.solnSVs = atol(_term);
|
|
|
|
|
// gcs().send_text(MAV_SEVERITY_INFO, "--- %d,%s \n",_term_number,_term);
|
|
|
|
|
get_new_mark = true; |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|