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
6a8bac2b
Commit
6a8bac2b
authored
9 years ago
by
Julian Oes
Browse files
Options
Downloads
Patches
Plain Diff
df_hmc5883_wrapper: subscribe to calibration data
parent
23da6696
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/platforms/posix/drivers/df_hmc5883_wrapper/df_hmc5883_wrapper.cpp
+41
-0
41 additions, 0 deletions
...s/posix/drivers/df_hmc5883_wrapper/df_hmc5883_wrapper.cpp
with
41 additions
and
0 deletions
src/platforms/posix/drivers/df_hmc5883_wrapper/df_hmc5883_wrapper.cpp
+
41
−
0
View file @
6a8bac2b
...
...
@@ -56,6 +56,8 @@
#include
<drivers/drv_mag.h>
#include
<uORB/topics/mag_calibration.h>
#include
<board_config.h>
//#include <mathlib/math/filter/LowPassFilter2p.hpp>
//#include <lib/conversion/rotation.h>
...
...
@@ -93,10 +95,18 @@ public:
private:
int
_publish
(
struct
mag_sensor_data
&
data
);
void
_update_mag_calibration
();
//enum Rotation _rotation;
orb_advert_t
_mag_topic
;
int
_mag_calibration_sub
;
struct
mag_calibration_s
_mag_calibration
;
bool
_mag_calibration_set
;
int
_mag_orb_class_instance
;
perf_counter_t
_mag_sample_perf
;
...
...
@@ -129,6 +139,11 @@ int DfHmc9250Wrapper::start()
return
-
1
;
}
/* Subscribe to calibration topic. */
if
(
_mag_calibration_sub
<
0
)
{
_mag_calibration_sub
=
orb_subscribe
(
ORB_ID
(
mag_calibration
));
}
/* Init device and start sensor. */
int
ret
=
init
();
...
...
@@ -160,8 +175,34 @@ int DfHmc9250Wrapper::stop()
return
0
;
}
void
DfHmc9250Wrapper
::
_update_mag_calibration
()
{
bool
updated
;
orb_check
(
_mag_calibration_sub
,
&
updated
);
if
(
updated
)
{
mag_calibration_s
new_calibration
;
orb_copy
(
ORB_ID
(
mag_calibration
),
_mag_calibration_sub
,
&
new_calibration
);
/* Only accept calibration for this device. */
if
(
m_id
.
dev_id
==
new_calibration
.
device_id
)
{
_mag_calibration
=
new_calibration
;
_mag_calibration_set
=
true
;
}
}
}
int
DfHmc9250Wrapper
::
_publish
(
struct
mag_sensor_data
&
data
)
{
/* Check if calibration values are still up-to-date. */
_update_mag_calibration
();
if
(
!
_mag_calibration_set
)
{
// TODO: check the return codes of this function
return
0
;
}
/* Publish mag first. */
perf_begin
(
_mag_sample_perf
);
...
...
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