diff --git a/ArduPlane/GCS_Mavlink.cpp b/ArduPlane/GCS_Mavlink.cpp index cd71c638a8..fba7e28997 100644 --- a/ArduPlane/GCS_Mavlink.cpp +++ b/ArduPlane/GCS_Mavlink.cpp @@ -392,14 +392,14 @@ void Plane::send_pid_tuning(mavlink_channel_t chan) void Plane::send_rangefinder(mavlink_channel_t chan) { - if (!rangefinder.has_data()) { + if (!rangefinder.has_data_orient(ROTATION_PITCH_270)) { // no sonar to report return; } mavlink_msg_rangefinder_send( chan, - rangefinder.distance_cm() * 0.01f, - rangefinder.voltage_mv()*0.001f); + rangefinder.distance_cm_orient(ROTATION_PITCH_270) * 0.01f, + rangefinder.voltage_mv_orient(ROTATION_PITCH_270) * 0.001f); } void Plane::send_current_waypoint(mavlink_channel_t chan) diff --git a/ArduPlane/Log.cpp b/ArduPlane/Log.cpp index 9ecf1986e2..6a9094aa68 100644 --- a/ArduPlane/Log.cpp +++ b/ArduPlane/Log.cpp @@ -343,15 +343,15 @@ struct PACKED log_Sonar { void Plane::Log_Write_Sonar() { uint16_t distance = 0; - if (rangefinder.status() == RangeFinder::RangeFinder_Good) { - distance = rangefinder.distance_cm(); + if (rangefinder.status_orient(ROTATION_PITCH_270) == RangeFinder::RangeFinder_Good) { + distance = rangefinder.distance_cm_orient(ROTATION_PITCH_270); } struct log_Sonar pkt = { LOG_PACKET_HEADER_INIT(LOG_SONAR_MSG), time_us : AP_HAL::micros64(), distance : (float)distance*0.01f, - voltage : rangefinder.voltage_mv()*0.001f, + voltage : rangefinder.voltage_mv_orient(ROTATION_PITCH_270)*0.001f, count : rangefinder_state.in_range_count, correction : rangefinder_state.correction }; diff --git a/ArduPlane/Plane.h b/ArduPlane/Plane.h index c080e803aa..741fab9643 100644 --- a/ArduPlane/Plane.h +++ b/ArduPlane/Plane.h @@ -200,7 +200,7 @@ private: AP_InertialSensor ins; - RangeFinder rangefinder {serial_manager}; + RangeFinder rangefinder {serial_manager, ROTATION_PITCH_270}; AP_Vehicle::FixedWing::Rangefinder_State rangefinder_state; diff --git a/ArduPlane/altitude.cpp b/ArduPlane/altitude.cpp index 859e10a0a1..58afed197c 100644 --- a/ArduPlane/altitude.cpp +++ b/ArduPlane/altitude.cpp @@ -568,9 +568,9 @@ float Plane::rangefinder_correction(void) */ void Plane::rangefinder_height_update(void) { - float distance = rangefinder.distance_cm()*0.01f; + float distance = rangefinder.distance_cm_orient(ROTATION_PITCH_270)*0.01f; - if ((rangefinder.status() == RangeFinder::RangeFinder_Good) && home_is_set != HOME_UNSET) { + if ((rangefinder.status_orient(ROTATION_PITCH_270) == RangeFinder::RangeFinder_Good) && home_is_set != HOME_UNSET) { if (!rangefinder_state.have_initial_reading) { rangefinder_state.have_initial_reading = true; rangefinder_state.initial_range = distance; @@ -586,10 +586,10 @@ void Plane::rangefinder_height_update(void) // to misconfiguration or a faulty sensor if (rangefinder_state.in_range_count < 10) { if (!is_equal(distance, rangefinder_state.last_distance) && - fabsf(rangefinder_state.initial_range - distance) > 0.05f * rangefinder.max_distance_cm()*0.01f) { + fabsf(rangefinder_state.initial_range - distance) > 0.05f * rangefinder.max_distance_cm_orient(ROTATION_PITCH_270)*0.01f) { rangefinder_state.in_range_count++; } - if (fabsf(rangefinder_state.last_distance - distance) > rangefinder.max_distance_cm()*0.01*0.2) { + if (fabsf(rangefinder_state.last_distance - distance) > rangefinder.max_distance_cm_orient(ROTATION_PITCH_270)*0.01*0.2) { // changes by more than 20% of full range will reset counter rangefinder_state.in_range_count = 0; } diff --git a/ArduPlane/sensors.cpp b/ArduPlane/sensors.cpp index d11eb7a796..c39430e356 100644 --- a/ArduPlane/sensors.cpp +++ b/ArduPlane/sensors.cpp @@ -352,12 +352,12 @@ void Plane::update_sensor_status_flags(void) } #endif - if (rangefinder.num_sensors() > 0) { + if (rangefinder.has_orientation(ROTATION_PITCH_270)) { control_sensors_present |= MAV_SYS_STATUS_SENSOR_LASER_POSITION; if (g.rangefinder_landing) { control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_LASER_POSITION; } - if (rangefinder.has_data()) { + if (rangefinder.has_data_orient(ROTATION_PITCH_270)) { control_sensors_health |= MAV_SYS_STATUS_SENSOR_LASER_POSITION; } }