Skip to content
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

WIP: Fixed wing control refactoring #24056

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

WIP: Fixed wing control refactoring #24056

wants to merge 22 commits into from

Conversation

RomanBapst
Copy link
Contributor

@RomanBapst RomanBapst commented Nov 29, 2024

Solved Problem

Implement fixed wing control API for lateral and longitudinal control.

fw_control_arch drawio

Changelog Entry

For release notes:

Feature/Bugfix XYZ
New parameter: XYZ_Z
Documentation: Need to clarify page ... / done, read docs.px4.io/...

TODO
Test in simulation all modes

  • Stabilized

  • Altitude

  • Position

  • Hold

  • Mission

  • RTL

  • Orbit

  • Finalize handling of control limits

  • Verify that fixed wing auto-takeoff and auto-landing still work as intended

  • Solve Flash

Alternatives

We could also ...

Test coverage

Context

Related links, screenshot before/after, video

Copy link

github-actions bot commented Dec 20, 2024

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 6972 byte (0.33 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.3% +6.73Ki  +0.3% +6.73Ki    .text
  [NEW] +8.71Ki  [NEW] +8.71Ki    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
  [NEW] +1.57Ki  [NEW] +1.57Ki    ../../src/lib/npfg/DirectionalGuidance.cpp
  +4.6% +1.47Ki  +4.6% +1.47Ki    ../../src/modules/uxrce_dds_client/uxrce_dds_client.cpp
  +0.4% +1.13Ki  +0.4% +1.13Ki    [section .text]
  [NEW]    +468  [NEW]    +468    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW]    +140  [NEW]    +140    ../../src/lib/npfg/AirspeedReferenceController.cpp
  +2.0%    +104  +2.0%    +104    ../../src/modules/logger/logged_topics.cpp
  [NEW]     +32  [NEW]     +32    msg/topics_sources/fw_lateral_control_setpoint.cpp
  [NEW]     +32  [NEW]     +32    msg/topics_sources/fw_longitudinal_control_setpoint.cpp
  [NEW]     +32  [NEW]     +32    msg/topics_sources/longitudinal_control_limits.cpp
  +2.0%     +24  +2.0%     +24    msg/topics_sources/uORBTopics.cpp
  +0.0%     +22  +0.0%     +22    ROMFS/nsh_romfsimg.c
  +0.4%     +16  +0.4%     +16    ../../src/modules/gimbal/input_mavlink.cpp
  +0.7%     +16  +0.7%     +16    builtin_list.c
  [NEW]     +16  [NEW]     +16    msg/topics_sources/lateral_control_limits.cpp
   +75%     +12   +75%     +12    msg/topics_sources/navigator_mission_item.cpp
 -99.9%      +8 -99.9%      +8    [4 Others]
 -27.3%     -12 -27.3%     -12    msg/topics_sources/normalized_unsigned_setpoint.cpp
 -50.0%     -16 -50.0%     -16    msg/topics_sources/logger_status.cpp
  [DEL] -2.61Ki  [DEL] -2.61Ki    ../../src/lib/npfg/npfg.cpp
 -15.9% -4.42Ki -15.9% -4.42Ki    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
[ = ]       0  +0.1%     +64    .bss
  [ = ]       0  +7.1%     +56    [section .bss]
  [ = ]       0  [NEW]      +8    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
+0.2%      +8  +0.2%      +8    .data
  [NEW]      +4  [NEW]      +4    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
  +100%      +4  +100%      +4    ../../src/modules/manual_control/ManualControl.cpp
+1.0%      +4  +1.0%      +4    .init_section
+0.5% +10.6Ki  [ = ]       0    .debug_abbrev
  [NEW] +1.48Ki  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW] +1.85Ki  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW] +2.05Ki  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL] -2.18Ki  [ = ]       0    ../../src/lib/npfg/npfg.cpp
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
  [NEW] +4.08Ki  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
  -4.2%    -190  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  -0.6%     -15  [ = ]       0    ../../src/modules/fw_pos_control/runway_takeoff/RunwayTakeoff.cpp
  [NEW]    +900  [ = ]       0    msg/topics_sources/fw_lateral_control_setpoint.cpp
  [NEW]    +900  [ = ]       0    msg/topics_sources/fw_longitudinal_control_setpoint.cpp
  [NEW]    +900  [ = ]       0    msg/topics_sources/lateral_control_limits.cpp
  [NEW]    +900  [ = ]       0    msg/topics_sources/longitudinal_control_limits.cpp
+0.4%    +688  [ = ]       0    .debug_aranges
  [NEW]     +40  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW]     +96  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW]    +184  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL]    -272  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  -5.0%      -8  [ = ]       0    ../../src/lib/version/version.c
  [NEW]    +560  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
  -5.6%     -72  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  +5.3%     +32  [ = ]       0    ../../src/modules/uxrce_dds_client/uxrce_dds_client.cpp
  [NEW]     +32  [ = ]       0    msg/topics_sources/fw_lateral_control_setpoint.cpp
  [NEW]     +32  [ = ]       0    msg/topics_sources/fw_longitudinal_control_setpoint.cpp
  [NEW]     +32  [ = ]       0    msg/topics_sources/lateral_control_limits.cpp
  [NEW]     +32  [ = ]       0    msg/topics_sources/longitudinal_control_limits.cpp
