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
5865a40b
Commit
5865a40b
authored
6 years ago
by
TSC21
Committed by
Lorenz Meier
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
attitude_estimator_q: add attitude data validation check
parent
6b2fb549
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/modules/attitude_estimator_q/attitude_estimator_q_main.cpp
+53
-40
53 additions, 40 deletions
...odules/attitude_estimator_q/attitude_estimator_q_main.cpp
with
53 additions
and
40 deletions
src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp
+
53
−
40
View file @
5865a40b
...
...
@@ -100,17 +100,18 @@ public:
void
task_main
();
private:
const
float
_eo_max_std_dev
=
100.0
f
;
/**< Maximum permissible standard deviation for estimated orientation */
const
float
_dt_min
=
0.00001
f
;
const
float
_dt_max
=
0.02
f
;
bool
_task_should_exit
=
false
;
/**< if true, task should exit */
int
_control_task
=
-
1
;
/**< task handle for task */
bool
_task_should_exit
=
false
;
/**< if true, task should exit */
int
_control_task
=
-
1
;
/**< task handle for task */
int
_params_sub
=
-
1
;
int
_sensors_sub
=
-
1
;
int
_global_pos_sub
=
-
1
;
int
_vision_sub
=
-
1
;
int
_mocap_sub
=
-
1
;
int
_vision_
odom_
sub
=
-
1
;
int
_mocap_
odom_
sub
=
-
1
;
int
_magnetometer_sub
=
-
1
;
orb_advert_t
_att_pub
=
nullptr
;
...
...
@@ -262,8 +263,8 @@ void AttitudeEstimatorQ::task_main()
#endif
_sensors_sub
=
orb_subscribe
(
ORB_ID
(
sensor_combined
));
_vision_sub
=
orb_subscribe
(
ORB_ID
(
vehicle_visual_odometry
));
_mocap_sub
=
orb_subscribe
(
ORB_ID
(
vehicle_mocap_odometry
));
_vision_
odom_
sub
=
orb_subscribe
(
ORB_ID
(
vehicle_visual_odometry
));
_mocap_
odom_
sub
=
orb_subscribe
(
ORB_ID
(
vehicle_mocap_odometry
));
_params_sub
=
orb_subscribe
(
ORB_ID
(
parameter_update
));
_global_pos_sub
=
orb_subscribe
(
ORB_ID
(
vehicle_global_position
));
_magnetometer_sub
=
orb_subscribe
(
ORB_ID
(
vehicle_magnetometer
));
...
...
@@ -341,49 +342,61 @@ void AttitudeEstimatorQ::task_main()
// Update vision and motion capture heading
bool
vision_updated
=
false
;
orb_check
(
_vision_sub
,
&
vision_updated
);
orb_check
(
_vision_
odom_
sub
,
&
vision_updated
);
if
(
vision_updated
)
{
vehicle_attitude_s
vision
;
if
(
orb_copy
(
ORB_ID
(
vehicle_visual_odometry
),
_vision_sub
,
&
vision
)
==
PX4_OK
)
{
Quatf
q
(
vision
.
q
);
Dcmf
Rvis
=
Quatf
(
vision
.
q
);
Vector3f
v
(
1.0
f
,
0.0
f
,
0.4
f
);
// Rvis is Rwr (robot respect to world) while v is respect to world.
// Hence Rvis must be transposed having (Rwr)' * Vw
// Rrw * Vw = vn. This way we have consistency
_vision_hdg
=
Rvis
.
transpose
()
*
v
;
// vision external heading usage (ATT_EXT_HDG_M 1)
if
(
_ext_hdg_mode
==
1
)
{
// Check for timeouts on data
_ext_hdg_good
=
vision
.
timestamp
>
0
&&
(
hrt_elapsed_time
(
&
vision
.
timestamp
)
<
500000
);
vehicle_odometry_s
vision
;
if
(
orb_copy
(
ORB_ID
(
vehicle_visual_odometry
),
_vision_odom_sub
,
&
vision
)
==
PX4_OK
)
{
// validation check for vision attitude data
bool
vision_att_valid
=
!
PX4_ISFINITE
(
vision
.
pose_covariance
[
0
])
?
fabsf
(
sqrtf
(
fmaxf
(
vision
.
pose_covariance
[
15
],
fmaxf
(
vision
.
pose_covariance
[
18
],
vision
.
pose_covariance
[
20
])))
-
_eo_max_std_dev
)
<
FLT_EPSILON
:
true
;
if
(
vision_att_valid
)
{
Dcmf
Rvis
=
Quatf
(
vision
.
q
);
Vector3f
v
(
1.0
f
,
0.0
f
,
0.4
f
);
// Rvis is Rwr (robot respect to world) while v is respect to world.
// Hence Rvis must be transposed having (Rwr)' * Vw
// Rrw * Vw = vn. This way we have consistency
_vision_hdg
=
Rvis
.
transpose
()
*
v
;
// vision external heading usage (ATT_EXT_HDG_M 1)
if
(
_ext_hdg_mode
==
1
)
{
// Check for timeouts on data
_ext_hdg_good
=
vision
.
timestamp
>
0
&&
(
hrt_elapsed_time
(
&
vision
.
timestamp
)
<
500000
);
}
}
}
}
bool
mocap_updated
=
false
;
orb_check
(
_mocap_sub
,
&
mocap_updated
);
orb_check
(
_mocap_
odom_
sub
,
&
mocap_updated
);
if
(
mocap_updated
)
{
vehicle_odometry_s
mocap
;
if
(
orb_copy
(
ORB_ID
(
vehicle_mocap_odometry
),
_mocap_sub
,
&
mocap
)
==
PX4_OK
)
{
Dcmf
Rmoc
=
Quatf
(
mocap
.
q
);
Vector3f
v
(
1.0
f
,
0.0
f
,
0.4
f
);
// Rmoc is Rwr (robot respect to world) while v is respect to world.
// Hence Rmoc must be transposed having (Rwr)' * Vw
// Rrw * Vw = vn. This way we have consistency
_mocap_hdg
=
Rmoc
.
transpose
()
*
v
;
// Motion Capture external heading usage (ATT_EXT_HDG_M 2)
if
(
_ext_hdg_mode
==
2
)
{
// Check for timeouts on data
_ext_hdg_good
=
mocap
.
timestamp
>
0
&&
(
hrt_elapsed_time
(
&
mocap
.
timestamp
)
<
500000
);
if
(
orb_copy
(
ORB_ID
(
vehicle_mocap_odometry
),
_mocap_odom_sub
,
&
mocap
)
==
PX4_OK
)
{
// validation check for mocap attitude data
bool
mocap_att_valid
=
!
PX4_ISFINITE
(
mocap
.
pose_covariance
[
0
])
?
fabsf
(
sqrtf
(
fmaxf
(
mocap
.
pose_covariance
[
15
],
fmaxf
(
mocap
.
pose_covariance
[
18
],
mocap
.
pose_covariance
[
20
])))
-
_eo_max_std_dev
)
<
FLT_EPSILON
:
true
;
if
(
mocap_att_valid
)
{
Dcmf
Rmoc
=
Quatf
(
mocap
.
q
);
Vector3f
v
(
1.0
f
,
0.0
f
,
0.4
f
);
// Rmoc is Rwr (robot respect to world) while v is respect to world.
// Hence Rmoc must be transposed having (Rwr)' * Vw
// Rrw * Vw = vn. This way we have consistency
_mocap_hdg
=
Rmoc
.
transpose
()
*
v
;
// Motion Capture external heading usage (ATT_EXT_HDG_M 2)
if
(
_ext_hdg_mode
==
2
)
{
// Check for timeouts on data
_ext_hdg_good
=
mocap
.
timestamp
>
0
&&
(
hrt_elapsed_time
(
&
mocap
.
timestamp
)
<
500000
);
}
}
}
}
...
...
@@ -451,8 +464,8 @@ void AttitudeEstimatorQ::task_main()
orb_unsubscribe
(
_params_sub
);
orb_unsubscribe
(
_sensors_sub
);
orb_unsubscribe
(
_global_pos_sub
);
orb_unsubscribe
(
_vision_sub
);
orb_unsubscribe
(
_mocap_sub
);
orb_unsubscribe
(
_vision_
odom_
sub
);
orb_unsubscribe
(
_mocap_
odom_
sub
);
orb_unsubscribe
(
_magnetometer_sub
);
}
...
...
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