See discussion here:
https://github.com/ArduPilot/ardupilot/issues/7331
we were getting some uninitialised variables. While it only showed up in
AP_SbusOut, it means we can't be sure it won't happen on other objects,
so safest to remove the approach
Thanks to assistance from Lucas, Peter and Francisco
The following is a Barometer sensor driver for the LPS25H Barometer that
is integrated in the 96Boards STM32 Sensor mezzanine board.
the update includes the .cpp and .h files of the driver as well as the
updates required in AP_Baro.cpp.
The method was not using the instance parameter. Instead it always use
primary barometer. Bug was not detected because method
get_last_update() is used where instance is _primary.
Detected with warnings, warnings are useful :-)
this is needed to enable probing for a MS5611 on external I2C bus. The
MS5611 looks the same as a MS5525 airspeed sensor, so we can't just
auto-probe. Users will need to enable external barometers
the datasheet says that if you get back zero in an ADC read that the
next value can be corrupt. I have seen this happen on the FMUv1,
leading to bad altitude readings
RC_Channel: To nullptr from NULL.
AC_Fence: To nullptr from NULL.
AC_Avoidance: To nullptr from NULL.
AC_PrecLand: To nullptr from NULL.
DataFlash: To nullptr from NULL.
SITL: To nullptr from NULL.
GCS_MAVLink: To nullptr from NULL.
DataFlash: To nullptr from NULL.
AP_Compass: To nullptr from NULL.
Global: To nullptr from NULL.
Global: To nullptr from NULL.
We currently check examples are buildable with waf which doesn't need
the libraries to be specified in a make.inc file. Having the makefiles
there is misleading since people try to build and realize the build is
broken.
- reorder and document members.
- remove tentative of vertical alignement
- like was done for accumulated values, move the calibration
values to a struct
This converts MS56XX to use the thread started by SPI/I2C instead of
using the timer thread. This also fixes a possible starvation of the
main thread:
1) INS driver registers itself to be sampled on timer thread
2) MS56XX registers itself to be sampled on timer thread
3) Main thread waits for a sample from INS with
ins.wait_for_sample()
4) timer thread is waiting on update from MS56XX and consequently
the main thread is waiting on an I2C/SPI transfer
Besides this starvation there's another one due to reuse of the timer
lock in order to pump values from the timer thread to the main thread. A
call to the update() method when we have a sample available would need
to wait on any other driver holding the timer lock.
Now there's a lock just to pass the new values from the bus thread to
the main thread with a very tiny critical region, not waiting on any
bus transfers and/or syscalls.
Instead of a couple seconds, make it about 15sec. This makes TECS happy by not glitching the height demand as much. When applied too fast the TECS height demand causes a large single oscillation as it chases the filter lag.
Instead of depending on the frequency accumulate() is called, use
AverageIntegralFilter with 10 samples. The data obtained by BMP085 is
too noisy with any value of OVERSAMPLING so use twice the number of
samples as currently used. Besides that now we are sure there's always
10 samples used in the average.
The temperature readings is not subject to white noise so there's no
point in averaging its reading. Moreover since for a normal 50Hz
accumulate() / 10Hz update() it would read temperature only once per
update(), it's pointless to keep averaging and introducing rounding
error.
The temperature doesn't need to be checked as frequent as pressure, too.
The datasheet even suggests on section 3.3, page 10 to enable standard
mode and read the temperature at 1Hz. Here we reduce it to 2Hz
(considering the accumulate() function being called at 50Hz).
If we don't have EOC pin and assuming the accumulate() function is
called at 50Hz (or higher) we would take very few samples to accumulate
before the update is called. That's because since we have to wait 26ms
to get a sample and we calling accumulate() every 20ms, half of the
times it will return without getting anything. So we will
be using 2 or 3 samples only to average.
If we don't have EOC, use OVERSAMPLING=2 which gives us more noise, but
that we can filter out by using measurements to average. When we have
EOC we don't need it because most of the time the conversion will take
less than 20ms: I'm getting 16ms on most of them while bench-testing.
We don't need to expose to other libraries how each backend is
implemented. AP_Baro.h is the main header, included by other libraries.
Instead of including each backend in the main header, move them to where
they are needed. Additionally standardize the order and how we include
the headers.
The advantages are:
- Internals of each backend is not exposed outside of the
library
- Faster incremental builds since we don't need to recompile
whoever includes AP_Baro.h because a backend changed
The configuration of MS5637 is different from MS5611 in 2 ways:
- The PROM is of 112 bytes rather than 128
- The CRC is located in the first MSB of the first word, not the
last one
For CRC calculation we also need to zero out the last (missing) word.
This renames _check_crc() to _read_prom(), which returns false when the
PROM doesn't contain valid data. It also makes it virtual so MS5637 can
override it. This also moves the PROM read to be all in the same place
rather than split between the CRC field and coefficient fields. Finally
calculate_crc() is renamed to crc4() to be shorter and add info on what
it does.
On MS5637 we will need to override the method to read and calculate the
PROM's crc. Thus we need a 2-phase init.
It also makes the constructor of AP_Baro_MS56XX protected since only the
derived classes should instantiate the base one.
This is the same change as done in PX4:
This reduces self-heating of the sensor which reduces the amount
of altitude change when warming up. Apparently some individual
sensors are severely affected by this.
Unfortunately it raises the noise level, but Paul is confident
it won't be a significant issue.
Remove the checks for HAL_CPU_CLASS > HAL_CPU_CLASS_16 and
HAL_CPU_CLASS >= HAL_CPU_CLASS_75. Corresponding dead code will be
removed on separate commits.
Now variables don't have to be declared with PROGMEM anymore, so remove
them. This was automated with:
git grep -l -z PROGMEM | xargs -0 sed -i 's/ PROGMEM / /g'
git grep -l -z PROGMEM | xargs -0 sed -i 's/PROGMEM//g'
The 2 commands were done so we don't leave behind spurious spaces.
AVR-specific places were not changed.
The PSTR is already define as a NOP for all supported platforms. It's
only needed for AVR so here we remove all the uses throughout the
codebase.
This was automated with a simple python script so it also converts
places which spans to multiple lines, removing the matching parentheses.
AVR-specific places were not changed.
Instead of requiring every program to specify the HAL related modules,
let the build system do it (in practice everything we compiled depended
on HAL anyway). This allow including only the necessary files in the
compilation.
The switching between different AP_HAL was happening by giving different
definitions of AP_HAL_BOARD_DRIVER, and the programs would use it to
instantiate.
A program or library code would have to explicitly include (and depend)
on the concrete implementation of the HAL, even when using it only via
interface.
The proposed change move this dependency to be link time. There is a
AP_HAL::get_HAL() function that is used by the client code. Each
implementation of HAL provides its own definition of this function,
returning the appropriate concrete instance.
Since this replaces the job of AP_HAL_BOARD_DRIVER, the definition was
removed.
The static variables for PX4 and VRBRAIN were named differently to avoid
shadowing the extern symbol 'hal'.
As AVR2560 is not supported anymore and do integer operations is
usually faster than float-point the _calculate() implementation was
done using only integer operations and as more close to what
datasheet says.
If there is a read error, reading from the adc will return 0 but moreover,
we need to re-initiate a read or else we are stuck forever.
From MS5611-01BA03 datasheet, p. 10, CONVERSION SEQUENCE:
"After the conversion, using ADC read command the result is clocked out with the MSB first.
If the conversion is not executed before the ADC read command, or the ADC read command is
repeated, it will give 0 as the output result."
If we have an error in the SPI or I2C transaction we should not change
the state. Otherwise we might read a temperature when the sensor is
reporting pressure and vice-versa.
This param seems to have been un-implemented. This is putting it back in. Adds a meter offset to the calculated altitude form the baro sensors.
Also changes it from int8 to float
This commit changes the way libraries headers are included in source files:
- If the header is in the same directory the source belongs to, so the
notation '#include ""' is used with the path relative to the directory
containing the source.
- If the header is outside the directory containing the source, then we use
the notation '#include <>' with the path relative to libraries folder.
Some of the advantages of such approach:
- Only one search path for libraries headers.
- OSs like Windows may have a better lookup time.
this allows the use of an external temperature sensor for calibration
purposes, such as the sensor built in to the digital airspeed sensor.
The main affect this has is on the EAS2TAS calculation
The get_calibration_temperature() is used to choose either an external
temperature or an internal one. If an internal one is used then it is
clamped at no higher than 25 degrees C, to prevent hot electronics
on startup affecting altitude scaling and EAS2TAS