+0.4% +1.74Ki  [ = ]       0    .debug_frame
+0.7%  +193Ki  [ = ]       0    .debug_info
  +0.4%     +42  [ = ]       0    ../../platforms/common/uORB/Subscription.cpp
  +0.3%     +42  [ = ]       0    ../../platforms/common/uORB/SubscriptionInterval.cpp
  +0.1%     +42  [ = ]       0    ../../platforms/common/uORB/uORB.cpp
  +0.2%     +42  [ = ]       0    ../../platforms/common/uORB/uORBDeviceMaster.cpp
  +0.2%     +42  [ = ]       0    ../../platforms/common/uORB/uORBDeviceNode.cpp
  +0.2%     +42  [ = ]       0    ../../platforms/common/uORB/uORBManager.cpp
  +0.2%     +42  [ = ]       0    ../../platforms/nuttx/src/px4/common/gpio/mcp23009/mcp23009.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/adc/ads1115/ads1115_main.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/adc/board_adc/ADC.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/barometer/bmp388/bmp388.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/barometer/ms5611/ms5611.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/camera_capture/camera_capture.cpp
  +0.1%     +42  [ = ]       0    ../../src/drivers/camera_trigger/camera_trigger.cpp
  +0.1%     +42  [ = ]       0    ../../src/drivers/cdcacm_autostart/cdcacm_autostart.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/differential_pressure/ms4525do/MS4525DO.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/differential_pressure/ms5525dso/MS5525DSO.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/differential_pressure/sdp3x/SDP3X.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/distance_sensor/cm8jl65/CM8JL65.cpp
  +0.1%     +42  [ = ]       0    ../../src/drivers/distance_sensor/lightware_laser_i2c/lightware_laser_i2c.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/distance_sensor/lightware_laser_serial/lightware_laser_serial.cpp
 -98.9%  +192Ki  [ = ]       0    [482 Others]
+0.4% +19.7Ki  [ = ]       0    .debug_line
  [NEW] +1.30Ki  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW] +2.23Ki  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW] +3.84Ki  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL] -5.75Ki  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  [NEW] +20.7Ki  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
 -19.3% -10.4Ki  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  -0.2%      -6  [ = ]       0    ../../src/modules/fw_pos_control/runway_takeoff/RunwayTakeoff.cpp
  +0.6%     +37  [ = ]       0    ../../src/modules/logger/logged_topics.cpp
  +4.9% +2.49Ki  [ = ]       0    ../../src/modules/uxrce_dds_client/uxrce_dds_client.cpp
  [NEW] +1.31Ki  [ = ]       0    msg/topics_sources/fw_lateral_control_setpoint.cpp
  [NEW] +1.32Ki  [ = ]       0    msg/topics_sources/fw_longitudinal_control_setpoint.cpp
  [NEW] +1.30Ki  [ = ]       0    msg/topics_sources/lateral_control_limits.cpp
  [NEW] +1.31Ki  [ = ]       0    msg/topics_sources/longitudinal_control_limits.cpp
  +2.3%    +132  [ = ]       0    msg/topics_sources/uORBTopics.cpp
  +0.4%      +4  [ = ]       0    task/task_cancelpt.c
+0.3% +15.9Ki  [ = ]       0    .debug_loc
  +0.5%     +15  [ = ]       0    ../../src/drivers/camera_capture/camera_capture.cpp
  +0.2%     +15  [ = ]       0    ../../src/drivers/camera_trigger/camera_trigger.cpp
  +0.2%     +15  [ = ]       0    ../../src/drivers/osd/msp_osd/msp_osd.cpp
  -0.1%     -15  [ = ]       0    ../../src/drivers/px4io/px4io.cpp
  +0.2%     +15  [ = ]       0    ../../src/drivers/rc/crsf_rc/CrsfRc.cpp
  +0.4%     +15  [ = ]       0    ../../src/drivers/telemetry/frsky_telemetry/frsky_data.cpp
  -0.4%     -15  [ = ]       0    ../../src/drivers/telemetry/frsky_telemetry/sPort_data.cpp
  -0.0%     -30  [ = ]       0    ../../src/drivers/uavcan/uavcan_main.cpp
  +0.0%      +2  [ = ]       0    ../../src/drivers/uavcan/uavcan_servers.cpp
  -0.3%     -15  [ = ]       0    ../../src/lib/adsb/AdsbConflict.cpp
  -0.1%     -15  [ = ]       0    ../../src/lib/battery/battery.cpp
  +1.7%    +413  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  +0.1%     +15  [ = ]       0    ../../src/lib/mixer_module/mixer_module.cpp
  [NEW] +1.25Ki  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW] +4.87Ki  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW] +9.07Ki  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL] -14.9Ki  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  +6.0%    +398  [ = ]       0    ../../src/lib/rtl/rtl_time_estimator.cpp
  -0.2%     -13  [ = ]       0    ../../src/lib/weather_vane/WeatherVane.cpp
  -0.0%     -15  [ = ]       0    ../../src/modules/commander/Commander.cpp
 -99.3% +14.9Ki  [ = ]       0    [48 Others]
+0.3% +3.29Ki  [ = ]       0    .debug_ranges
  +0.5%     +24  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW]    +176  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW]    +728  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW] +1.34Ki  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL] -2.10Ki  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  +1.6%     +24  [ = ]       0    ../../src/lib/rtl/rtl_time_estimator.cpp
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  +3.8%     +24  [ = ]       0    ../../src/modules/commander/HealthAndArmingChecks/checks/windCheck.cpp
  +0.3%     +24  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/Auto/FlightTaskAuto.cpp
  +0.4%     +24  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/AutoFollowTarget/FlightTaskAutoFollowTarget.cpp
  +1.1%     +24  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/ManualAltitude/FlightTaskManualAltitude.cpp
  +0.9%     +24  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/ManualPosition/FlightTaskManualPosition.cpp
  +0.4%     +24  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/Orbit/FlightTaskOrbit.cpp
  +0.6%     +24  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/Utility/StickAccelerationXY.cpp
  [NEW] +8.80Ki  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
 -28.4% -6.62Ki  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  -0.6%      -8  [ = ]       0    ../../src/modules/logger/logged_topics.cpp
  +0.8%     +24  [ = ]       0    ../../src/modules/mc_pos_control/PositionControl/ControlMath.cpp
  +1.2%     +24  [ = ]       0    ../../src/modules/navigator/mission_block.cpp
  +1.0%     +24  [ = ]       0    ../../src/modules/navigator/precland.cpp
 -98.7%    +750  [ = ]       0    [7 Others]
