diff --git a/libraries/AP_DAL/AP_DAL.cpp b/libraries/AP_DAL/AP_DAL.cpp index 35c5c02758..9980e76a46 100644 --- a/libraries/AP_DAL/AP_DAL.cpp +++ b/libraries/AP_DAL/AP_DAL.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #if APM_BUILD_TYPE(APM_BUILD_Replay) #include @@ -61,6 +62,7 @@ void AP_DAL::start_frame(AP_DAL::FrameType frametype) _RFRN.ahrs_airspeed_sensor_enabled = AP::ahrs().airspeed_sensor_enabled(); _RFRN.available_memory = hal.util->available_memory(); _RFRN.ahrs_trim = ahrs.get_trim(); + _RFRN.opticalflow_enabled = AP::opticalflow() && AP::opticalflow()->enabled(); WRITE_REPLAY_BLOCK_IFCHANGED(RFRN, _RFRN, old); // update body conversion diff --git a/libraries/AP_DAL/AP_DAL.h b/libraries/AP_DAL/AP_DAL.h index a9821b9919..cc6de56146 100644 --- a/libraries/AP_DAL/AP_DAL.h +++ b/libraries/AP_DAL/AP_DAL.h @@ -192,6 +192,10 @@ public: return _RFRH.time_flying_ms; } + bool opticalflow_enabled(void) const { + return _RFRN.opticalflow_enabled; + } + // log optical flow data void writeOptFlowMeas(const uint8_t rawFlowQuality, const Vector2f &rawFlowRates, const Vector2f &rawGyroRates, const uint32_t msecFlowMeas, const Vector3f &posOffset); diff --git a/libraries/AP_DAL/AP_DAL_Beacon.cpp b/libraries/AP_DAL/AP_DAL_Beacon.cpp index f731855f94..666fe511bc 100644 --- a/libraries/AP_DAL/AP_DAL_Beacon.cpp +++ b/libraries/AP_DAL/AP_DAL_Beacon.cpp @@ -24,6 +24,7 @@ void AP_DAL_Beacon::start_frame() Location loc; _RBCH.get_origin_returncode = bcon->get_origin(loc); + _RBCH.enabled = bcon->enabled(); _RBCH.origin_lat = loc.lat; _RBCH.origin_lng = loc.lng; _RBCH.origin_alt = loc.alt; diff --git a/libraries/AP_DAL/AP_DAL_Beacon.h b/libraries/AP_DAL/AP_DAL_Beacon.h index f3b05e4e67..bfe1edff86 100644 --- a/libraries/AP_DAL/AP_DAL_Beacon.h +++ b/libraries/AP_DAL/AP_DAL_Beacon.h @@ -22,6 +22,11 @@ public: return _RBCH.get_origin_returncode; } + // return beacon enabled + bool enabled(void) const { + return _RBCH.enabled; + } + // return beacon health bool beacon_healthy(uint8_t i) const { return _RBCI[i].healthy; diff --git a/libraries/AP_DAL/AP_DAL_RangeFinder.cpp b/libraries/AP_DAL/AP_DAL_RangeFinder.cpp index 17ba0deae0..884170c757 100644 --- a/libraries/AP_DAL/AP_DAL_RangeFinder.cpp +++ b/libraries/AP_DAL/AP_DAL_RangeFinder.cpp @@ -89,6 +89,17 @@ void AP_DAL_RangeFinder_Backend::start_frame(AP_RangeFinder_Backend *backend) { WRITE_REPLAY_BLOCK_IFCHANGED(RRNI, _RRNI, old); } +// return true if we have a range finder with the specified orientation +bool AP_DAL_RangeFinder::has_orientation(enum Rotation orientation) const +{ + for (uint8_t i=0; i #include "AP_DAL.h" +/* + update position offsets to align to AHRS position + should only be called when this library is not being used as the position source + This function does not change EKF state, so does not need to be logged +*/ +void AP_DAL_VisualOdom::align_position_to_ahrs(bool align_xy, bool align_z) +{ +#if !APM_BUILD_TYPE(APM_BUILD_AP_DAL_Standalone) + auto *vo = AP::visualodom(); + vo->align_position_to_ahrs(align_xy, align_z); +#endif +} + void AP_DAL_VisualOdom::start_frame() { const auto *vo = AP::visualodom(); diff --git a/libraries/AP_DAL/AP_DAL_VisualOdom.h b/libraries/AP_DAL/AP_DAL_VisualOdom.h index 83f2c00ab2..f601019b76 100644 --- a/libraries/AP_DAL/AP_DAL_VisualOdom.h +++ b/libraries/AP_DAL/AP_DAL_VisualOdom.h @@ -29,6 +29,10 @@ public: return RVOH.pos_offset; } + // update position offsets to align to AHRS position + // should only be called when this library is not being used as the position source + void align_position_to_ahrs(bool align_xy, bool align_z); + AP_DAL_VisualOdom *visualodom() { if (RVOH.ptr_is_nullptr) { return nullptr; @@ -40,7 +44,7 @@ public: void handle_message(const log_RVOH &msg) { RVOH = msg; - } + } private: diff --git a/libraries/AP_DAL/LogStructure.h b/libraries/AP_DAL/LogStructure.h index d25f19f6a8..411a2d93a8 100644 --- a/libraries/AP_DAL/LogStructure.h +++ b/libraries/AP_DAL/LogStructure.h @@ -67,6 +67,7 @@ struct log_RFRN { uint8_t airspeed_ptr_is_null:1; uint8_t fly_forward:1; uint8_t ahrs_airspeed_sensor_enabled:1; + uint8_t opticalflow_enabled:1; uint8_t _end; }; @@ -265,10 +266,11 @@ struct log_RBCH { int32_t origin_lat; int32_t origin_lng; int32_t origin_alt; - bool get_vehicle_position_ned_returncode; + uint8_t get_vehicle_position_ned_returncode:1; + uint8_t get_origin_returncode:1; + uint8_t enabled:1; + uint8_t ptr_is_nullptr:1; uint8_t count; - bool get_origin_returncode; - uint8_t ptr_is_nullptr; uint8_t _end; }; @@ -402,7 +404,7 @@ struct log_RBOH { { LOG_RMGI_MSG, RLOG_SIZE(RMGI), \ "RMGI", "IffffffBBBB", "LU,OX,OY,OZ,FX,FY,FZ,UFY,H,HSF,I", "----------#", "-----------" }, \ { LOG_RBCH_MSG, RLOG_SIZE(RBCH), \ - "RBCH", "ffffiiiBBBB", "PX,PY,PZ,AE,OLat,OLng,OAlt,GVPR,NumInst,ORet,NPtr", "-----------", "-----------" }, \ + "RBCH", "ffffiiiBB", "PX,PY,PZ,AE,OLat,OLng,OAlt,Flags,NumInst", "---------", "---------" }, \ { LOG_RBCI_MSG, RLOG_SIZE(RBCI), \ "RBCI", "IffffBB", "LU,PX,PY,PZ,Dist,H,I", "smmmm-#", "?0000--" }, \ { LOG_RVOH_MSG, RLOG_SIZE(RVOH), \