Skip to content

Commit

Permalink
AP_RCTelemetry: correct alt ref
Browse files Browse the repository at this point in the history
  • Loading branch information
andyp1per committed Apr 28, 2024
1 parent f86cb78 commit a6e34c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libraries/AP_RCTelemetry/AP_CRSF_Telem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ uint16_t AP_CRSF_Telem::get_altitude_packed()
int8_t AP_CRSF_Telem::get_vertical_speed_packed()
{
float vspeed = get_vspeed_ms();
float vertical_speed_cm_s = vspeed * 100;
float vertical_speed_cm_s = vspeed * 100.0f;
const int16_t Kl = 100; // linearity constant;
const float Kr = .026f; // range constant;
int8_t vspeed_packed = int8_t(logf(fabsf(vertical_speed_cm_s)/Kl + 1)/Kr);
Expand All @@ -976,7 +976,7 @@ void AP_CRSF_Telem::calc_baro_vario()
// prepare vario data
void AP_CRSF_Telem::calc_vario()
{
_telem.bcast.vario.v_speed = get_vspeed_ms() * 100;
_telem.bcast.vario.v_speed = int16_t(get_vspeed_ms() * 100.0f);
_telem_size = sizeof(VarioFrame);
_telem_type = AP_RCProtocol_CRSF::CRSF_FRAMETYPE_VARIO;

Expand Down
4 changes: 1 addition & 3 deletions libraries/AP_RCTelemetry/AP_RCTelemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ uint32_t AP_RCTelemetry::sensor_status_flags() const
*/
float AP_RCTelemetry::get_vspeed_ms(void)
{

{
// release semaphore as soon as possible
AP_AHRS &_ahrs = AP::ahrs();
Expand All @@ -310,7 +309,6 @@ float AP_RCTelemetry::get_vspeed_ms(void)
return -v.z;
}
}

auto &_baro = AP::baro();
WITH_SEMAPHORE(_baro.get_semaphore());
return _baro.get_climb_rate();
Expand All @@ -327,7 +325,7 @@ float AP_RCTelemetry::get_nav_alt_m(Location::AltFrame frame)
AP_AHRS &_ahrs = AP::ahrs();
WITH_SEMAPHORE(_ahrs.get_semaphore());
if (_ahrs.get_location(loc)) {
if (!loc.get_alt_m(Location::AltFrame::ABSOLUTE, current_height)) {
if (!loc.get_alt_m(frame, current_height)) {
// ignore this error
}
}
Expand Down

0 comments on commit a6e34c9

Please sign in to comment.