+0.3% +8.85Ki  [ = ]       0    .debug_str
  +0.7%    +402  [ = ]       0    
  +1.0%    +169  [ = ]       0    ../../src/drivers/adc/ads1115/ads1115_main.cpp
  -4.4%     -11  [ = ]       0    ../../src/lib/airspeed/airspeed.cpp
  -1.8%     -36  [ = ]       0    ../../src/lib/battery/battery.cpp
  -0.1%      -1  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocation.cpp
   +13%     +78  [ = ]       0    ../../src/lib/geo/geo.cpp
  [NEW]     +98  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW]     +73  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW]    +463  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL]    -561  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  -1.9%     -60  [ = ]       0    ../../src/modules/ekf2/EKF/yaw_estimator/EKFGSF_yaw.cpp
 -22.3%    -239  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/Transition/FlightTaskTransition.cpp
  [NEW] +50.8Ki  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
 -38.0% -42.9Ki  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
 -15.4%     -44  [ = ]       0    ../../src/modules/fw_pos_control/runway_takeoff/RunwayTakeoff.cpp
  -7.8%     -33  [ = ]       0    ../../src/modules/landing_target_estimator/LandingTargetEstimator.cpp
  -0.0%     -11  [ = ]       0    ../../src/modules/logger/logger.cpp
  -0.1%      -7  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
   +19%      +7  [ = ]       0    ../../src/modules/mc_pos_control/Takeoff/Takeoff.cpp
  +1.8%    +360  [ = ]       0    ../../src/modules/uxrce_dds_client/uxrce_dds_client.cpp
 -99.9%    +342  [ = ]       0    [9 Others]
+0.5% +3.24Ki  [ = ]       0    .strtab
  [NEW]    +128  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW]    +386  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW]    +670  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL]    -762  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  -1.9%     -35  [ = ]       0    ../../src/lib/tecs/TECS.cpp
  -8.1%     -32  [ = ]       0    ../../src/lib/version/version.c
  [NEW] +2.85Ki  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
  -9.5%    -789  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  -0.2%      -1  [ = ]       0    ../../src/modules/fw_pos_control/runway_takeoff/RunwayTakeoff.cpp
  +1.6%     +40  [ = ]       0    ../../src/modules/gimbal/input_mavlink.cpp
  +5.1%    +175  [ = ]       0    ../../src/modules/uxrce_dds_client/uxrce_dds_client.cpp
  +0.5%    +413  [ = ]       0    [section .strtab]
  [NEW]     +66  [ = ]       0    msg/topics_sources/fw_lateral_control_setpoint.cpp
  [NEW]     +76  [ = ]       0    msg/topics_sources/fw_longitudinal_control_setpoint.cpp
  [NEW]     +29  [ = ]       0    msg/topics_sources/lateral_control_limits.cpp
  [NEW]     +34  [ = ]       0    msg/topics_sources/longitudinal_control_limits.cpp
+0.4% +2.16Ki  [ = ]       0    .symtab
 -16.7%     -16  [ = ]       0    ../../platforms/nuttx/src/px4/common/board_fat_dma_alloc.c
  -1.9%     -16  [ = ]       0    ../../src/drivers/barometer/bmp388/bmp388_spi.cpp
  -2.1%     -16  [ = ]       0    ../../src/drivers/gps/devices/src/nmea.cpp
  +0.7%     +16  [ = ]       0    ../../src/drivers/gps/gps.cpp
  -1.5%     -16  [ = ]       0    ../../src/drivers/imu/invensense/icm20948/ICM20948_I2C_Passthrough.cpp
  -1.3%     -16  [ = ]       0    ../../src/drivers/power_monitor/ina228/ina228.cpp
  -0.4%     -16  [ = ]       0    ../../src/drivers/uavcan/sensors/sensor_bridge.cpp
  +0.1%     +16  [ = ]       0    ../../src/drivers/uavcan/uavcan_main.cpp
  -0.4%     -16  [ = ]       0    ../../src/drivers/uavcan/uavcan_servers.cpp
  [NEW]    +128  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW]    +208  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW]    +560  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL]    -832  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  -2.8%     -32  [ = ]       0    ../../src/lib/tecs/TECS.cpp
  -7.0%     -64  [ = ]       0    ../../src/lib/version/version.c
  +1.9%     +16  [ = ]       0    ../../src/modules/commander/HealthAndArmingChecks/HealthAndArmingChecks.cpp
  +3.6%     +16  [ = ]       0    ../../src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTilts.cpp
  [NEW] +2.34Ki  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
 -11.4%    -688  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  -2.9%     -16  [ = ]       0    ../../src/modules/fw_pos_control/runway_takeoff/RunwayTakeoff.cpp
 -99.4%    +592  [ = ]       0    [10 Others]
-37.0% -6.74Ki  [ = ]       0    [Unmapped]
+0.5%  +259Ki  +0.3% +6.81Ki    TOTAL

px4_fmu-v6x [Total VM Diff: 6972 byte (0.34 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.4% +6.74Ki  +0.4% +6.74Ki    .text
  [NEW] +8.71Ki  [NEW] +8.71Ki    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
  [NEW] +1.57Ki  [NEW] +1.57Ki    ../../src/lib/npfg/DirectionalGuidance.cpp
  +4.6% +1.47Ki  +4.6% +1.47Ki    ../../src/modules/uxrce_dds_client/uxrce_dds_client.cpp
  +0.5% +1.14Ki  +0.5% +1.14Ki    [section .text]
  [NEW]    +468  [NEW]    +468    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW]    +140  [NEW]    +140    ../../src/lib/npfg/AirspeedReferenceController.cpp
  +2.0%    +104  +2.0%    +104    ../../src/modules/logger/logged_topics.cpp
  [NEW]     +32  [NEW]     +32    msg/topics_sources/fw_lateral_control_setpoint.cpp
  [NEW]     +32  [NEW]     +32    msg/topics_sources/fw_longitudinal_control_setpoint.cpp
  [NEW]     +32  [NEW]     +32    msg/topics_sources/longitudinal_control_limits.cpp
  +2.0%     +24  +2.0%     +24    msg/topics_sources/uORBTopics.cpp
  +0.0%     +22  +0.0%     +22    ROMFS/nsh_romfsimg.c
  +0.4%     +16  +0.4%     +16    ../../src/modules/gimbal/input_mavlink.cpp
  +0.8%     +16  +0.8%     +16    builtin_list.c
  [NEW]     +16  [NEW]     +16    msg/topics_sources/lateral_control_limits.cpp
   +75%     +12   +75%     +12    msg/topics_sources/navigator_mission_item.cpp
 -99.9%      +8 -99.9%      +8    [4 Others]
 -27.3%     -12 -27.3%     -12    msg/topics_sources/normalized_unsigned_setpoint.cpp
 -50.0%     -16 -50.0%     -16    msg/topics_sources/logger_status.cpp
  [DEL] -2.61Ki  [DEL] -2.61Ki    ../../src/lib/npfg/npfg.cpp
 -15.9% -4.42Ki -15.9% -4.42Ki    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
[ = ]       0  +0.1%     +64    .bss
  [ = ]       0  +6.3%     +56    [section .bss]
  [ = ]       0  [NEW]      +8    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
+1.1%      +4  +1.1%      +4    .init_section
+0.6% +10.6Ki  [ = ]       0    .debug_abbrev
  [NEW] +1.48Ki  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW] +1.85Ki  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW] +2.05Ki  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL] -2.18Ki  [ = ]       0    ../../src/lib/npfg/npfg.cpp
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
  [NEW] +4.08Ki  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
  -4.2%    -190  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  -0.6%     -15  [ = ]       0    ../../src/modules/fw_pos_control/runway_takeoff/RunwayTakeoff.cpp
  [NEW]    +900  [ = ]       0    msg/topics_sources/fw_lateral_control_setpoint.cpp
  [NEW]    +900  [ = ]       0    msg/topics_sources/fw_longitudinal_control_setpoint.cpp
  [NEW]    +900  [ = ]       0    msg/topics_sources/lateral_control_limits.cpp
  [NEW]    +900  [ = ]       0    msg/topics_sources/longitudinal_control_limits.cpp
+0.4%    +688  [ = ]       0    .debug_aranges
  [NEW]     +40  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW]     +96  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW]    +184  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL]    -272  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  -5.0%      -8  [ = ]       0    ../../src/lib/version/version.c
  [NEW]    +560  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
  -5.6%     -72  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  +5.3%     +32  [ = ]       0    ../../src/modules/uxrce_dds_client/uxrce_dds_client.cpp
  [NEW]     +32  [ = ]       0    msg/topics_sources/fw_lateral_control_setpoint.cpp
  [NEW]     +32  [ = ]       0    msg/topics_sources/fw_longitudinal_control_setpoint.cpp
  [NEW]     +32  [ = ]       0    msg/topics_sources/lateral_control_limits.cpp
  [NEW]     +32  [ = ]       0    msg/topics_sources/longitudinal_control_limits.cpp
+0.4% +1.74Ki  [ = ]       0    .debug_frame
+0.7%  +192Ki  [ = ]       0    .debug_info
  +0.4%     +42  [ = ]       0    ../../platforms/common/uORB/Subscription.cpp
  +0.3%     +42  [ = ]       0    ../../platforms/common/uORB/SubscriptionInterval.cpp
  +0.1%     +42  [ = ]       0    ../../platforms/common/uORB/uORB.cpp
  +0.2%     +42  [ = ]       0    ../../platforms/common/uORB/uORBDeviceMaster.cpp
  +0.2%     +42  [ = ]       0    ../../platforms/common/uORB/uORBDeviceNode.cpp
  +0.2%     +42  [ = ]       0    ../../platforms/common/uORB/uORBManager.cpp
  +0.2%     +42  [ = ]       0    ../../platforms/nuttx/src/px4/common/gpio/mcp23009/mcp23009.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/adc/ads1115/ads1115_main.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/adc/board_adc/ADC.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/barometer/bmp388/bmp388.cpp
  +0.1%     +42  [ = ]       0    ../../src/drivers/barometer/invensense/icp201xx/ICP201XX.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/barometer/ms5611/ms5611.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/camera_capture/camera_capture.cpp
  +0.1%     +42  [ = ]       0    ../../src/drivers/camera_trigger/camera_trigger.cpp
  +0.1%     +42  [ = ]       0    ../../src/drivers/cdcacm_autostart/cdcacm_autostart.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/differential_pressure/ms4525do/MS4525DO.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/differential_pressure/ms5525dso/MS5525DSO.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/differential_pressure/sdp3x/SDP3X.cpp
  +0.2%     +42  [ = ]       0    ../../src/drivers/distance_sensor/cm8jl65/CM8JL65.cpp
  +0.1%     +42  [ = ]       0    ../../src/drivers/distance_sensor/lightware_laser_i2c/lightware_laser_i2c.cpp
 -98.9%  +191Ki  [ = ]       0    [466 Others]
+0.4% +19.7Ki  [ = ]       0    .debug_line
  [NEW] +1.30Ki  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW] +2.23Ki  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW] +3.84Ki  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL] -5.75Ki  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  [NEW] +20.7Ki  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
 -19.3% -10.4Ki  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  -0.2%      -6  [ = ]       0    ../../src/modules/fw_pos_control/runway_takeoff/RunwayTakeoff.cpp
  +0.6%     +37  [ = ]       0    ../../src/modules/logger/logged_topics.cpp
  +4.9% +2.49Ki  [ = ]       0    ../../src/modules/uxrce_dds_client/uxrce_dds_client.cpp
  [NEW] +1.31Ki  [ = ]       0    msg/topics_sources/fw_lateral_control_setpoint.cpp
  [NEW] +1.32Ki  [ = ]       0    msg/topics_sources/fw_longitudinal_control_setpoint.cpp
  [NEW] +1.30Ki  [ = ]       0    msg/topics_sources/lateral_control_limits.cpp
  [NEW] +1.31Ki  [ = ]       0    msg/topics_sources/longitudinal_control_limits.cpp
  +2.3%    +132  [ = ]       0    msg/topics_sources/uORBTopics.cpp
  -0.2%      -2  [ = ]       0    task/task_cancelpt.c
+0.3% +15.8Ki  [ = ]       0    .debug_loc
  +0.4%     +15  [ = ]       0    ../../src/drivers/adc/board_adc/ADC.cpp
  -0.5%     -15  [ = ]       0    ../../src/drivers/camera_capture/camera_capture.cpp
  +0.2%     +15  [ = ]       0    ../../src/drivers/distance_sensor/lightware_laser_i2c/lightware_laser_i2c.cpp
  +0.2%     +15  [ = ]       0    ../../src/drivers/osd/msp_osd/msp_osd.cpp
  -0.1%     -15  [ = ]       0    ../../src/drivers/px4io/px4io.cpp
  +0.3%     +13  [ = ]       0    ../../src/drivers/rc_input/crsf_telemetry.cpp
  +1.2%     +13  [ = ]       0    ../../src/drivers/rc_input/ghst_telemetry.cpp
  -0.0%     -29  [ = ]       0    ../../src/drivers/uavcan/uavcan_main.cpp
  +0.0%     +15  [ = ]       0    ../../src/drivers/uavcan/uavcan_servers.cpp
  +0.3%     +15  [ = ]       0    ../../src/lib/adsb/AdsbConflict.cpp
  -0.1%     -15  [ = ]       0    ../../src/lib/battery/battery.cpp
  +1.7%    +413  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  -0.1%     -16  [ = ]       0    ../../src/lib/mixer_module/mixer_module.cpp
  [NEW] +1.25Ki  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW] +4.87Ki  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW] +9.07Ki  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL] -14.9Ki  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  +6.0%    +398  [ = ]       0    ../../src/lib/rtl/rtl_time_estimator.cpp
  -0.2%     -13  [ = ]       0    ../../src/lib/weather_vane/WeatherVane.cpp
  -0.0%     -15  [ = ]       0    ../../src/modules/commander/Commander.cpp
 -99.2% +14.8Ki  [ = ]       0    [40 Others]
+0.3% +3.30Ki  [ = ]       0    .debug_ranges
  +0.5%     +24  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW]    +176  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW]    +728  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW] +1.34Ki  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL] -2.10Ki  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  +1.6%     +24  [ = ]       0    ../../src/lib/rtl/rtl_time_estimator.cpp
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  +3.8%     +24  [ = ]       0    ../../src/modules/commander/HealthAndArmingChecks/checks/windCheck.cpp
  +0.3%     +24  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/Auto/FlightTaskAuto.cpp
  +0.4%     +24  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/AutoFollowTarget/FlightTaskAutoFollowTarget.cpp
  +1.1%     +24  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/ManualAltitude/FlightTaskManualAltitude.cpp
  +0.9%     +24  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/ManualPosition/FlightTaskManualPosition.cpp
  +0.4%     +24  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/Orbit/FlightTaskOrbit.cpp
  +0.6%     +24  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/Utility/StickAccelerationXY.cpp
  [NEW] +8.80Ki  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
 -28.4% -6.62Ki  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  -0.6%      -8  [ = ]       0    ../../src/modules/logger/logged_topics.cpp
  +0.8%     +24  [ = ]       0    ../../src/modules/mc_pos_control/PositionControl/ControlMath.cpp
  +1.2%     +24  [ = ]       0    ../../src/modules/navigator/mission_block.cpp
  +1.0%     +24  [ = ]       0    ../../src/modules/navigator/precland.cpp
 -98.7%    +751  [ = ]       0    [7 Others]
+0.3% +9.52Ki  [ = ]       0    .debug_str
  +0.7%    +402  [ = ]       0    
  +1.0%    +169  [ = ]       0    ../../src/drivers/adc/ads1115/ads1115_main.cpp
  -4.4%     -11  [ = ]       0    ../../src/lib/airspeed/airspeed.cpp
  -1.8%     -36  [ = ]       0    ../../src/lib/battery/battery.cpp
  -0.1%      -1  [ = ]       0    ../../src/lib/control_allocation/control_allocation/ControlAllocation.cpp
   +13%     +78  [ = ]       0    ../../src/lib/geo/geo.cpp
  [NEW]     +98  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW]     +73  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW]    +463  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL]    -561  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  -1.9%     -60  [ = ]       0    ../../src/modules/ekf2/EKF/yaw_estimator/EKFGSF_yaw.cpp
 -22.3%    -239  [ = ]       0    ../../src/modules/flight_mode_manager/tasks/Transition/FlightTaskTransition.cpp
  [NEW] +51.4Ki  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
 -38.0% -42.9Ki  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
 -15.4%     -44  [ = ]       0    ../../src/modules/fw_pos_control/runway_takeoff/RunwayTakeoff.cpp
  -7.8%     -33  [ = ]       0    ../../src/modules/landing_target_estimator/LandingTargetEstimator.cpp
  -0.0%     -11  [ = ]       0    ../../src/modules/logger/logger.cpp
  -0.1%      -7  [ = ]       0    ../../src/modules/mc_att_control/mc_att_control_main.cpp
   +19%      +7  [ = ]       0    ../../src/modules/mc_pos_control/Takeoff/Takeoff.cpp
  +1.7%    +360  [ = ]       0    ../../src/modules/uxrce_dds_client/uxrce_dds_client.cpp
 -99.9%    +342  [ = ]       0    [9 Others]
+0.5% +3.24Ki  [ = ]       0    .strtab
  [NEW]    +128  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW]    +386  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW]    +670  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL]    -762  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  -1.9%     -35  [ = ]       0    ../../src/lib/tecs/TECS.cpp
  -8.1%     -32  [ = ]       0    ../../src/lib/version/version.c
  [NEW] +2.85Ki  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
  -9.5%    -789  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  -0.2%      -1  [ = ]       0    ../../src/modules/fw_pos_control/runway_takeoff/RunwayTakeoff.cpp
  +1.6%     +40  [ = ]       0    ../../src/modules/gimbal/input_mavlink.cpp
  +5.1%    +175  [ = ]       0    ../../src/modules/uxrce_dds_client/uxrce_dds_client.cpp
  +0.5%    +413  [ = ]       0    [section .strtab]
  [NEW]     +66  [ = ]       0    msg/topics_sources/fw_lateral_control_setpoint.cpp
  [NEW]     +76  [ = ]       0    msg/topics_sources/fw_longitudinal_control_setpoint.cpp
  [NEW]     +29  [ = ]       0    msg/topics_sources/lateral_control_limits.cpp
  [NEW]     +34  [ = ]       0    msg/topics_sources/longitudinal_control_limits.cpp
