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

ekf2: apply astyle formatting and enforce #23369

Merged
merged 2 commits into from
Jul 10, 2024
Merged

Conversation

dagar
Copy link
Member

@dagar dagar commented Jul 5, 2024

Now that all the generated code is cleanly separated we can start enforcing astyle like the rest of the code base. There are a few areas with very long lines that astyle has kind of made a mess of, but we can get that under control.

bool vision_data_stopped : 1; ///< 9 - true when the vision system data has stopped for a significant time period
bool emergency_yaw_reset_mag_stopped : 1; ///< 10 - true when the filter has detected bad magnetometer data, has reset the yaw to anothter source of data and has stopped further use of the magnetometer data
bool emergency_yaw_reset_gps_yaw_stopped: 1; ///< 11 - true when the filter has detected bad GNSS yaw data, has reset the yaw to anothter source of data and has stopped further use of the GNSS yaw data
bool gps_data_stopped_using_alternate :
Copy link
Member Author

@dagar dagar Jul 5, 2024

Choose a reason for hiding this comment

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

Some of these warning flags aren't even being used, and most of the rest we can figure out from other sources.

Rather than cleaning this up I propose we get rid of these, it saves about 500 bytes of flash in message field strings.

@dagar dagar force-pushed the pr-ekf2_ekf_code_style_enforce branch from 1187150 to 1f6d69d Compare July 8, 2024 16:49
@@ -85,7 +87,8 @@ bool Ekf::fuseMag(const Vector3f &mag, const float R_MAG, VectorState &H, estima
sym::ComputeMagZInnovVarAndH(state_vector, P, R_MAG, FLT_EPSILON, &aid_src.innovation_variance[index], &H);

// recalculate innovation using the updated state
aid_src.innovation[index] = _state.quat_nominal.rotateVectorInverse(_state.mag_I)(index) + _state.mag_B(index) - mag(index);
aid_src.innovation[index] = _state.quat_nominal.rotateVectorInverse(_state.mag_I)(index) + _state.mag_B(index) - mag(
index);
Copy link
Member

Choose a reason for hiding this comment

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

that's a strange way to break a long line...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I was going to do some manual adjusting as a follow up, splitting these long lines with readability in mind.

@@ -281,7 +289,7 @@ struct parameters {
float initial_tilt_err{0.1f}; ///< 1-sigma tilt error after initial alignment using gravity vector (rad)

#if defined(CONFIG_EKF2_BAROMETER)
int32_t baro_ctrl{1};
int32_t baro_ctrl {1};
Copy link
Member

Choose a reason for hiding this comment

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

why do we need a space here and not on the other variables?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we do, but at the moment it's a compromise to let astyle do the rest automatically.

We could try and fix this particular little annoyance, but I don't think that should block the change for now.
https://astyle.sourceforge.net/astyle.html

@@ -345,7 +353,7 @@ struct parameters {
float mag_heading_noise{3.0e-1f}; ///< measurement noise used for simple heading fusion (rad)

#if defined(CONFIG_EKF2_MAGNETOMETER)
float mag_delay_ms{0.0f}; ///< magnetometer measurement delay relative to the IMU (mSec)
float mag_delay_ms {0.0f}; ///< magnetometer measurement delay relative to the IMU (mSec)
Copy link
Member

Choose a reason for hiding this comment

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

is it always the first one after a #if defined that needs an extra space?

Copy link
Member Author

Choose a reason for hiding this comment

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

Newer astyle may have fixed it, I'd like to get the container updated soon and shift the default CI environment to Ubuntu 24.04 (latest LTS).

bresch
bresch previously approved these changes Jul 10, 2024
 - some of these warning flags aren't even being used, and most of the rest we can figure out from other sources
@dagar dagar force-pushed the pr-ekf2_ekf_code_style_enforce branch from 49cf9dd to 9eed970 Compare July 10, 2024 14:43
@dagar dagar merged commit 75bb339 into main Jul 10, 2024
4 of 73 checks passed
@dagar dagar deleted the pr-ekf2_ekf_code_style_enforce branch July 10, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants