-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
precland: support receiving LANDING_TARGET message #9050
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2bdd909
precland: fix typos and code style
okalachev 91f5ba7
precland: fix landing_target_pose subscription check
okalachev dc88c34
precland: fix incorrect converting microseconds to seconds
okalachev 02d52a8
precland: support receiving LANDING_TARGET message
okalachev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,8 +69,8 @@ void | |
PrecLand::on_activation() | ||
{ | ||
// We need to subscribe here and not in the constructor because constructor is called before the navigator task is spawned | ||
if (!_targetPoseSub) { | ||
_targetPoseSub = orb_subscribe(ORB_ID(landing_target_pose)); | ||
if (_target_pose_sub < 0) { | ||
_target_pose_sub = orb_subscribe(ORB_ID(landing_target_pose)); | ||
} | ||
|
||
_state = PrecLandState::Start; | ||
|
@@ -108,15 +108,14 @@ void | |
PrecLand::on_active() | ||
{ | ||
// get new target measurement | ||
bool updated = false; | ||
orb_check(_targetPoseSub, &updated); | ||
orb_check(_target_pose_sub, &_target_pose_updated); | ||
|
||
if (updated) { | ||
orb_copy(ORB_ID(landing_target_pose), _targetPoseSub, &_target_pose); | ||
if (_target_pose_updated) { | ||
orb_copy(ORB_ID(landing_target_pose), _target_pose_sub, &_target_pose); | ||
_target_pose_valid = true; | ||
} | ||
|
||
if ((hrt_elapsed_time(&_target_pose.timestamp) / 1e-6f) > _param_timeout.get()) { | ||
if ((hrt_elapsed_time(&_target_pose.timestamp) / 1e6f) > _param_timeout.get()) { | ||
_target_pose_valid = false; | ||
} | ||
|
||
|
@@ -212,7 +211,7 @@ PrecLand::run_state_horizontal_approach() | |
|
||
// check if target visible, if not go to start | ||
if (!check_state_conditions(PrecLandState::HorizontalApproach)) { | ||
PX4_WARN("Lost landing target while landig (horizontal approach)."); | ||
PX4_WARN("Lost landing target while landing (horizontal approach)."); | ||
|
||
// Stay at current position for searching for the landing target | ||
pos_sp_triplet->current.lat = _navigator->get_global_position()->lat; | ||
|
@@ -466,7 +465,7 @@ bool PrecLand::check_state_conditions(PrecLandState state) | |
// if we're already in this state, only want to make it invalid if we reached the target but can't see it anymore | ||
if (_state == PrecLandState::HorizontalApproach) { | ||
if (fabsf(_target_pose.x_abs - vehicle_local_position->x) < _param_hacc_rad.get() | ||
&& fabsf(_target_pose.y_rel - vehicle_local_position->y) < _param_hacc_rad.get()) { | ||
&& fabsf(_target_pose.y_abs - vehicle_local_position->y) < _param_hacc_rad.get()) { | ||
// we've reached the position where we last saw the target. If we don't see it now, we need to do something | ||
return _target_pose_valid && _target_pose.abs_pos_valid; | ||
|
||
|
@@ -478,7 +477,7 @@ bool PrecLand::check_state_conditions(PrecLandState state) | |
} | ||
|
||
// If we're trying to switch to this state, the target needs to be visible | ||
return _target_pose_valid && _target_pose.abs_pos_valid; | ||
return _target_pose_updated && _target_pose.abs_pos_valid; | ||
|
||
case PrecLandState::DescendAboveTarget: | ||
|
||
|
@@ -494,12 +493,14 @@ bool PrecLand::check_state_conditions(PrecLandState state) | |
|
||
} else { | ||
// if not already in this state, need to be above target to enter it | ||
return _target_pose_valid && _target_pose.abs_pos_valid | ||
&& fabsf(_target_pose.x_rel) < _param_hacc_rad.get() && fabsf(_target_pose.y_rel) < _param_hacc_rad.get(); | ||
return _target_pose_updated && _target_pose.abs_pos_valid | ||
&& fabsf(_target_pose.x_abs - vehicle_local_position->x) < _param_hacc_rad.get() | ||
&& fabsf(_target_pose.y_abs - vehicle_local_position->y) < _param_hacc_rad.get(); | ||
} | ||
|
||
case PrecLandState::FinalApproach: | ||
return _target_pose_valid && _target_pose.rel_pos_valid && _target_pose.z_rel < _param_final_approach_alt.get(); | ||
return _target_pose_valid && _target_pose.abs_pos_valid | ||
&& (_target_pose.z_abs - vehicle_local_position->z) < _param_final_approach_alt.get(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should use relative measurements, see my other comment. |
||
|
||
case PrecLandState::Search: | ||
return true; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bug. But the fix should be in the other direction, see my other comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ndepal could you submit the correct fix as a separate PR? We are doing preclands and have been observing weird horizontal approach failures. Probably related to this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I can do it.
@ndepal, you mean we just have to use
_target_pose.x_rel
instead of_target_pose.x_abs - vehicle_local_position->x
?Also, I wanted to notice that this is incorrect calculation if we're inside the desired radius. The correct would be
sqrt(pow(_target_pose.x_rel, 2) + pow(_target_pose.y_rel, 2))
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhkabir Sure thing. But if @okalachev does it, that's great.
Correct.
That would be the L2 norm. I used the L1 norm because it's cheaper to compute and just as good in this situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@okalachev Is this addressed now?