+0.4% +2.16Ki  [ = ]       0    .symtab
  -1.9%     -16  [ = ]       0    ../../src/drivers/barometer/bmp388/bmp388_spi.cpp
  -8.3%     -16  [ = ]       0    ../../src/drivers/barometer/invensense/icp201xx/icp201xx_main.cpp
  -2.1%     -16  [ = ]       0    ../../src/drivers/gps/devices/src/nmea.cpp
  +0.7%     +16  [ = ]       0    ../../src/drivers/gps/gps.cpp
  -1.3%     -16  [ = ]       0    ../../src/drivers/uavcan/sensors/baro.cpp
  +0.1%     +16  [ = ]       0    ../../src/drivers/uavcan/uavcan_main.cpp
  -0.4%     -16  [ = ]       0    ../../src/drivers/uavcan/uavcan_servers.cpp
  +2.7%     +16  [ = ]       0    ../../src/lib/motion_planning/PositionSmoothing.cpp
  [NEW]    +128  [ = ]       0    ../../src/lib/npfg/AirspeedReferenceController.cpp
  [NEW]    +208  [ = ]       0    ../../src/lib/npfg/CourseToAirspeedRefMapper.cpp
  [NEW]    +560  [ = ]       0    ../../src/lib/npfg/DirectionalGuidance.cpp
  [DEL]    -832  [ = ]       0    ../../src/lib/npfg/npfg.cpp
  -2.8%     -32  [ = ]       0    ../../src/lib/tecs/TECS.cpp
  -7.0%     -64  [ = ]       0    ../../src/lib/version/version.c
  +1.9%     +16  [ = ]       0    ../../src/modules/commander/HealthAndArmingChecks/HealthAndArmingChecks.cpp
 -10.0%     -16  [ = ]       0    ../../src/modules/commander/HealthAndArmingChecks/checks/navigatorCheck.cpp
  -0.9%     -16  [ = ]       0    ../../src/modules/fw_att_control/FixedwingAttitudeControl.cpp
  [NEW] +2.38Ki  [ = ]       0    ../../src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp
 -11.4%    -688  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  -2.9%     -16  [ = ]       0    ../../src/modules/fw_pos_control/runway_takeoff/RunwayTakeoff.cpp
 -99.5%    +560  [ = ]       0    [10 Others]
-8.9% -6.75Ki  [ = ]       0    [Unmapped]
+0.6%  +259Ki  +0.3% +6.81Ki    TOTAL

Updated: 2025-02-24T15:46:27

@RomanBapst RomanBapst force-pushed the pr-fw_ctrl_api branch 3 times, most recently from 4544dec to daa6b1a Compare January 8, 2025 12:40
Copy link
Contributor

@KonradRudin KonradRudin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the restructuring, having the fixed wing position control more separated into the mode and the actual control. As well as having more intermediate options.
I went through all of it. but not in the complete detail yet, just when i saw something i mentioned it.
Biggest issue for me is that we don't yet have a clear way to tell, that the longitudinal and lateral controller should be enabled or not. Should be in the vehicle control mode flags propably like _vcontrol_mode.flag_control_rates_enabled

float32 height_rate_setpoint # NAN if not controlled directly, used as feeforward if altitude_setpoint is finite [m/s]
float32 altitude_setpoint # NAN if not controlled, MSL [m]
float32 equivalent_airspeed_setpoint # [m/s]
float32 pitch_sp # NAN if not controlled, overrides total energy controller [rad]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you can't use those as feedforwards, right? So shouldn't we keep that separate as an alternative to the attitudeSetpoint message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KonradRudin The reason that they are there is because the fixed wing takeoff and landing modes do make use of setting pitch / roll setpoints directly. I thought about having those modes publish attitude setpoints directly, however, the issue is that the FwLatLonControl module does not know about this and keeps on publishing attitude setpoints as well. The correct approach would be to set the control flags for attitude and rates only, but that requires those modes to be separated in commander. I don't yet have a good solution for this.

float tecs_fw_thr_max;
const float acc_rad = _directional_guidance.switchDistance(500.0f);
float throttle_min = _param_fw_thr_min.get();
float throttle_max = _param_fw_thr_max.get();

