Repository navigation
fix(autoware_gnss_poser): skip a fix without its antenna transform and report it once - #1523
Conversation
|
Thank you for contributing to the Autoware project! 🚧 If your pull request is in progress, switch it to draft mode. Please ensure:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1523 +/- ##
==========================================
- Coverage 82.36% 82.34% -0.02%
==========================================
Files 421 421
Lines 23857 23897 +40
Branches 147 147
==========================================
+ Hits 19650 19679 +29
- Misses 4177 4188 +11
Partials 30 30
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
f42fb12 to
d41c2f7
Compare
003f0ec to
047b131
Compare
047b131 to
5087ba1
Compare
|
This pull request comes from a fork, so its documentation site is built but not published.
|
5087ba1 to
5052773
Compare
sasakisasaki
left a comment
There was a problem hiding this comment.
Thank you for refactoring! Now reviewed again! I agree with merging this PR while put a very minor comment 👍
| // zero translation and rotation w = 1). | ||
| const geometry_msgs::msg::Transform antenna_to_base_link = | ||
| lookup_antenna_to_base_link_(fix.header.frame_id).value_or(geometry_msgs::msg::Transform{}); | ||
| // get TF from gnss_antenna to base_link. Without it the fix cannot be expressed as a base_link |
There was a problem hiding this comment.
It might be better to explicitly say at the very beginning of the comment like "Do not input this fix if its transform is not available".
There was a problem hiding this comment.
Thanks. I've separated the comment in two parts; the second one starts with an explicit explanation of the behavior.
5052773 to
cb14f60
Compare
Every outcome but Published returns a Result whose pose fields are all empty, spelled out as a row of std::nullopt at each return. The optional fields of Result now default to std::nullopt, so a return names only what it carries. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kentaro NAGATOMO <kentaro.nagatomo@tier4.jp>
When TF could not provide the transform from the antenna frame of a fix to base_link, the node composed the base_link pose with the identity transform, that is, it published the antenna position as the vehicle pose with the receiver's covariance. The pose is wrong by the lever arm whether the transform is merely late or never comes. Skip such a fix instead: no gnss_pose, gnss_pose_cov or map -> gnss_base TF, while gnss_fixed keeps reporting the receiver's status, which does not depend on TF. GnssPoser returns the new Outcome::TransformLookupFailed for it, which logs nothing more: the lookup keeps its throttled warning, which the next commit replaces. The lookup stays at the end of the pipeline, so a skipped fix has still been observed: it is in the position buffer and it is the previous position of the motion orientation. Skipped fixes are not replayed. Since the transform is looked up as the latest, a lookup fails only when the transform has not been received, not because of the fix's stamp, so skipping does not cost a setup that publishes the relation on /tf any fixes. This follows what autoware_ndt_scan_matcher does for the sensor frame of its point cloud: drop the measurement on failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kentaro NAGATOMO <kentaro.nagatomo@tier4.jp>
… a grace period Since the fix without its antenna transform is skipped, a missing transform means no pose, so it has to be visible. The lookup warned every second instead, from the first fix on, although right after startup /tf_static may simply not have arrived yet; the warnings went on for as long as the transform was missing. GnssPoser now decides when it is to be logged, as it decides to skip the fix: Result::antenna_transform_missing is set at the first fix that cannot get the transform more than antenna_transform_grace_period (5 s) after the first fix, of any status, and again only after a fix has got the transform. The time is measured by the fix header stamps, so that it follows the data, e.g. a rosbag replayed at another rate. The first fix is taken once, so a rosbag replayed in a loop gets the grace period only on its first pass; TF keeps /tf_static across the loop anyway. The node logs an error naming both frames when the flag is set, and the lookup no longer logs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kentaro NAGATOMO <kentaro.nagatomo@tier4.jp>
…t once A transform that TF has not received yet is expected right after startup, and waiting resolves it; a lookup that TF rejects although it is ready, for example for a frame name it does not accept, does not resolve by waiting. Giving both the same grace period delays the report of the latter for nothing. The lookup now reports why it could not provide the transform, as GnssPoser::TransformLookupError: Unavailable when TF is not ready for it yet (a frame, or a transform connecting the frames, has not been received: tf2::LookupException, tf2::ConnectivityException), Failed for any other tf2::TransformException. The node only converts the tf2 exceptions. Result::antenna_transform_missing becomes Result::antenna_transform_error, which says which one to log: Unavailable keeps the grace period, Failed is set at once. Each error is reported once until a fix gets the transform, independently of the other: Failed is the rarer one and says something Unavailable does not, so a reported Unavailable must not hide it. For the fix either error means the same, so both give Outcome::TransformLookupFailed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kentaro NAGATOMO <kentaro.nagatomo@tier4.jp>
…ng it should_report_transform_error() read first_fix_stamp_ with value() without checking it. input_fix() sets the stamp before any lookup, so it is always there, but clang-tidy cannot see that across the two functions and reported bugprone-unchecked-optional-access. Check has_value() first. Without a first fix stamp the grace period does not apply, so the error would be reported; this does not happen in practice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kentaro NAGATOMO <kentaro.nagatomo@tier4.jp>
cb14f60 to
8c8f510
Compare
Description
Purpose
When TF cannot provide the transform from the antenna frame of a fix to
base_frame,autoware_gnss_posercomposes the base_link pose with the identity transform: it publishes the antenna position as the vehicle pose, with the receiver's covariance, as if nothing were missing. That pose is wrong by the lever arm, whether the transform is merely late or never comes. Meanwhile the lookup logs two throttled warnings for every such fix, which also appear on a correctly configured vehicle, since depending on the startup order the first fixes can arrive before/tf_static.This PR stops publishing the wrong pose, and then makes the missing transform visible once rather than every second:
Skipping comes first because it is what makes the report necessary: without the report, the pose would stop silently.
This PR builds on #1537 (merged), which looks the transform up as the latest. With that, a lookup fails only when the transform has not been received, not because of the fix's stamp, so skipping does not cost a setup that publishes the relation on
/tfany fixes.Skipping the fix
The antenna ->
base_linktransform is taken to be static (an antenna that moves relative tobase_linkis out of scope; #1537 looks it up as the latest), and a fix without it is skipped. No buffering of fixes and no timeout is needed under that assumption.Outcome::TransformLookupFailed:gnss_fixedwith the receiver's status (which does not depend on TF) and no pose. Skipped fixes are not replayed.This follows what
autoware_ndt_scan_matcherdoes for the sensor frame of its point cloud: drop the measurement on failure.Reporting the missing transform
The rule:
Grace period from the first fix. Right after startup
/tf_staticmay not have arrived yet, so a missing transform is not reported within 5 s (antenna_transform_grace_period) of the first fix, whatever its status.Once. After that, the first fix that cannot get the transform reports it. It is reported again only after a fix has got the transform in between. The log stays, so repeating it adds nothing.
Measured by the fix header stamps. The grace period follows the data rather than a clock: a rosbag replayed at another rate, or a simulator slower than real time, gives the same result as the vehicle.
input_fix(fix)keeps its signature and the unit tests need no clock.A failed lookup at once. The lookup now says why it could not provide the transform, as
GnssPoser::TransformLookupError:Unavailable: TF is not ready for the lookup yet; it has not received the frames, or not the transforms that connect them (tf2::LookupException,tf2::ConnectivityException). Expected right after startup, so it keeps the grace period.Failed: TF was ready, but the lookup failed (any othertf2::TransformException, e.g. a frame name TF does not accept). Waiting does not help, so it is reported at once.Each error is reported once until a fix gets the transform, independently of the other:
Failedis the rarer one and says somethingUnavailabledoes not, so a reportedUnavailablemust not hide it. For the fix either error means the same,Outcome::TransformLookupFailed.GnssPoserdecides when to report, because it isGnssPoserthat decides to skip the fix: whether a skipped fix is expected is part of the same behavior, and it is unit-tested with stamped fixes alone. The decision is carried in the result of the fix, asResult::antenna_transform_error, set at the one fix where it is to be logged. The node only logs it, as an error naming both frames, with "Fixes are skipped.". The state behind it is the stamp of the first fix and, per error, whether it has been reported since the transform was last obtained.Commits
Each commit builds and passes every test on its own.
refactorResultdefault tostd::nullopt, so the existing returns without a pose name only the outcome andgnss_fixed. No behavior change; the following commits build their results the same way.fixOutcome::TransformLookupFailedand no pose instead of the identity fallback. The lookup keeps its throttled warnings, so the logs are as before. All the node test changes are here.fixResult::antenna_transform_missingat the first fix without the transform more than 5 s after the first fix, again only after the transform was obtained. The rule is one predicate,should_report_transform_missing(), over two members of state; the node logs it, and the lookup no longer logs.featTransformLookupreturnstl::expected<Transform, TransformLookupError>, the node maps the tf2 exceptions toUnavailableorFailed, andResult::antenna_transform_missingbecomesResult::antenna_transform_error, which says which one to log. The predicate becomesshould_report_transform_error(), in whichFailedskips the grace period, and the state becomes one flag per error, so that each is reported once.refactorshould_report_transform_error()checks that the first fix stamp is set before reading it.input_fix()always sets it before the lookup, but clang-tidy (bugprone-unchecked-optional-access) cannot see that across the two functions. No behavior change.Tests
The fixes of the node test keep their default frame,
gnss, for which the fixture publishes no transform. A fix that reaches the lookup in that frame used to get the identity fallback and is now dropped, so the two cases that publish a pose from such a fix,Gate_FirstFixAfterMgrsProjector_PublishesOneOfEachOutputandMethodBuffered_PubMethodParameter_SelectsTheMethod, now publish the identity as the static TFgnss -> base_linkfirst. With it they publish the same poses as before, so what they check is unchanged. It is published only in these two cases rather than by the fixture for every case, since each publication waits for the TF to propagate and the other cases do not need it. No other case gets an unintended lookup failure: the other cases either send no fix, send fixes that stop before the lookup, or name their frame (my_antennawith its TF,my_baseequal tobase_frame, or a frame without a TF on purpose to check the drop).Tf_MissingTransform_PublishesOnlyGnssFixed(unit; a TEST_P over both lookup errors from commit 4): the fix is dropped,gnss_fixedis still reported, and the outcome isTransformLookupFailedTf_MissingTransform_FixStaysInPositionBuffer(unit): the dropped fix still counts for the average once the transform appearsTf_MissingTransform_FixAdvancesMotionHeading(unit): the first published heading is the step from the last dropped fixTf_AntennaFrameComesFromFixHeader_UnknownFrameFallsBackToIdentity(integration, with aNOTE(characterization))..._UnknownFrameDropsTheFix; the note is gone, the defect it described is fixedTf_UnavailableWithinGracePeriod_NotReported(unit, commit 3): fixes at 0 s and at exactly the grace period without the transform report nothingTf_UnavailableBeyondGracePeriod_ReportedOnce(unit, commit 3): the first fix past the grace period reports it, the next one does notTf_UnavailableAfterGracePeriod_ReportedAtOnce(unit, commit 3): the grace period is measured from the first fix of all, so a transform missing only after it is reported at the first such fixTf_UnavailableAgainAfterAvailable_ReportedAgain(unit, commit 3): a fix that gets the transform ends the outage, so the next missing transform is reported againTf_LookupFailed_ReportedAtOnce(unit, commit 4): a failed lookup is reported at the first fix, without the grace periodThe node test does not check logs.
How was this PR tested?
colcon test: 42 unit + 32 node instances pass, plus the ament linters (33 + 32 after commit 1, 36 + 32 after commit 2, 40 + 32 after commit 3; commit 5 adds no test).clang-format21.1.8 andcpplint2.0.2 pass, andclang-tidy18.1.8 reports nothing forgnss_poser.cppandgnss_poser_node.cpp.Notes for reviewers
GnssPoser. Whether it should be longer, or a parameter, is open./tf_staticacross a backward time jump anyway, so a later pass cannot reproduce a late/tf_staticin the first place.GnssPoserstays free of tf2 wording.libexpected-dev(fortl::expected) is a new dependency of the package (already used byautoware_trajectory,autoware_path_generatorandautoware_downsample_filters).BufferCore::lookupTransform(tf2 0.36 / Humble / Rolling).Interface changes
No parameter, topic or QoS change. Observable behavior changes:
gnss_pose,gnss_pose_covormap -> gnss_base_linkTF (it produced a pose equal to the antenna position before).gnss_fixedis unchanged.Effects on system behavior
A vehicle whose TF is configured correctly sees no change, except that fixes arriving before
/tf_static(depending on the startup order) are skipped silently instead of being published at the antenna position with warnings. A vehicle whoseheader.frame_iddoes not match the URDF stops producinggnss_poseinstead of producing one that is wrong by the lever arm, and logs one error saying so.🤖 Generated with Claude Code