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

Refactoring, StateObserver and Python Tooling #229

Merged
merged 47 commits into from
May 14, 2024
Merged

Conversation

devarndt
Copy link
Collaborator

@devarndt devarndt commented Mar 7, 2024

Important files:

[2.0.1] - Unreleased

Added

  • Ruff: Python linter & formatter (see DEVELOPMENT.md)
  • StateObserver: An easy way to get state values with error checking example
  • Integrated gem_controls repository into gem. classic_controllers will be removed in further version
  • Using pyproject.toml, dropping deprecated setup.py
  • Enabled Gymnasium env checker see here

Changed

  • Linted and formatted all files
  • Changed max. steps in some test files to improve test speed by 30%

Fixed

@devarndt devarndt requested a review from max-schenke March 7, 2024 19:54
Comment on lines +59 to +60
_default_nominal_values = dict(omega=300, torque=16.0, i=97, i_a=97, i_e=97, u=60, u_a=60, u_e=60)
_default_limits = dict(omega=400, torque=38.0, i=210, i_a=210, i_e=210, u=60, u_a=60, u_e=60)
Copy link
Member

Choose a reason for hiding this comment

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

Should one specify all these values as floats by putting ".0" behind them?

(Applies to several files)

Comment on lines 130 to 166
[
0,
-mp["r_s"] / sigma,
0,
mp["l_m"] * mp["r_e"] / (sigma * mp["l_e"]),
1 / sigma,
0,
-mp["l_m"] / (sigma * mp["l_e"]),
0,
mp["l_q"] * mp["p"] / sigma,
0,
],
[
0,
0,
-mp["r_s"],
0,
0,
1,
0,
-mp["l_d"] * mp["p"],
0,
-mp["p"] * mp["l_m"],
],
[
0,
mp["l_m"] * mp["r_s"] / (sigma * mp["l_d"]),
0,
-mp["r_e"] / sigma,
-mp["l_m"] / (sigma * mp["l_d"]),
0,
1 / sigma,
0,
-mp["p"] * mp["l_m"] * mp["l_q"] / (sigma * mp["l_d"]),
0,
],
[mp["p"], 0, 0, 0, 0, 0, 0, 0, 0, 0],
Copy link
Member

Choose a reason for hiding this comment

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

On the one hand, I get that the formatter prefers this shape of code.
On the other hand, the matrix calculations involved have been more intuitive the way it was before refactoring.
I guess this needs further discussion.

(Applies to several files)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea, formating should definitely be disabled for this kind of calucations.
Leaving this here for future reference:

# fmt: off

def my_unformatted_function():
   do_something()

# fmt: on

Comment on lines 15 to 17
_t23 = 2 / 3 * np.array([
[1, -0.5, -0.5],
[0, 0.5 * np.sqrt(3), -0.5 * np.sqrt(3)]
])
_t23 = 2 / 3 * np.array([[1, -0.5, -0.5], [0, 0.5 * np.sqrt(3), -0.5 * np.sqrt(3)]])
Copy link
Member

Choose a reason for hiding this comment

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

Same issue. The formatter made the code less understandable (in my opinion).

Copy link
Member

@max-schenke max-schenke left a comment

Choose a reason for hiding this comment

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

No further objections apart from my earlier minor remarks.

An execution test will follow.

@max-schenke
Copy link
Member

I was not successful to run the unit tests locally:
ModuleNotFoundError: No module named 'classic_controllers'

Did I miss an optional install or is something missing from the requirements?
Also, GitHub still reports the tests to not be successful for Python 3.8. Is that fixable?

@devarndt
Copy link
Collaborator Author

devarndt commented Apr 2, 2024

I was not successful to run the unit tests locally:

ModuleNotFoundError: No module named 'classic_controllers'

Did I miss an optional install or is something missing from the requirements?

Also, GitHub still reports the tests to not be successful for Python 3.8. Is that fixable?

I will look into it on Thursday.

@max-schenke max-schenke changed the base branch from master to nightly April 25, 2024 07:21
@max-schenke
Copy link
Member

Integration test still fails on my machine, all other tests seems successful.

Also, GitHub still reports Version 3.8 to have failing tests.

Formatting issues persist and make it hard to read coded matrices.

@max-schenke max-schenke merged commit 24e3d82 into nightly May 14, 2024
4 checks passed
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.

3 participants