if (pos_sp_curr.gliding_enabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is currently not handled, right? Check comment about the uorb topic, would be nice to have in the long control a field where you can specify normal mode or like here thrust/speed mode

Copy link
Member

@Jaeyoung-Lim Jaeyoung-Lim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry that I am late to comment on this PR. I think there would be a lot of value of creating a FW API.

The api proposed have separate messages for longitudinal and lateral gudiance. This seems to be built on the assumption that lateral and longitudinal control (TECS) would be controlled in a decoupled way.

However, it would have been nicer if the api would be designed for more "generic" fixed-wing tasks, rather than exposing configurations of the underlying interface. IMO, an api should fully define what the vehicle "should" do for a given task (e.g. path following), rather than expose the underlying implementation.

  • Lateral/longitudinal controller decoupling is a design choice for a specific implementation. This would make it hard for other controllers to share the API, if the controllers do not have such decoupling (e.g. 3D NDI acceleration-based control).

  • The decoupling is not only not necessary for the task of path following, but can even limit what kind of paths we can follow in 3D. For example, if you try to track an inclined loiter(or any complex 3D path of arbitrary shape) the height rate setpoint in the FwLongitudinalSetpoint.msg is no longer usable, since the information on the 3D geometry is already lost (e.g. height rate depends on the speed and direction of the vehicle to stay on the path).

Is there a good reason that we want to enforce the separation of lateral/longitudinal control on the API side?
@tstastny

@RomanBapst
Copy link
Contributor Author

@Jaeyoung-Lim Thanks for your input on this!

The api proposed have separate messages for longitudinal and lateral gudiance. This seems to be built on the assumption that lateral and longitudinal control (TECS) would be controlled in a decoupled way.

Yes, and so far lateral and longitudinal control have almost completely been decoupled in PX4. The only coupling I am aware of is that NPFG used to be able to change the airspeed setpoint. But other than that, it was decoupled.
So far this architecture has brought us a long way and I don't think it's terrible.

However, it would have been nicer if the api would be designed for more "generic" fixed-wing tasks, rather than exposing configurations of the underlying interface. IMO, an api should fully define what the vehicle "should" do for a given task (e.g. path following), rather than expose the underlying implementation.

You are not limited to the exposed interfaces presented in this PR. If you want to have your fancy NDI controller running offboard and send attitude / rate or even actuator commands directly, you are free to do so, those interfaces I think are already there.

Lateral/longitudinal controller decoupling is a design choice for a specific implementation. This would make it hard for other controllers to share the API, if the controllers do not have such decoupling (e.g. 3D NDI acceleration-based control).

I think it's a design choice which solves 95% of the use case that people would want. I think that's pretty good.

The decoupling is not only not necessary for the task of path following, but can even limit what kind of paths we can follow in 3D. For example, if you try to track an inclined loiter(or any complex 3D path of arbitrary shape) the height rate setpoint in the FwLongitudinalSetpoint.msg is no longer usable, since the information on the 3D geometry is already lost (e.g. height rate depends on the speed and direction of the vehicle to stay on the path).

Could you please specify the exact interface that you would need to solve whatever use case you are trying to solve?
If it's a valid use case and it cannot be done with the current API, then we could always add it.

Generally, I have a feeling that your expectation is that ONE uorb topic defines exactly ONE control API. I don't think this needs to be true necessarily. I think you will use some kind of SDK, which will expose one interface to the developer, but the SDK itself can use multiple uorb topics.

@tstastny
Copy link

tstastny commented Feb 12, 2025

Hi. Thanks @RomanBapst and @KonradRudin for putting in work to finally start cleaning up the the fixed-wing high-level control infrastructure a bit! I haven't had time to fully go through the details, but I am a little confused what specifically is the "API" here. But there may just be some difference in everyone's semantics...

The uorb topics in the figure look more like logging topics to me, as I find it odd an application would send e.g. pitch setpoint, throttle setpoint, altitude setpoint, and height rate setpoint all out into the ether at the same time? Maybe @RomanBapst you can de-confuse me on the strategy? :) Are there multiple uorbs being bundled and sent at once from e.g. the ROS2 mode? Are these messages just defining what each block (controller) needs as input? And the actual exposed API will be something more basic, with each control block parsing it to convert to the right inputs to each? Maybe it would help to include the module boundaries on the diagram, so it's clear where uorbs are subscribed to, vs whatever internal parsing a module does to input the right args to the control libraries.

On the topic of alternate APIs (@Jaeyoung-Lim ), the block diagram itself looks as though it's not terribly far away from supporting a wide array of things. e.g. if there were a single 3d instantaneous path setpoint API, the height component of it could still be routed to Alt-Ctrl, the vertical incline of the path then converted to a height rate setpoint that could be used as feedforward, added to the feedback height rate from Alt-Ctrl, and then sent off to TECS (or Velocity NDI, or whatever). It looks as though that is actually already somewhat happening in the diagram?

So long as the blocks on the diagram are decoupled as shown, and new urobs can be made with a parser to spit out the resp. input msgs each controller one is using needs, I would imagine it's possible to do, right? Or maybe I miss something on the routing details? (I am a bit foggy on things now after not looking for a long time)

@RomanBapst RomanBapst changed the title WIP: Fixed wing control API WIP: Fixed wing control refactoring Feb 13, 2025
@RomanBapst
Copy link
Contributor Author

The uorb topics in the figure look more like logging topics to me, as I find it odd an application would send e.g. pitch setpoint, throttle setpoint, altitude setpoint, and height rate setpoint all out into the ether at the same time? Maybe @RomanBapst you can de-confuse me on the strategy? :)

@tstastny I have changed the title of the PR to not contain the word API, as it seems to be confusing.
You can call the new uorb messages an API, but it's definitely not the API we want to expose 1 to 1 to the end developer.
The idea would be that the SDK which is used for development (auterion SDK or whatever SDK you like), converts the developer facing controller setpoint into the uorb messages defined in this PR.

Also note, that the current uorb messages contain certain fields I wish would not be there, but since it was a priority to not break existing functionality with this refactor, I added them regardless. I am all in favor to remove fields like heading_sp_runway_takeoff and pitch_sp from the message.
It's the fixed wing takeoff and the fixed wing landing modes which requires these fields.

I'm also adding a diagram here which I hope explains a bit better the architecture in terms of modularity.
image

Comment on lines +5 to +6
float32 course_setpoint # [-pi, pi], NAN if not controlled directly
float32 airspeed_reference_direction # [-pi, pi], angle of desired airspeed vector, NAN if not controlled directly, used as feedforward if course setpoint is finite
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the other elements in the messages are described with units, [rad] could be added here as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and we need to add if it's a true airspeed or calibrated/indicated/equivalent

float32 course_setpoint # [-pi, pi], NAN if not controlled directly
float32 airspeed_reference_direction # [-pi, pi], angle of desired airspeed vector, NAN if not controlled directly, used as feedforward if course setpoint is finite
float32 lateral_acceleration_setpoint # [m/s^2], NAN if not controlled directly, used as feedforward if either course setpoint or airspeed_reference_direction is finite
float32 roll_sp # TODO: remove, only for testing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

RomanBapst and others added 6 commits March 4, 2025 13:19
* bit of cosmetic cleanup

Signed-off-by: Silvan <[email protected]>

* AttitudeSetpoint.msg: remove reset_integral

The functionality of resetting the rate controller integrals when
the position controller deems it necessary adds a lot of complexity
for low benefits and is thus removed here.

Signed-off-by: Silvan <[email protected]>

* FwLateralControlSetpoint.msg: remove reset_integral

Signed-off-by: Silvan <[email protected]>

* VehicleAttitudeSetpoint: remove fw_control_yaw_wheel

This info can be passed to the wheel controller via a separate message
(e.g. runway_takeoff_status). What about landing anyway? We don't have
any auto wheel control there yet.

Signed-off-by: Silvan <[email protected]>

* remove passing of yaw setpoint from FW Pos Control to attitude (for wheel)

