From a8a354d04aef726a4ef2725566cd72368aeac4d7 Mon Sep 17 00:00:00 2001 From: mahima-yoga Date: Wed, 16 Apr 2025 09:54:21 +0200 Subject: [PATCH] msgs: Clean up message definitions and descriptions - Add versioning to interfacing messages - Add header description - Add units, frame and range wherever possible --- msg/CMakeLists.txt | 10 +++++----- msg/FixedWingLateralGuidanceStatus.msg | 17 ++++++++++------- msg/FixedWingLateralSetpoint.msg | 7 ------- msg/FixedWingLateralStatus.msg | 9 ++++++--- msg/FixedWingLongitudinalSetpoint.msg | 9 --------- msg/LateralControlConfiguration.msg | 3 --- msg/versioned/FixedWingLateralSetpoint.msg | 11 +++++++++++ msg/versioned/FixedWingLongitudinalSetpoint.msg | 13 +++++++++++++ msg/versioned/LateralControlConfiguration.msg | 8 ++++++++ .../LongitudinalControlConfiguration.msg | 12 +++++++++--- msg/{ => versioned}/Wind.msg | 2 ++ .../FwLateralLongitudinalControl.cpp | 2 +- 12 files changed, 65 insertions(+), 38 deletions(-) delete mode 100644 msg/FixedWingLateralSetpoint.msg delete mode 100644 msg/FixedWingLongitudinalSetpoint.msg delete mode 100644 msg/LateralControlConfiguration.msg create mode 100644 msg/versioned/FixedWingLateralSetpoint.msg create mode 100644 msg/versioned/FixedWingLongitudinalSetpoint.msg create mode 100644 msg/versioned/LateralControlConfiguration.msg rename msg/{ => versioned}/LongitudinalControlConfiguration.msg (53%) rename msg/{ => versioned}/Wind.msg (96%) diff --git a/msg/CMakeLists.txt b/msg/CMakeLists.txt index 29af39b27f..0c8ff6a392 100644 --- a/msg/CMakeLists.txt +++ b/msg/CMakeLists.txt @@ -90,8 +90,6 @@ set(msg_files FollowTargetEstimator.msg FollowTargetStatus.msg FuelTankStatus.msg - FixedWingLateralSetpoint.msg - FixedWingLongitudinalSetpoint.msg FixedWingLateralGuidanceStatus.msg FixedWingLateralStatus.msg FixedWingRunwayControl.msg @@ -125,12 +123,10 @@ set(msg_files LandingGearWheel.msg LandingTargetInnovations.msg LandingTargetPose.msg - LateralControlConfiguration.msg LaunchDetectionStatus.msg LedControl.msg LoggerStatus.msg LogMessage.msg - LongitudinalControlConfiguration.msg MagnetometerBiasEstimate.msg MagWorkerData.msg ManualControlSwitches.msg @@ -238,7 +234,6 @@ set(msg_files VehicleTorqueSetpoint.msg VelocityLimits.msg WheelEncoders.msg - Wind.msg YawEstimatorStatus.msg versioned/ActuatorMotors.msg versioned/ActuatorServos.msg @@ -247,8 +242,12 @@ set(msg_files versioned/ArmingCheckRequest.msg versioned/BatteryStatus.msg versioned/ConfigOverrides.msg + versioned/FixedWingLateralSetpoint.msg + versioned/FixedWingLongitudinalSetpoint.msg versioned/GotoSetpoint.msg versioned/HomePosition.msg + versioned/LateralControlConfiguration.msg + versioned/LongitudinalControlConfiguration.msg versioned/ManualControlSetpoint.msg versioned/ModeCompleted.msg versioned/RegisterExtComponentReply.msg @@ -268,6 +267,7 @@ set(msg_files versioned/VehicleRatesSetpoint.msg versioned/VehicleStatus.msg versioned/VtolVehicleStatus.msg + versioned/Wind.msg ) list(SORT msg_files) diff --git a/msg/FixedWingLateralGuidanceStatus.msg b/msg/FixedWingLateralGuidanceStatus.msg index 6295f8948e..a2e3f5f951 100644 --- a/msg/FixedWingLateralGuidanceStatus.msg +++ b/msg/FixedWingLateralGuidanceStatus.msg @@ -1,10 +1,13 @@ +# Fixed Wing Lateral Guidance Status message +# Published by fw_pos_control module to report the resultant lateral setpoints and NPFG debug outputs + uint64 timestamp # time since system start (microseconds) -float32 course_setpoint # bearing angle (same as course) [rad] -float32 lateral_acceleration_ff # lateral acceleration demand only for maintaining curvature [m/s^2] -float32 bearing_feas # bearing feasibility [0,1] -float32 bearing_feas_on_track # on-track bearing feasibility [0,1] -float32 signed_track_error # signed track error [m] -float32 track_error_bound # track error bound [m] -float32 adapted_period # adapted period (if auto-tuning enabled) [s] +float32 course_setpoint # [rad] [-pi, pi] Bearing angle. Same as course over ground setpoint, w.r.t. North. +float32 lateral_acceleration_ff # [m/s^2] [FRD] lateral acceleration demand only for maintaining curvature +float32 bearing_feas # [0,1] bearing feasibility +float32 bearing_feas_on_track # [0,1] on-track bearing feasibility +float32 signed_track_error # [m] signed track error +float32 track_error_bound # [m] track error bound +float32 adapted_period # [s] adapted period (if auto-tuning enabled) uint8 wind_est_valid # (boolean) true = wind estimate is valid and/or being used by controller (also indicates if wind est usage is disabled despite being valid) diff --git a/msg/FixedWingLateralSetpoint.msg b/msg/FixedWingLateralSetpoint.msg deleted file mode 100644 index d899993ad5..0000000000 --- a/msg/FixedWingLateralSetpoint.msg +++ /dev/null @@ -1,7 +0,0 @@ -uint64 timestamp - -# NOTE: At least one of course, airspeed_direction, or lateral_acceleration must be finite - -float32 course # [-pi, pi] Course over ground setpoint, w.r.t. North. NAN if not controlled directly. -float32 airspeed_direction # [-pi, pi] Angle projected to ground of desired airspeed vector, w.r.t. North. NAN if not controlled directly, used as feedforward if course setpoint is finite. -float32 lateral_acceleration # [m/s^2] Lateral acceleration setpoint in FRD frame. NAN if not controlled directly, used as feedforward if either course setpoint or airspeed_direction is finite. diff --git a/msg/FixedWingLateralStatus.msg b/msg/FixedWingLateralStatus.msg index b877948b24..607729fa47 100644 --- a/msg/FixedWingLateralStatus.msg +++ b/msg/FixedWingLateralStatus.msg @@ -1,4 +1,7 @@ -uint64 timestamp # time since system start (microseconds) +# Fixed Wing Lateral Status message +# Published by the fw_lateral_longitudinal_control module to report the resultant lateral setpoint -float32 lateral_acceleration # resultant lateral acceleration reference [m/s^2] -float32 can_run_factor # estimate of certainty of the correct functionality of the npfg roll setpoint in [0, 1] +uint64 timestamp # time since system start (microseconds) + +float32 lateral_acceleration_setpoint # [m/s^2] [FRD] resultant lateral acceleration setpoint +float32 can_run_factor # [0, 1] estimate of certainty of the correct functionality of the npfg roll setpoint in diff --git a/msg/FixedWingLongitudinalSetpoint.msg b/msg/FixedWingLongitudinalSetpoint.msg deleted file mode 100644 index 25595f76c4..0000000000 --- a/msg/FixedWingLongitudinalSetpoint.msg +++ /dev/null @@ -1,9 +0,0 @@ -uint64 timestamp - -# Note: If not both pitch_direct and throttle_direct are finite, then either altitude or height_rate must be finite - -float32 altitude # [m] Altitude setpoint AMSL, NAN if not controlled -float32 height_rate # [m/s] NAN if not controlled directly, used as feedforward if altitude is finite -float32 equivalent_airspeed # [m/s] NAN if system default should be used -float32 pitch_direct # [rad] NAN if not controlled, overrides total energy controller -float32 throttle_direct # [0,1] NAN if not controlled, overrides total energy controller diff --git a/msg/LateralControlConfiguration.msg b/msg/LateralControlConfiguration.msg deleted file mode 100644 index ee96028776..0000000000 --- a/msg/LateralControlConfiguration.msg +++ /dev/null @@ -1,3 +0,0 @@ -uint64 timestamp - -float32 lateral_accel_max # [m/s^2] maps 1:1 to a maximum roll angle, accel_max = tan(roll_max) * GRAVITY diff --git a/msg/versioned/FixedWingLateralSetpoint.msg b/msg/versioned/FixedWingLateralSetpoint.msg new file mode 100644 index 0000000000..7485f502ae --- /dev/null +++ b/msg/versioned/FixedWingLateralSetpoint.msg @@ -0,0 +1,11 @@ +# Fixed Wing Lateral Setpoint message +# Used by the fw_lateral_longitudinal_control module +# At least one of course, airspeed_direction, or lateral_acceleration must be finite. + +uint32 MESSAGE_VERSION = 0 + +uint64 timestamp # time since system start (microseconds) + +float32 course # [rad] [-pi, pi] Course over ground setpoint, w.r.t. North. NAN if not controlled directly. +float32 airspeed_direction # [rad] [-pi, pi] Angle projected to ground of desired airspeed vector, w.r.t. North. NAN if not controlled directly, used as feedforward if course setpoint is finite. +float32 lateral_acceleration # [m/s^2] [FRD] Lateral acceleration setpoint. NAN if not controlled directly, used as feedforward if either course setpoint or airspeed_direction is finite. diff --git a/msg/versioned/FixedWingLongitudinalSetpoint.msg b/msg/versioned/FixedWingLongitudinalSetpoint.msg new file mode 100644 index 0000000000..fac2980394 --- /dev/null +++ b/msg/versioned/FixedWingLongitudinalSetpoint.msg @@ -0,0 +1,13 @@ +# Fixed Wing Longitudinal Setpoint message +# Used by the fw_lateral_longitudinal_control module +# If not both pitch_direct and throttle_direct are finite, then either altitude or height_rate must be finite. + +uint32 MESSAGE_VERSION = 0 + +uint64 timestamp # time since system start (microseconds) + +float32 altitude # [m] Altitude setpoint AMSL, not controlled directly if NAN or if height_rate is finite +float32 height_rate # [m/s] NAN if not controlled directly +float32 equivalent_airspeed # [m/s] NAN if system default should be used +float32 pitch_direct # [rad] [FRD] NAN if not controlled, overrides total energy controller +float32 throttle_direct # [0,1] NAN if not controlled, overrides total energy controller diff --git a/msg/versioned/LateralControlConfiguration.msg b/msg/versioned/LateralControlConfiguration.msg new file mode 100644 index 0000000000..363b28d2e1 --- /dev/null +++ b/msg/versioned/LateralControlConfiguration.msg @@ -0,0 +1,8 @@ +# Fixed Wing Lateral Control Configuration message +# Used by the fw_lateral_longitudinal_control module to constrain FixedWingLateralSetpoint messages. + +uint32 MESSAGE_VERSION = 0 + +uint64 timestamp # time since system start (microseconds) + +float32 lateral_accel_max # [m/s^2] maps 1:1 to a maximum roll angle, accel_max = tan(roll_max) * GRAVITY diff --git a/msg/LongitudinalControlConfiguration.msg b/msg/versioned/LongitudinalControlConfiguration.msg similarity index 53% rename from msg/LongitudinalControlConfiguration.msg rename to msg/versioned/LongitudinalControlConfiguration.msg index 0f944cc9bf..a9beb3eb06 100644 --- a/msg/LongitudinalControlConfiguration.msg +++ b/msg/versioned/LongitudinalControlConfiguration.msg @@ -1,11 +1,17 @@ -uint64 timestamp +# Fixed Wing Longitudinal Control Configuration message +# Used by the fw_lateral_longitudinal_control module and TECS to constrain FixedWingLongitudinalSetpoint messages +# and configure the resultant setpoints. + +uint32 MESSAGE_VERSION = 0 + +uint64 timestamp # time since system start (microseconds) float32 pitch_min # [rad] float32 pitch_max # [rad] float32 throttle_min # [0,1] float32 throttle_max # [0,1] -float32 climb_rate_target # [m/s] target climbrate used to change altitude -float32 sink_rate_target # [m/s] target sinkrate used to change altitude +float32 climb_rate_target # [m/s] target climbrate used to change altitude. Not used if height_rate is directly set in FixedWingLongitudinalSetpoint. +float32 sink_rate_target # [m/s] target sinkrate used to change altitude. Not used if height_rate is directly set in FixedWingLongitudinalSetpoint. float32 speed_weight # [0,2], 0=pitch controls altitude only, 2=pitch controls airspeed only bool enforce_low_height_condition # if true, total energy controller will use lower altitude control time constant bool disable_underspeed_protection # if true, underspeed handling is disabled in the total energy controller diff --git a/msg/Wind.msg b/msg/versioned/Wind.msg similarity index 96% rename from msg/Wind.msg rename to msg/versioned/Wind.msg index ff8b6f4535..7a53f9bfa7 100644 --- a/msg/Wind.msg +++ b/msg/versioned/Wind.msg @@ -1,3 +1,5 @@ +uint32 MESSAGE_VERSION = 0 + uint64 timestamp # time since system start (microseconds) uint64 timestamp_sample # the timestamp of the raw data (microseconds) diff --git a/src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp b/src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp index b0306b0655..bce9f535f5 100644 --- a/src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp +++ b/src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp @@ -278,7 +278,7 @@ void FwLateralLongitudinalControl::Run() fixed_wing_lateral_status_s fixed_wing_lateral_status{}; fixed_wing_lateral_status.timestamp = hrt_absolute_time(); - fixed_wing_lateral_status.lateral_acceleration = lateral_accel_sp; + fixed_wing_lateral_status.lateral_acceleration_setpoint = lateral_accel_sp; fixed_wing_lateral_status.can_run_factor = _can_run_factor; _fixed_wing_lateral_status_pub.publish(fixed_wing_lateral_status);