Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
5a841761
Commit
5a841761
authored
6 years ago
by
Daniel Agar
Committed by
Lorenz Meier
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
PX4Accelerometer apply sensor rotation before scaling
- prevents loss of numerical precision - fixes #11695
parent
b35883f5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib/drivers/accelerometer/PX4Accelerometer.cpp
+9
-4
9 additions, 4 deletions
src/lib/drivers/accelerometer/PX4Accelerometer.cpp
src/lib/drivers/accelerometer/PX4Accelerometer.hpp
+1
-1
1 addition, 1 deletion
src/lib/drivers/accelerometer/PX4Accelerometer.hpp
with
10 additions
and
5 deletions
src/lib/drivers/accelerometer/PX4Accelerometer.cpp
+
9
−
4
View file @
5a841761
...
...
@@ -40,7 +40,7 @@ PX4Accelerometer::PX4Accelerometer(uint32_t device_id, uint8_t priority, enum Ro
CDev
(
nullptr
),
ModuleParams
(
nullptr
),
_sensor_accel_pub
{
ORB_ID
(
sensor_accel
),
priority
},
_rotation
{
get_rot_matrix
(
rotation
)
}
_rotation
{
rotation
}
{
_class_device_instance
=
register_class_devname
(
ACCEL_BASE_DEVICE_PATH
);
...
...
@@ -103,9 +103,14 @@ void PX4Accelerometer::update(hrt_abstime timestamp, int16_t x, int16_t y, int16
sensor_accel_s
&
report
=
_sensor_accel_pub
.
get
();
report
.
timestamp
=
timestamp
;
// Apply rotation, range scale, and the calibrating offset/scale
const
matrix
::
Vector3f
val_raw
{(
float
)
x
,
(
float
)
y
,
(
float
)
z
};
const
matrix
::
Vector3f
val_calibrated
{
_rotation
*
(((
val_raw
*
report
.
scaling
)
-
_calibration_offset
).
emult
(
_calibration_scale
))};
// Apply rotation (before scaling)
float
xraw_f
=
x
;
float
yraw_f
=
y
;
float
zraw_f
=
z
;
rotate_3f
(
_rotation
,
xraw_f
,
yraw_f
,
zraw_f
);
// Apply range scale and the calibrating offset/scale
const
matrix
::
Vector3f
val_calibrated
{(((
matrix
::
Vector3f
{
xraw_f
,
yraw_f
,
zraw_f
}
*
report
.
scaling
)
-
_calibration_offset
).
emult
(
_calibration_scale
))};
// Filtered values
const
matrix
::
Vector3f
val_filtered
{
_filter
.
apply
(
val_calibrated
)};
...
...
This diff is collapsed.
Click to expand it.
src/lib/drivers/accelerometer/PX4Accelerometer.hpp
+
1
−
1
View file @
5a841761
...
...
@@ -72,7 +72,7 @@ private:
math
::
LowPassFilter2pVector3f
_filter
{
1000
,
100
};
Integrator
_integrator
{
4000
,
false
};
const
matrix
::
Dcmf
_rotation
;
const
enum
Rotation
_rotation
;
matrix
::
Vector3f
_calibration_scale
{
1.0
f
,
1.0
f
,
1.0
f
};
matrix
::
Vector3f
_calibration_offset
{
0.0
f
,
0.0
f
,
0.0
f
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment