Skip to content

feat(ekf2): publish acceleration in VehicleOdometry#26944

Open
evannsmc wants to merge 5 commits intoPX4:mainfrom
evannsmc:pr-vehicle-odometry-v1-final
Open

feat(ekf2): publish acceleration in VehicleOdometry#26944
evannsmc wants to merge 5 commits intoPX4:mainfrom
evannsmc:pr-vehicle-odometry-v1-final

Conversation

@evannsmc
Copy link
Copy Markdown
Contributor

@evannsmc evannsmc commented Apr 1, 2026

Summary

  • extend VehicleOdometry to v1 with NED acceleration
  • read the accumulated velocity derivative once per EKF2 update, reuse it for both vehicle_local_position and vehicle_odometry, then reset once
  • preserve ROS 2 interoperability by archiving VehicleOdometry v0 in px4_msgs_old and adding a translation_node v0<->v1 translator

Why

This follows the prior review direction from #25507 to extend VehicleOdometry instead of introducing a separate VehicleFullState topic. Sharing a single publish-window derivative sample avoids mixed-rate aliasing and double consumption.

Testing

  • make px4_sitl_default -j4
  • colcon build --packages-select px4_msgs
  • colcon build --packages-select px4_msgs_old translation_node
  • colcon test --packages-select translation_node --ctest-args -R translation_node_unit_tests

Notes

  • v0 -> v1 translation fills acceleration with NaN
  • v1 -> v0 translation drops acceleration

@evannsmc evannsmc force-pushed the pr-vehicle-odometry-v1-final branch from 174d8cc to b1fe920 Compare April 1, 2026 18:12
Changes:

    extend VehicleOdometry.msg to v1 with float32[3] acceleration in NED,
    defined as the derivative of NED velocity averaged over the odometry
    publish interval
    read _ekf.getVelocityDerivative() once in EKF2::Run(), pass it to
    PublishLocalPosition() and PublishOdometry(), and reset the
    accumulation once after both publishers consume it
    archive VehicleOdometryV0.msg in px4_msgs_old and add
    VehicleOdometryV1Translation to translation_node
    preserve ROS 2 interoperability between v0 and v1 clients:
    v0 -> v1 fills acceleration with NaN, and v1 -> v0 drops it

This avoids mixed-rate aliasing or double consumption of the velocity derivative and enables one clean message with everything control theorists need for their work.

Tested:

    make px4_sitl_default -j4
    colcon build --packages-select px4_msgs
    colcon build --packages-select px4_msgs_old translation_node
    colcon test --packages-select translation_node --ctest-args -R translation_node_unit_tests

Signed-off-by: evannsmc <evannsmcuadrado@gmail.com>
@evannsmc evannsmc force-pushed the pr-vehicle-odometry-v1-final branch from b1fe920 to 8ffa2c1 Compare April 1, 2026 18:12
@evannsmc evannsmc changed the title ekf2/odometry: add VehicleOdometry acceleration and ROS 2 translation for control pipelines feat(ekf2): publish acceleration in VehicleOdometry Apr 1, 2026
@dakejahl dakejahl requested review from Jaeyoung-Lim and bresch April 1, 2026 20:28
Comment thread msg/translation_node/translations/translation_vehicle_odometry_v1.h
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 120 byte (0.01 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +120  +0.0%    +120    .text
    +0.9%     +32  +0.9%     +32    EKF2::Run()
    +8.5%     +32  +8.5%     +32    ucdr_serialize_vehicle_odometry()
    +6.6%     +28  +6.6%     +28    ucdr_deserialize_vehicle_odometry()
    +6.0%     +20  +6.0%     +20    EKF2::PublishOdometry()
    +2.6%     +16  +2.6%     +16    EKF2::UpdateGpsSample()
    +0.1%      +8  +0.1%      +8    EKF2::EKF2()
    +4.5%      +8  +4.5%      +8    EKF2::PublishBaroBias()
    +0.8%      +8  +0.8%      +8    EKF2::PublishStatusFlags()
   -99.7%      +8 -99.7%      +8    [4 Others]
    +0.0%      +8  +0.0%      +8    uORB::compressed_fields
    +0.1%      +4  +0.1%      +4    EKF2::PublishAidSourceStatus()
    +0.9%      +4  +0.9%      +4    EKF2::PublishFusionControl()
    +0.6%      +4  +0.6%      +4    EKF2::PublishStatus()
    -1.2%      -4  -1.2%      -4    EKF2::PublishInnovationTestRatios()
    -1.2%      -4  -1.2%      -4    EKF2::PublishInnovationVariances()
    -1.2%      -4  -1.2%      -4    EKF2::PublishInnovations()
    -0.3%      -4  -0.3%      -4    EKF2::PublishLocalPosition()
    -1.6%      -8  -1.6%      -8    EKF2::PublishEventFlags()
    -2.9%      -8  -2.9%      -8    EKF2::PublishGpsStatus()
    -1.3%      -8  -1.3%      -8    EKF2Selector::PublishVehicleGlobalPosition()
    -3.4%     -20  -3.4%     -20    EKF2::UpdateRangeSample()
  +0.0%     +55  [ = ]       0    .debug_abbrev
  +0.0%      +8  [ = ]       0    .debug_frame
  +0.0%    +619  [ = ]       0    .debug_info
  +0.0%    +534  [ = ]       0    .debug_line
     +40%      +2  [ = ]       0    [Unmapped]
    +0.0%    +532  [ = ]       0    [section .debug_line]
  +0.0%    +635  [ = ]       0    .debug_loclists
  +0.0%    +148  [ = ]       0    .debug_rnglists
    [DEL]      -3  [ = ]       0    [Unmapped]
    +0.0%    +151  [ = ]       0    [section .debug_rnglists]
  +0.0%      +1  [ = ]       0    .debug_str
  -1.2%    -120  [ = ]       0    [Unmapped]
  +0.0% +1.95Ki  +0.0%    +120    TOTAL

px4_fmu-v6x [Total VM Diff: 120 byte (0.01 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%    +120  +0.0%    +120    .text
    +0.9%     +32  +0.9%     +32    EKF2::Run()
    +8.5%     +32  +8.5%     +32    ucdr_serialize_vehicle_odometry()
    +6.6%     +28  +6.6%     +28    ucdr_deserialize_vehicle_odometry()
    +6.0%     +20  +6.0%     +20    EKF2::PublishOdometry()
    +2.6%     +16  +2.6%     +16    EKF2::UpdateGpsSample()
    +0.1%      +8  +0.1%      +8    EKF2::EKF2()
    +4.5%      +8  +4.5%      +8    EKF2::PublishBaroBias()
    +0.8%      +8  +0.8%      +8    EKF2::PublishStatusFlags()
   -99.7%      +8 -99.7%      +8    [4 Others]
    +0.0%      +8  +0.0%      +8    uORB::compressed_fields
    +0.1%      +4  +0.1%      +4    EKF2::PublishAidSourceStatus()
    +0.9%      +4  +0.9%      +4    EKF2::PublishFusionControl()
    +0.6%      +4  +0.6%      +4    EKF2::PublishStatus()
    -1.2%      -4  -1.2%      -4    EKF2::PublishInnovationTestRatios()
    -1.2%      -4  -1.2%      -4    EKF2::PublishInnovationVariances()
    -1.2%      -4  -1.2%      -4    EKF2::PublishInnovations()
    -0.3%      -4  -0.3%      -4    EKF2::PublishLocalPosition()
    -1.6%      -8  -1.6%      -8    EKF2::PublishEventFlags()
    -2.9%      -8  -2.9%      -8    EKF2::PublishGpsStatus()
    -1.3%      -8  -1.3%      -8    EKF2Selector::PublishVehicleGlobalPosition()
    -3.4%     -20  -3.4%     -20    EKF2::UpdateRangeSample()
  +0.0%     +55  [ = ]       0    .debug_abbrev
  +0.0%      +8  [ = ]       0    .debug_frame
  +0.0%    +619  [ = ]       0    .debug_info
  +0.0%    +526  [ = ]       0    .debug_line
   -85.7%      -6  [ = ]       0    [Unmapped]
    +0.0%    +532  [ = ]       0    [section .debug_line]
  +0.0%    +641  [ = ]       0    .debug_loclists
  +0.0%    +150  [ = ]       0    .debug_rnglists
   -33.3%      -1  [ = ]       0    [Unmapped]
    +0.0%    +151  [ = ]       0    [section .debug_rnglists]
  +0.0%      +1  [ = ]       0    .debug_str
  -1.9%    -120  [ = ]       0    [Unmapped]
  +0.0% +1.95Ki  +0.0%    +120    TOTAL

Updated: 2026-04-10T19:38:55

evannsmc added 3 commits April 9, 2026 17:24
The translation_node is a standalone ROS 2 package that depends on
px4_msgs_old headers generated only in a colcon ROS build — they are
not available in the px4_sitl_default-clang environment used by
clang-tidy CI.  All translation headers share this dependency; the
new file triggers the error only because it is the sole diff entry.

Add msg/translation_node to the exclude lists in three places so that
no translation-node file is analysed in the SITL context:

  • CLANG_TIDY_EXCLUDE_EXTRA in Makefile (make clang-tidy)
  • EXCLUDE_EXTRA in Tools/ci/run-clang-tidy-pr.py (PR incremental run)
  • git diff pathspec in clang-tidy.yml (clang-tidy-diff-18 pr-review step)

The translation_node already has dedicated CI coverage via
ros_translation_node.yml (builds and tests under ROS 2 humble + jazzy).
…lishLocalPosition

The previous commit added vel_deriv as a function parameter, changing the
mangled C++ names and breaking ITCM linker-script entries on v6xrt, nxp_mr-tropic,
and nxp_tropic-community (itcm_check CI failures).

Use a member variable _vel_deriv instead:
  - compute once in Run() via _ekf.getVelocityDerivative()
  - read in PublishLocalPosition() and PublishOdometry() via _vel_deriv

Original function signatures are preserved:
  PublishLocalPosition(const hrt_abstime &)
  PublishOdometry(const hrt_abstime &, const imuSample &)

The single-sample-per-update sharing of the velocity derivative (to avoid
mixed-rate aliasing between vehicle_local_position and vehicle_odometry)
is maintained.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants