* logger: prevent logpath buffer overflows
The handling of the log path had the potential to cause buffer
overflows, especially on POSIX platforms where the paths are often much
longer than just 64 chars.
* sdlog2: prevent logpath buffer overflows
When the log folder path was created, this was done with the unsafe
sprintf function instead of snprintf. This caused buffer overflows in
SITL but the overflow was usually not detected until recent testing of
some work in progress.
Previously, the MAX and MIN were both 512 meaning that usually it would
start writing at > 512 bytes but only write 512 bytes which results in
a 512 bytes write shortly followed by a e.g. 30 bytes write.
Also, performance (measured in missed poll updates) seems slightly
better on Snapdragon with bigger chunks.
Reason: the value is easier to read & handle (for example plotting). In
most places the value is needed, not the integral.
Note that this breaks the replay format for sdlog2 replay
- voting is now at a central place instead of duplicated within the
estimators
-> this also means that estimators that did not do voting so far,
now have voting, like ekf2
- estimators requiring more than that can still subscribe to the raw
sensors
- allows sensors_combined to be 3 times smaller
- reduces logger, memcpy (cache) & RAM overhead
- all modules requiring only 1 or 2 sensor values now automatically get
the voted result
- this also adds voting to baro
Decreases the message size from 780 to 280 bytes.
In particular, all modules using sensor_combined must use the integral now.
The sensor value can easily be reconstructed by dividing with dt.
Voters now need to be moved into sensors module, because error count and
priority is removed from the topic.
Any module that requires additional data from a sensor can subscribe to
the raw sensor topics.
At two places, values are set to zero instead of subscribing to the raw
sensors (with the assumption that no one reads them):
- mavlink mavlink_highres_imu_t::abs_pressure
- sdlog2: sensor temperatures
These are not really used. differential_pressure is just copied from the
topic with the same name.
for sdlog2 we assume no one needs the diff pressure fields and set it to 0.
We plan to switch to the new logger soon anyway.
* Use variance to control publishing for LPE.
* Don't stop publishing if we have gps/ baro.
* LPE tuning and cleanup.
* Added bias saturation to LPE.
* Added vector enabled low pass filter block.
* Added rk4 integration and pub lowpass to LPE.
* Fix std::abs issue on mac/ reset lowpass on state reset.
* Don't estimate gyro bias when rotating at high speed att_est_q.
* Lowered low pass on position to 5 Hz for LPE.
* Streamline state space update for LPE.
* Added health flags to est2 log.
* Revert to old tuning, more conservative, less faults.
* Formatting.
* Fix for fault message on LPE.
* Added subscription throttling to LPE.
* Formatting.
Previously, if no time was set, sdlog2 created a folder like sess001,
sess002 for every logfile. The logfiles would then always be named
log001.px4log and their numbering would not actually increase.
This is now fixed and a new folder is only created per boot.
Since orb_exist doesn't work on the Snapdragon Linux side, we need to do
an additional orb_check after the orb_subscribe_multi, otherwise we copy
garbage.
The segfault was triggered by a count/length information about ESC
packets which lead to access outside the struct in the garbage case.
Since the vehicle_status topic has been split up, we can't publish it
together with the the split cpuload and commander_state topics.
Therefore, the log field STAT.MainState will change to COMM.MainState
because it is only the internal commander state. Important to the
outside is STAT.NavState.
Likewise, the log field STAT.Load becomes LOAD.CPU.
In SITL and on Snapdragon, the logging performance is high enough, so we
can log both: the usual topics, as well as the ekf2 replay fields.
Note that the ekf2 replay still needs to be enabled via param.
* sdlog2: move from STAT.MainState to COMM.MainState
This fixes a bug where vehicle_system_status and the commander internal
state were conflicting.
This will need adaptations in logging tools.
* sdlog2: don't bother changing STAT.MainState
For compatibility reasons, let's stick to the used log field (but still
fix the bug where the buffer (union) was overwrittern.
- either sensor combined or the replay topic where copied into
the union buffer but at times the memory was overwritten by other
topics which updated below
- this change makes sure that the two topics are copied into the union
buffer at the correct location in the code
This fixes an issue where topics where not subscribed to on the Linux
side on Snapdragon. It's a hack until there is a proper fix for the
orb_exists() call.
Most condition bools in the commander are not used anywhere but in the
commander. It therefore makes sense to move them to a different internal
struct and remove them from the vehicle_status message.
Also, the land_detected should be used by all the modules instead of
getting it through the commander and system_status.
The commander used to consume the battery_status topic and write the
contents after some calculations into the system state. Instead, the
calculations now happen in library calls in systemlib/battery.
This moves the battery fields out of the vehicle_status message into the
battery_status topic.
This brought quite some changes in all modules that need battery
information. The current state is compiling but untested.