-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
Move PositionControl logging (PSCN, PSCE, PSCD) into AC_AttitudeControl library #26351
Merged
peterbarker
merged 5 commits into
ArduPilot:master
from
peterbarker:pr/move-poscontrol-logging
Feb 29, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
21d9155
AC_AttitudeControl: move logging of PSC messages into AC_AttitudeControl
peterbarker ddccca4
AP_Logger: move logging of PSC messages into AC_AttitudeControl
peterbarker 2e69f97
AC_AttitudeControl: make logging methods public/static so Blimp can u…
peterbarker 6b9928c
Blimp: adjust for logging having moved to AC_PosControl
peterbarker 2950ff6
AR_PosControl: adjust for logging having moved into AC_AttitudeControl
peterbarker 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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <AP_Logger/AP_Logger_config.h> | ||
|
||
#if HAL_LOGGING_ENABLED | ||
|
||
#include "AC_PosControl.h" | ||
|
||
#include <AP_Logger/AP_Logger.h> | ||
#include "LogStructure.h" | ||
|
||
// a convenience function for writing out the position controller PIDs | ||
void AC_PosControl::Write_PSCx(LogMessages id, float pos_target, float pos, float vel_desired, float vel_target, float vel, float accel_desired, float accel_target, float accel) | ||
{ | ||
const struct log_PSCx pkt{ | ||
LOG_PACKET_HEADER_INIT(id), | ||
time_us : AP_HAL::micros64(), | ||
pos_target : pos_target * 0.01f, | ||
pos : pos * 0.01f, | ||
vel_desired : vel_desired * 0.01f, | ||
vel_target : vel_target * 0.01f, | ||
vel : vel * 0.01f, | ||
accel_desired : accel_desired * 0.01f, | ||
accel_target : accel_target * 0.01f, | ||
accel : accel * 0.01f | ||
}; | ||
AP::logger().WriteBlock(&pkt, sizeof(pkt)); | ||
} | ||
|
||
void AC_PosControl::Write_PSCN(float pos_target, float pos, float vel_desired, float vel_target, float vel, float accel_desired, float accel_target, float accel) | ||
{ | ||
Write_PSCx(LOG_PSCN_MSG, pos_target, pos, vel_desired, vel_target, vel, accel_desired, accel_target, accel); | ||
} | ||
|
||
void AC_PosControl::Write_PSCE(float pos_target, float pos, float vel_desired, float vel_target, float vel, float accel_desired, float accel_target, float accel) | ||
{ | ||
Write_PSCx(LOG_PSCE_MSG, pos_target, pos, vel_desired, vel_target, vel, accel_desired, accel_target, accel); | ||
} | ||
|
||
void AC_PosControl::Write_PSCD(float pos_target, float pos, float vel_desired, float vel_target, float vel, float accel_desired, float accel_target, float accel) | ||
{ | ||
Write_PSCx(LOG_PSCD_MSG, pos_target, pos, vel_desired, vel_target, vel, accel_desired, accel_target, accel); | ||
} | ||
|
||
#endif // HAL_LOGGING_ENABLED |
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#pragma once | ||
|
||
#include <AP_Logger/LogStructure.h> | ||
|
||
#define LOG_IDS_FROM_AC_ATTITUDECONTROL \ | ||
LOG_PSCN_MSG, \ | ||
LOG_PSCE_MSG, \ | ||
LOG_PSCD_MSG | ||
|
||
// @LoggerMessage: PSCN | ||
// @Description: Position Control North | ||
// @Field: TimeUS: Time since system startup | ||
// @Field: TPN: Target position relative to EKF origin | ||
// @Field: PN: Position relative to EKF origin | ||
// @Field: DVN: Desired velocity North | ||
// @Field: TVN: Target velocity North | ||
// @Field: VN: Velocity North | ||
// @Field: DAN: Desired acceleration North | ||
// @Field: TAN: Target acceleration North | ||
// @Field: AN: Acceleration North | ||
|
||
// @LoggerMessage: PSCE | ||
// @Description: Position Control East | ||
// @Field: TimeUS: Time since system startup | ||
// @Field: TPE: Target position relative to EKF origin | ||
// @Field: PE: Position relative to EKF origin | ||
// @Field: DVE: Desired velocity East | ||
// @Field: TVE: Target velocity East | ||
// @Field: VE: Velocity East | ||
// @Field: DAE: Desired acceleration East | ||
// @Field: TAE: Target acceleration East | ||
// @Field: AE: Acceleration East | ||
|
||
// @LoggerMessage: PSCD | ||
// @Description: Position Control Down | ||
// @Field: TimeUS: Time since system startup | ||
// @Field: TPD: Target position relative to EKF origin | ||
// @Field: PD: Position relative to EKF origin | ||
// @Field: DVD: Desired velocity Down | ||
// @Field: TVD: Target velocity Down | ||
// @Field: VD: Velocity Down | ||
// @Field: DAD: Desired acceleration Down | ||
// @Field: TAD: Target acceleration Down | ||
// @Field: AD: Acceleration Down | ||
|
||
|
||
// position controller per-axis logging | ||
struct PACKED log_PSCx { | ||
LOG_PACKET_HEADER; | ||
uint64_t time_us; | ||
float pos_target; | ||
float pos; | ||
float vel_desired; | ||
float vel_target; | ||
float vel; | ||
float accel_desired; | ||
float accel_target; | ||
float accel; | ||
}; | ||
|
||
#define PSCx_FMT "Qffffffff" | ||
#define PSCx_UNITS "smmnnnooo" | ||
#define PSCx_MULTS "F00000000" | ||
|
||
#define LOG_STRUCTURE_FROM_AC_ATTITUDECONTROL \ | ||
{ LOG_PSCN_MSG, sizeof(log_PSCx), \ | ||
"PSCN", PSCx_FMT, "TimeUS,TPN,PN,DVN,TVN,VN,DAN,TAN,AN", PSCx_UNITS, PSCx_MULTS }, \ | ||
{ LOG_PSCE_MSG, sizeof(log_PSCx), \ | ||
"PSCE", PSCx_FMT, "TimeUS,TPE,PE,DVE,TVE,VE,DAE,TAE,AE", PSCx_UNITS, PSCx_MULTS }, \ | ||
{ LOG_PSCD_MSG, sizeof(log_PSCx), \ | ||
"PSCD", PSCx_FMT, "TimeUS,TPD,PD,DVD,TVD,VD,DAD,TAD,AD", PSCx_UNITS, PSCx_MULTS } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
nitpick: small whitespace issue but preexisting it seems..