Signed-off-by: Silvan <[email protected]>

* remove NPFG guidance when on ground

Signed-off-by: Silvan <[email protected]>

---------

Signed-off-by: Silvan <[email protected]>
Co-authored-by: Roman Bapst <[email protected]>
- only publish if they changed

Signed-off-by: RomanBapst <[email protected]>
return can_run_factor * (lateral_accel_sp);
}
float FwLateralLongitudinalControl::mapLateralAccelerationToRollAngle(float lateral_acceleration_sp) const {
return atanf(lateral_acceleration_sp * 1.0f / CONSTANTS_ONE_G);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussion we can remove the 1.0f from the function.

Comment on lines +256 to +262
fw_lateral_control_setpoint_s status = {
.timestamp = _lat_control_sp.timestamp,
.course_setpoint = _lat_control_sp.course_setpoint,
.airspeed_reference_direction = airspeed_reference_direction,
.lateral_acceleration_setpoint = lateral_accel_sp,
.roll_sp = roll_sp // TODO: just for logging, can be removed later
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment that its only for logging and not consumed by any other

Comment on lines +132 to +133
uORB::PublicationData <fw_lateral_control_setpoint_s> _lateral_ctrl_status_pub{ORB_ID(fw_lateral_control_status)};
uORB::PublicationData <fw_longitudinal_control_setpoint_s> _longitudinal_ctrl_status_pub{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be type uORB::Publication ?

@@ -0,0 +1,63 @@
/****************************************************************************
*
* Copyright (c) 2024 PX4 Development Team. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Copyright (c) 2024 PX4 Development Team. All rights reserved.
* Copyright (c) 2025 PX4 Development Team. All rights reserved.

saw it in a few other places as well

* @param[in] wind_cross_bearing 2D cross product of wind velocity and bearing vector [m/s]
* @param[in] wind_dot_bearing 2D dot product of wind velocity and bearing vector [m/s]
* @param[in] wind_speed Wind speed [m/s]
* @param[in] min_ground_speed Minimum commanded forward ground speed [m/s]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min_ground_speed is no longer an input

// must be called before trackErrorBound() as it updates time_const_
adapted_period_ = adaptPeriod(ground_speed, airspeed, wind_speed, track_error,
path_curvature, wind_vel, unit_path_tangent, feas_on_track_);
_time_const = timeConst(adapted_period_, damping_);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_time_const = timeConst(adapted_period_, damping_);
const float time_const = timeConst(adapted_period_, damping_);

As it's no longer used outside the scope of this function and then remove the class variable in the headerfile

// must be called before trackErrorBound() as it updates time_const_
adapted_period_ = adaptPeriod(ground_speed, airspeed, wind_speed, track_error,
path_curvature, wind_vel, unit_path_tangent, feas_on_track_);
p_gain_ = pGain(adapted_period_, damping_);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is an adaptive gain not needed anymore?

float throttle_sp{NAN};

if (_fw_longitudinal_ctrl_sub.updated()) {
_fw_longitudinal_ctrl_sub.copy(&_long_control_sp);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_fw_longitudinal_ctrl_sub.copy(&_long_control_sp);
fw_longitudinal_control_setpoint_s long_control_sp
_fw_longitudinal_ctrl_sub.copy(&long_control_sp);

Looks like it's only in this scope so definition can be within the scope instead of the headerfile


if ((now - _time_since_first_reduced_roll) > ROLL_WARNING_TIMEOUT) {
_need_report_npfg_uncertain_condition = false;
events::send(events::ID("npfg_roll_command_uncertain"), events::Log::Warning,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
events::send(events::ID("npfg_roll_command_uncertain"), events::Log::Warning,
events::send(events::ID("fw_lateral_longitudinal_control_roll_command_uncertain"), events::Log::Warning,

as it's now in the module and not in the lib

Comment on lines +697 to +707
_long_limits.timestamp = hrt_absolute_time();
_long_limits.equivalent_airspeed_min = _performance_model.getMinimumCalibratedAirspeed();
_long_limits.equivalent_airspeed_max = _performance_model.getMaximumCalibratedAirspeed();
_long_limits.pitch_min = radians(_param_fw_p_lim_min.get());
_long_limits.pitch_max = radians(_param_fw_p_lim_max.get());
_long_limits.throttle_min = _param_fw_thr_min.get();
_long_limits.throttle_max = _param_fw_thr_max.get();
_long_limits.climb_rate_target = _param_climbrate_target.get();
_long_limits.sink_rate_target = _param_sinkrate_target.get();
_long_limits.disable_underspeed_protection = false;
_long_limits.enforce_low_height_condition = false;
Copy link
Contributor

@perrrre perrrre Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rows has 2 indents

_longitudinal_ctrl_status_pub.publish(longitudinal_control_status);

float roll_sp {NAN};
float yaw_sp {NAN};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall the yaw_sp be removed?

_long_limits.disable_underspeed_protection,
_long_control_sp.height_rate_setpoint
);
pitch_sp = PX4_ISFINITE(_long_control_sp.pitch_sp) ? _long_control_sp.pitch_sp : _tecs.get_pitch_setpoint();
Copy link
Contributor

@perrrre perrrre Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pitch setpoint used to have a protection in case the tecs is not running:
`
if (_tecs_is_running) {
return _tecs.get_pitch_setpoint() + radians(_param_fw_psp_off.get());
}

// return level flight pitch offset to prevent stale tecs state when it's not running
return radians(_param_fw_psp_off.get());

`

Shall we add a method for that here?

_long_control_sp.height_rate_setpoint
);
pitch_sp = PX4_ISFINITE(_long_control_sp.pitch_sp) ? _long_control_sp.pitch_sp : _tecs.get_pitch_setpoint();
throttle_sp = PX4_ISFINITE(_long_control_sp.thrust_sp) ? _long_control_sp.thrust_sp : _tecs.get_throttle_setpoint();
Copy link
Contributor

@perrrre perrrre Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The throttle also had some protection:

`
if (_tecs_is_running) {
return min(_tecs.get_throttle_setpoint(), 1.f);

// return 0 to prevent stale tecs state when it's not running
return 0.0f;`

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.

8 participants