dist-sensor: reduce enum names

This commit is contained in:
bresch 2024-09-09 15:22:09 +02:00 committed by Mathieu Bresciani
parent 8bca467c15
commit 15e9c65a8f
5 changed files with 9 additions and 9 deletions

View File

@ -41,7 +41,7 @@ uint8 ROTATION_DOWNWARD_FACING = 25 # MAV_SENSOR_ROTATION_PITCH_270
uint8 ROTATION_CUSTOM = 100 # MAV_SENSOR_ROTATION_CUSTOM uint8 ROTATION_CUSTOM = 100 # MAV_SENSOR_ROTATION_CUSTOM
uint8 mode # mode of operation uint8 mode
uint8 DISTANCE_SENSOR_MODE_UNKNOWN = 0 # Unknown mode uint8 MODE_UNKNOWN = 0
uint8 DISTANCE_SENSOR_MODE_RUN = 1 # sensor is running continuosly uint8 MODE_ENABLED = 1
uint8 DISTANCE_SENSOR_MODE_DISABLED = 2 # sensor is disabled per request uint8 MODE_DISABLED = 2

View File

@ -499,7 +499,7 @@ void LightwareLaser::RunImpl()
case State::Running: case State::Running:
if (!_restriction) { if (!_restriction) {
_px4_rangefinder.set_mode(distance_sensor_s::DISTANCE_SENSOR_MODE_RUN); _px4_rangefinder.set_mode(distance_sensor_s::MODE_ENABLED);
if (PX4_OK != collect()) { if (PX4_OK != collect()) {
PX4_DEBUG("collection error"); PX4_DEBUG("collection error");
@ -511,7 +511,7 @@ void LightwareLaser::RunImpl()
} }
} else { } else {
_px4_rangefinder.set_mode(distance_sensor_s::DISTANCE_SENSOR_MODE_DISABLED); _px4_rangefinder.set_mode(distance_sensor_s::MODE_DISABLED);
if (!_prev_restriction) { // Publish disabled status once if (!_prev_restriction) { // Publish disabled status once
_px4_rangefinder.update(hrt_absolute_time(), -1.f, 0); _px4_rangefinder.update(hrt_absolute_time(), -1.f, 0);

View File

@ -40,7 +40,7 @@ PX4Rangefinder::PX4Rangefinder(const uint32_t device_id, const uint8_t device_or
set_device_id(device_id); set_device_id(device_id);
set_orientation(device_orientation); set_orientation(device_orientation);
set_rangefinder_type(distance_sensor_s::MAV_DISTANCE_SENSOR_LASER); set_rangefinder_type(distance_sensor_s::MAV_DISTANCE_SENSOR_LASER);
set_mode(distance_sensor_s::DISTANCE_SENSOR_MODE_UNKNOWN); set_mode(distance_sensor_s::MODE_UNKNOWN);
} }
PX4Rangefinder::~PX4Rangefinder() PX4Rangefinder::~PX4Rangefinder()

View File

@ -60,7 +60,7 @@ public:
void set_orientation(const uint8_t device_orientation = distance_sensor_s::ROTATION_DOWNWARD_FACING); void set_orientation(const uint8_t device_orientation = distance_sensor_s::ROTATION_DOWNWARD_FACING);
void set_mode(const uint8_t mode) {_distance_sensor_pub.get().mode = mode; } void set_mode(const uint8_t mode) { _distance_sensor_pub.get().mode = mode; }
void update(const hrt_abstime &timestamp_sample, const float distance, const int8_t quality = -1); void update(const hrt_abstime &timestamp_sample, const float distance, const int8_t quality = -1);

View File

@ -49,7 +49,7 @@ void DistanceSensorChecks::checkAndReport(const Context &context, Report &report
if (exists) { if (exists) {
distance_sensor_s dist_sens; distance_sensor_s dist_sens;
valid = _distance_sensor_sub[instance].copy(&dist_sens) && ((hrt_elapsed_time(&dist_sens.timestamp) < 1_s) valid = _distance_sensor_sub[instance].copy(&dist_sens) && ((hrt_elapsed_time(&dist_sens.timestamp) < 1_s)
|| (dist_sens.mode == distance_sensor_s::DISTANCE_SENSOR_MODE_DISABLED)); || (dist_sens.mode == distance_sensor_s::MODE_DISABLED));
reporter.setIsPresent(health_component_t::distance_sensor); reporter.setIsPresent(health_component_t::distance_sensor);
} }