Note: I am going crazy. I know this is not a hard one but if anyone has ideas I’d greatly appreciate it
I am porting changes from an older version of ArduCopter (4.0.5) to 4.2.3.
After porting some of the functionality the firmware compiled without complaints but keeps yelling about mem_guard panic.
mem_guard internal error gets thrown if block size > num_blocks in
AP_UAVCAN_pool.cpp - void* AP_PoolAllocator::allocate(std::size_t size)
AP_UAVCAN_pool.cpp - void* AP_PoolAllocator::deallocate(std::size_t size)
num_blocks = _pool_size/pool block size // 8192 and 64 respectively.
the value 8192 is also displayed in CAN_D1_UC_POOL and instruction say to increase it for higher CAN loads. Previously these numbers worked fine in 4.0.5. Anyway I doubled it to 16384 and the error persists.
I then started commenting things out and narrowed it down to one of my custom fns. I use custom ESCs with custom messages, so within AP_UAVCAN.cpp - handle_ESC_status(AP_UAVCAN* ap_uavcan, uint8_t node_id, const ESCStatusCb &cb) I have added a call to my fn:
AP_Motors::get_singleton()->update_esc_state(cb.msg->esc_index, cb.msg->voltage, cb.msg->current, cb.msg->temperature, cb.msg->rpm, cb.msg->power_rating_pct > 0, cb.msg->error_count);
update_esc_state() fn just assigns the provided values to an array of esc_status structs.
e.g.
esc_status[i].voltage = voltage;
The strangest thing is that the error occurs if I try to assign value to any floats (e.g. voltage) but not ints (e.g. rpms).
The esc_status array (size of 8, ) of structs is a public variable if that matters.
struct EscStatus_info{
float voltage;
float current;
float temperature;
int rpm;
bool ready;
int stus;
uint32_t last_reading_ms = 0;
};
Please HALP!