sensor calibration: apply board level adjustment to external sensors (#16127)

- apply SENS_BOARD_{X,Y,Z}_OFF to external sensors to prevent unnecessary misalignment with internal IMU
This commit is contained in:
Daniel Agar
2020-11-12 10:37:30 -05:00
committed by GitHub
parent 5f0c572c61
commit d14b4221f1
7 changed files with 58 additions and 24 deletions
+20 -4
View File
@@ -34,6 +34,7 @@
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/log.h>
#include <lib/conversion/rotation.h>
#include <lib/mathlib/mathlib.h>
#include <lib/parameters/param.h>
using math::radians;
@@ -146,7 +147,7 @@ bool SetCalibrationParamsVector3f(const char *sensor_type, const char *cal_type,
return ret == PX4_OK;
}
Dcmf GetBoardRotation()
Eulerf GetSensorLevelAdjustment()
{
float x_offset = 0.f;
float y_offset = 0.f;
@@ -155,13 +156,28 @@ Dcmf GetBoardRotation()
param_get(param_find("SENS_BOARD_Y_OFF"), &y_offset);
param_get(param_find("SENS_BOARD_Z_OFF"), &z_offset);
const Dcmf board_rotation_offset(Eulerf(radians(x_offset), radians(y_offset), radians(z_offset)));
return Eulerf{radians(x_offset), radians(y_offset), radians(z_offset)};
}
enum Rotation GetBoardRotation()
{
// get transformation matrix from sensor/board to body frame
int32_t board_rot = 0;
int32_t board_rot = -1;
param_get(param_find("SENS_BOARD_ROT"), &board_rot);
return board_rotation_offset * get_rot_matrix((enum Rotation)board_rot);
if (board_rot >= 0 && board_rot <= Rotation::ROTATION_MAX) {
return static_cast<enum Rotation>(board_rot);
} else {
PX4_ERR("invalid SENS_BOARD_ROT: %d", board_rot);
}
return Rotation::ROTATION_NONE;
}
Dcmf GetBoardRotationMatrix()
{
return get_rot_matrix(GetBoardRotation());
}
} // namespace calibration