diff --git a/libraries/AP_Vehicle/AP_Vehicle.cpp b/libraries/AP_Vehicle/AP_Vehicle.cpp index 83a0e80fc7..fbb0356dea 100644 --- a/libraries/AP_Vehicle/AP_Vehicle.cpp +++ b/libraries/AP_Vehicle/AP_Vehicle.cpp @@ -251,6 +251,13 @@ const AP_Param::GroupInfo AP_Vehicle::var_info[] = { // @Path: ../Filter/AP_Filter.cpp AP_SUBGROUPINFO(filters, "FILT", 26, AP_Vehicle, AP_Filters), #endif + +#if AP_STATS_ENABLED + // @Group: STAT + // @Path: ../AP_Stats/AP_Stats.cpp + AP_SUBGROUPINFO(stats, "STAT", 27, AP_Vehicle, AP_Stats), +#endif + AP_GROUPEND }; @@ -346,6 +353,11 @@ void AP_Vehicle::setup() generator.init(); #endif +#if AP_STATS_ENABLED + // initialise stats module + stats.init(); +#endif + // init_ardupilot is where the vehicle does most of its initialisation. init_ardupilot(); @@ -573,6 +585,9 @@ const AP_Scheduler::Task AP_Vehicle::scheduler_tasks[] = { #endif #if AP_FILTER_ENABLED SCHED_TASK_CLASS(AP_Filters, &vehicle.filters, update, 1, 100, 252), +#endif +#if AP_STATS_ENABLED + SCHED_TASK_CLASS(AP_Stats, &vehicle.stats, update, 1, 100, 252), #endif SCHED_TASK(update_arming, 1, 50, 253), }; diff --git a/libraries/AP_Vehicle/AP_Vehicle.h b/libraries/AP_Vehicle/AP_Vehicle.h index a109b31253..32e0f3150c 100644 --- a/libraries/AP_Vehicle/AP_Vehicle.h +++ b/libraries/AP_Vehicle/AP_Vehicle.h @@ -68,6 +68,7 @@ #include #include #include +#include // statistics library class AP_DDS_Client; @@ -388,6 +389,11 @@ protected: AP_Airspeed airspeed; #endif +#if AP_STATS_ENABLED + // vehicle statistics + AP_Stats stats; +#endif + #if AP_AIS_ENABLED // Automatic Identification System - for tracking sea-going vehicles AP_AIS ais;