Skip to content

Commit

Permalink
update to eric comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacharyLowell committed Dec 5, 2023
1 parent 833d704 commit 1733bf7
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 15 deletions.
10 changes: 5 additions & 5 deletions msg/Cpuload.msg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
char[5] platform # Platform running on (QURT, LINUX, NUTTX...)
uint64 timestamp # time since system start (microseconds)
float32 process_load # processor load from 0 to 1
float32 system_load # processor load from 0 to 1 for entire CPU not just core
float32 ram_usage # RAM usage from 0 to 1
char[5] platform # Platform running on (QURT, POSIX, NUTTX...)
uint64 timestamp # time since system start (microseconds)
float32 process_load # PX4 process load from 0.0 to 1.0
float32 system_load # System load for all processes from 0.0 to 1.0
float32 ram_usage # RAM usage from 0.0 to 1.0
2 changes: 1 addition & 1 deletion src/modules/commander/Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,7 @@ void Commander::control_status_leds(bool changed, const uint8_t battery_warning)
cpuload_s cpuload;

if (_cpuload_sub.copy(&cpuload)) {
const float cpuload_percent = cpuload.process_load * 100.f;
const float cpuload_percent = cpuload.system_load * 100.f;

bool overload = (cpuload_percent > _param_com_cpu_max.get()) || (cpuload.ram_usage > 0.99f);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void CpuResourceChecks::checkAndReport(const Context &context, Report &reporter)
}

} else {
const float cpuload_percent = cpuload.process_load * 100.f;
const float cpuload_percent = cpuload.system_load * 100.f;

if (cpuload_percent > _param_com_cpu_max.get()) {

Expand Down
4 changes: 0 additions & 4 deletions src/modules/load_mon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
#
############################################################################

if ((${PX4_BOARD_NAME} MATCHES "MODALAI_VOXL2"))
add_definitions(-D__MULTICORE)
endif()

px4_add_module(
MODULE modules__load_mon
MAIN load_mon
Expand Down
6 changes: 4 additions & 2 deletions src/modules/load_mon/LoadMon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void LoadMon::cpuload()
}

cpuload.process_load = interval_spent_time / interval;
#if defined(__MULTICORE)

FILE *stat_file = fopen("/proc/stat", "r");
if (!stat_file) {
PX4_ERR("Failed to open /proc/stat");
Expand All @@ -250,17 +250,19 @@ void LoadMon::cpuload()
float total_usage = (total - idle) / total;
cpuload.system_load = total_usage;
}
#endif

strncpy(cpuload.platform, "POSIX", sizeof(cpuload.platform));
#elif defined(__PX4_NUTTX)
// get ram usage
struct mallinfo mem = mallinfo();
cpuload.ram_usage = (float)mem.uordblks / mem.arena;
cpuload.process_load = 1.f - interval_idletime / interval;
cpuload.system_load = cpuload.process_load;
strncpy(cpuload.platform, "NUTTX", sizeof(cpuload.platform));
#elif defined(__PX4_QURT)
cpuload.ram_usage = 0.0f;
cpuload.process_load = px4muorb_get_cpu_load() / 100.0f;
cpuload.system_load = cpuload.process_load;
strncpy(cpuload.platform, "QURT", sizeof(cpuload.platform));
#endif
cpuload.timestamp = hrt_absolute_time();
Expand Down
1 change: 0 additions & 1 deletion src/modules/load_mon/LoadMon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class LoadMon : public ModuleBase<LoadMon>, public ModuleParams, public px4::Sch
hrt_abstime _last_idle_time_sample{0};
#endif


perf_counter_t _cycle_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")};

DEFINE_PARAMETERS(
Expand Down
2 changes: 1 addition & 1 deletion src/modules/mavlink/streams/SYS_STATUS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class MavlinkStreamSysStatus : public MavlinkStream
fillOutComponent(health_report, MAV_SYS_STATUS_SENSOR_DIFFERENTIAL_PRESSURE, health_component_t::differential_pressure,
msg);

msg.load = cpuload.process_load * 1000.0f;
msg.load = cpuload.system_load * 1000.0f;

// TODO: Determine what data should be put here when there are multiple batteries.
// Right now, it uses the lowest battery. This is a safety decision, because if a client is only checking
Expand Down

0 comments on commit 1733bf7

Please sign in to comment.