Skip to content

Commit e15f167

Browse files
committed
SITL: fudge zero-length to 1cm for Wasp and NoopLoop drivers
both ArduPilot drivers consider 0 to be invalid, so you don't end up with any readings at all if you just send through 0 all the time. Fudge 0cm to 1cm for the simulated data for these drivers
1 parent 0fa227f commit e15f167

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

libraries/SITL/SIM_RF_NoopLoop.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ using namespace SITL;
2222

2323
uint32_t RF_Nooploop::packet_for_alt(uint16_t alt_cm, uint8_t *buffer, uint8_t buflen)
2424
{
25+
// the NoopLoop driver considers a value of zero invalid and won't
26+
// consider it a reading, so you end up with no readings at all
27+
// from the driver. Fudge it here:
28+
if (alt_cm == 0) {
29+
alt_cm = 1;
30+
}
2531

2632
int32_t alt_scaled = 2560*alt_cm;
2733
buffer[0] = 0x57;

libraries/SITL/SIM_RF_Wasp.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,11 @@ void RF_Wasp::update(float range)
113113

114114
uint32_t RF_Wasp::packet_for_alt(uint16_t alt_cm, uint8_t *buffer, uint8_t buflen)
115115
{
116+
// the Wasp driver does not consider 0 a valid reading, so you end
117+
// up getting 0 samples back if you send exactly zero all the
118+
// time. So munge it a little bit:
119+
if (alt_cm == 0) {
120+
alt_cm = 1;
121+
}
116122
return snprintf((char*)buffer, buflen, "%f\n", alt_cm*0.01f);
117123
}

0 commit comments

Comments
 (0)