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
d7611cac
Commit
d7611cac
authored
7 years ago
by
Mohammed Kabir
Committed by
Lorenz Meier
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
commander : make mag calibration correctly lock-in to corresponding uORB topic
parent
52f1718b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/commander/mag_calibration.cpp
+41
-13
41 additions, 13 deletions
src/modules/commander/mag_calibration.cpp
with
41 additions
and
13 deletions
src/modules/commander/mag_calibration.cpp
+
41
−
13
View file @
d7611cac
...
...
@@ -581,26 +581,54 @@ calibrate_return mag_calibrate_all(orb_advert_t *mavlink_log_pub)
if
(
result
==
calibrate_return_ok
)
{
// We should not try to subscribe if the topic doesn't actually exist and can be counted.
const
unsigned
mag_count
=
orb_group_count
(
ORB_ID
(
sensor_mag
));
const
unsigned
orb_
mag_count
=
orb_group_count
(
ORB_ID
(
sensor_mag
));
// Warn that we will not calibrate more than max_mags magnetometers
if
(
mag_count
>
max_mags
)
{
calibration_log_critical
(
mavlink_log_pub
,
"[cal] Detected %u mags, but will calibrate only %u"
,
mag_count
,
max_mags
);
if
(
orb_
mag_count
>
max_mags
)
{
calibration_log_critical
(
mavlink_log_pub
,
"[cal] Detected %u mags, but will calibrate only %u"
,
orb_
mag_count
,
max_mags
);
}
for
(
unsigned
cur_mag
=
0
;
cur_mag
<
mag_count
&&
cur_mag
<
max_mags
;
cur_mag
++
)
{
// Mag in this slot is available
worker_data
.
sub_mag
[
cur_mag
]
=
orb_subscribe_multi
(
ORB_ID
(
sensor_mag
),
cur_mag
);
for
(
unsigned
cur_mag
=
0
;
cur_mag
<
orb_mag_count
&&
cur_mag
<
max_mags
;
cur_mag
++
)
{
// Lock in to correct ORB instance
bool
found_cur_mag
=
false
;
for
(
unsigned
i
=
0
;
i
<
orb_mag_count
;
i
++
)
{
worker_data
.
sub_mag
[
cur_mag
]
=
orb_subscribe_multi
(
ORB_ID
(
sensor_mag
),
cur_mag
);
if
(
worker_data
.
sub_mag
[
cur_mag
]
<
0
)
{
calibration_log_critical
(
mavlink_log_pub
,
"[cal] Mag #%u not found, abort"
,
cur_mag
);
result
=
calibrate_return_error
;
break
;
}
struct
mag_report
report
;
orb_copy
(
ORB_ID
(
sensor_mag
),
worker_data
.
sub_mag
[
cur_mag
],
&
report
);
#if !defined(__PX4_QURT) && !defined(__PX4_POSIX_RPI) && !defined(__PX4_POSIX_BEBOP)
// For NuttX, we get the UNIQUE device ID from the sensor driver via an IOCTL
// and match it up with the one from the uORB subscription, because the
// instance ordering of uORB and the order of the FDs may not be the same.
if
(
report
.
device_id
==
device_ids
[
cur_mag
])
{
// Device IDs match, correct ORB instance for this mag
found_cur_mag
=
true
;
break
;
}
else
{
orb_unsubscribe
(
worker_data
.
sub_mag
[
cur_mag
]);
}
#elif defined(__PX4_QURT) || defined(__PX4_POSIX_RPI) || defined(__PX4_POSIX_BEBOP)
// For the DriverFramework drivers, we fill device ID (this is the first time) by copying one report.
device_ids
[
cur_mag
]
=
report
.
device_id
;
found_cur_mag
=
true
;
#if defined(__PX4_QURT) || defined(__PX4_POSIX_RPI) || defined(__PX4_POSIX_BEBOP)
// For QURT respectively the driver framework, we need to get the device ID by copying one report.
struct
mag_report
mag_report
;
orb_copy
(
ORB_ID
(
sensor_mag
),
worker_data
.
sub_mag
[
cur_mag
],
&
mag_report
);
device_ids
[
cur_mag
]
=
mag_report
.
device_id
;
#endif
}
if
(
worker_data
.
sub_mag
[
cur_mag
]
<
0
)
{
calibration_log_critical
(
mavlink_log_pub
,
"[cal] Mag #%u
not found, abort"
,
cur_mag
);
if
(
!
found_
cur_mag
)
{
calibration_log_critical
(
mavlink_log_pub
,
"[cal] Mag #%u
(ID %u) no matching uORB devid"
,
cur_mag
,
device_ids
[
cur_mag
]
);
result
=
calibrate_return_error
;
break
;
}
...
...
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