mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 12:48:53 +08:00
CollisionPrevention: reduce internal array size, zero initialize what's possible
This commit is contained in:
committed by
Claudio Chies
parent
c879ca531d
commit
1fa76ac71d
@@ -51,18 +51,14 @@ CollisionPrevention::CollisionPrevention(ModuleParams *parent) :
|
|||||||
>= BIN_COUNT, "BIN_COUNT must not overflow obstacle_distance.distances");
|
>= BIN_COUNT, "BIN_COUNT must not overflow obstacle_distance.distances");
|
||||||
|
|
||||||
// initialize internal obstacle map
|
// initialize internal obstacle map
|
||||||
_obstacle_map_body_frame.timestamp = getTime();
|
|
||||||
_obstacle_map_body_frame.frame = obstacle_distance_s::MAV_FRAME_BODY_FRD;
|
_obstacle_map_body_frame.frame = obstacle_distance_s::MAV_FRAME_BODY_FRD;
|
||||||
_obstacle_map_body_frame.increment = BIN_SIZE;
|
_obstacle_map_body_frame.increment = BIN_SIZE;
|
||||||
_obstacle_map_body_frame.min_distance = UINT16_MAX;
|
_obstacle_map_body_frame.min_distance = UINT16_MAX;
|
||||||
_obstacle_map_body_frame.max_distance = 0;
|
|
||||||
_obstacle_map_body_frame.angle_offset = 0.f;
|
static constexpr int BIN_COUNT_EXTERNAL =
|
||||||
const uint64_t current_time = getTime();
|
sizeof(_obstacle_map_body_frame.distances) / sizeof(_obstacle_map_body_frame.distances[0]);
|
||||||
|
|
||||||
for (uint32_t i = 0 ; i < BIN_COUNT_EXTERNAL; i++) {
|
for (uint32_t i = 0 ; i < BIN_COUNT_EXTERNAL; i++) {
|
||||||
_data_timestamps[i] = current_time;
|
|
||||||
_data_maxranges[i] = 0;
|
|
||||||
_data_fov[i] = 0;
|
|
||||||
_obstacle_map_body_frame.distances[i] = UINT16_MAX;
|
_obstacle_map_body_frame.distances[i] = UINT16_MAX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,12 +85,9 @@ protected:
|
|||||||
static constexpr int BIN_SIZE = 360 / BIN_COUNT; // cannot be lower than 5 degrees, should divide 360 evenly
|
static constexpr int BIN_SIZE = 360 / BIN_COUNT; // cannot be lower than 5 degrees, should divide 360 evenly
|
||||||
|
|
||||||
obstacle_distance_s _obstacle_map_body_frame{};
|
obstacle_distance_s _obstacle_map_body_frame{};
|
||||||
static constexpr int BIN_COUNT_EXTERNAL =
|
bool _data_fov[BIN_COUNT] {};
|
||||||
sizeof(_obstacle_map_body_frame.distances) / sizeof(_obstacle_map_body_frame.distances[0]);
|
uint64_t _data_timestamps[BIN_COUNT] {};
|
||||||
|
uint16_t _data_maxranges[BIN_COUNT] {}; /**< in cm */
|
||||||
bool _data_fov[BIN_COUNT_EXTERNAL];
|
|
||||||
uint64_t _data_timestamps[BIN_COUNT_EXTERNAL];
|
|
||||||
uint16_t _data_maxranges[BIN_COUNT_EXTERNAL]; /**< in cm */
|
|
||||||
|
|
||||||
void _addDistanceSensorData(distance_sensor_s &distance_sensor, const matrix::Quatf &vehicle_attitude);
|
void _addDistanceSensorData(distance_sensor_s &distance_sensor, const matrix::Quatf &vehicle_attitude);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user