Skip to content

CDS 110 and CDS 112 Jupyter notebooks #1037

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

Merged
merged 18 commits into from
Aug 11, 2024

Conversation

murrayrm
Copy link
Member

@murrayrm murrayrm commented Aug 9, 2024

This PR adds ~25 new/updated Python notebooks to the examples/ subdirectory that are based on lectures give in CDS 110 (Introduction to Feedback Control) and CDS 112 (Optimization-Based Control) at Caltech in Winter 2024 and Spring 2023, respectively.

These files are intended to illustrate various control concepts that can be implemented using the python-control toolbox:

  • CDS 110, L1: Dynamics and Control of a Servomechanism System using Python-Control

  • CDS 110, L2: Nonlinear Dynamics (and Control) of an Inverted Pendulum System

  • CDS 110, L3: Python Tools for Analyzing Linear Systems

  • CDS 110, L4a: Dynamics and State Feedback Control of a Predator-Prey Model

  • CDS 110, L4b: LQR Tracking

  • CDS 110, L5: State Estimation for a Kinematic Car Model

  • CDS 110, L6a: Trajectory Generation for a Kinematic Car Model

  • CDS 110, L6b: Trajectory Tracking for a Kinematic Car

  • CDS 110, L6c: Receding Horizon Control of a Double Integrator with Bounded Input

  • CDS 110, L7: Frequency Domain Analysis using Bode/Nyquist plots

  • CDS 110, L8a: Fundamental Limits for Control of a Magnetic Levitation System

  • CDS 110, L8b: Full Controller Stack for a Planar Vertical Take-Off and Landing (PVTOL) System

  • CDS 110, L9: PID Control of a Servomechanism

  • CDS 112, L1: Introduction to the Python Control Systems Library (python-control)

  • CDS 112, L2a: Differential Flatness

  • CDS 112, L2b; Gain Scheduling

  • CDS 112, L3a: Linear quadratic optimal control example

  • CDS 112, L3b: Optimal Control

  • CDS 112, L4a: LQR Tracking Example

  • CDS 112, L4b: PVTOL Linear Quadratic Regulator Example

  • CDS 112, L5: RHC Example: Double integrator with bounded input

  • CDS 112, L6: Stochastic Response

  • CDS 112, L7: PVTOL LQR + EQF example

  • CDS 112, L8: Kinematic car sensor fusion example

  • CDS 112, L9: Moving Horizon Estimation

The notebooks are also be copied to Google Colab and the CDS 110 notebooks have a link at the top to the Colab version sitting in the fbsbook.org Google account (publicly accessible).

@murrayrm murrayrm changed the title initial commit of CDS 110, Winter 2024 lectures CDS 110 and CDS 112 Jupyter notebooks Aug 9, 2024
@coveralls
Copy link

coveralls commented Aug 9, 2024

Coverage Status

coverage: 94.694%. remained the same
when pulling 7915c91 on murrayrm:cds_examples-06Jul2024
into 373ff11 on python-control:main.

@murrayrm murrayrm mentioned this pull request Aug 9, 2024
11 tasks
Copy link
Member

Choose a reason for hiding this comment

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

make clean is generally useful, but make post does not seem to be, unless they configure gdrive and rclone similarly. I recommend adding a comment that other users may need to change GDRIVE for their own upload target.

states=('x', 'y', 'theta'))

#
# Utility function to plot lane change manuever
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Utility function to plot lane change manuever
# Utility function to plot lane change maneuver

plt.xlabel("Time $t$ [sec]")
plt.ylabel("$\\delta$ [rad]")

plt.suptitle("Lane change manuever")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
plt.suptitle("Lane change manuever")
plt.suptitle("Lane change maneuver")

Copy link
Member

Choose a reason for hiding this comment

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

  • "Moment of inertial" -> "Moment of inertia"
  • "loop dynamicsof" -> "loop dynamics of"
  • "for the system that that" -> "for the system that"
  • "the the process" -> "the process"
  • "connect everthing" -> "connect everything"
  • "for a referend trajectory" -> "for a reference trajectory"

@slivingston
Copy link
Member

I will finish reviewing this tonight.

@@ -7,7 +7,7 @@ Examples

The source code for the examples below are available in the `examples/`
subdirectory of the source code distribution. They can also be accessed online
via the [python-control GitHub repository](https://github.com/python-control/python-control/tree/master/examples).
via the `python-control GitHub repository <https://github.com/python-control/python-control/tree/master/examples>`_.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
via the `python-control GitHub repository <https://github.com/python-control/python-control/tree/master/examples>`_.
via the `python-control GitHub repository <https://github.com/python-control/python-control/tree/main/examples>`_.

doc/examples.rst Outdated
Google Colab Notebooks
======================

A collection of Jupyter notebooks are available on [Google Colab](),
Copy link
Member

Choose a reason for hiding this comment

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

Should [Google Colab]() be a link to somewhere? Also, []() is Markdown syntax, but this looks like a reStructuredText file.

@@ -179,6 +183,8 @@ def bode_plot(
Number of samples to use for the frequeny range. Defaults to
config.defaults['freqplot.number_of_samples']. Ignored if data is
not a list of systems.
phase_label : str, optional
Label to use for magnitude axis. Defaults to "Phase [rad]".
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Label to use for magnitude axis. Defaults to "Phase [rad]".
Label to use for phase axis. Defaults to "Phase [rad]".

Copy link
Member

Choose a reason for hiding this comment

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

  • The link to python-control is broken at the top of the document, due to a Markdown syntax error. It is ([python-control](https://python-control.org]) but should be ([python-control](https://python-control.org))
  • "to define and input/output" -> "to define an input/output"
  • "a response object, we can be used" -> "a response object, which can be used"

Copy link
Member

Choose a reason for hiding this comment

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

  • u = np.atleast_1d(u) can be deleted (it is the line with comment "Fix python-control bug"). This bug was at least fixed in commit f6f88f8, when the call to _rhs() was changed to ensure u is an array (np.asarray(u).reshape(-1)).
  • "the Lynx population" -> "the lynx population"

Copy link
Member

Choose a reason for hiding this comment

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

  • "sytem" -> "system"
  • "frequeny" -> "frequency"

Copy link
Member

Choose a reason for hiding this comment

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

The electromagnet diagram has a misprint: "receivier" -> "receiver". I do not know where that file can be changed, but the URL in the notebook is https://www.cds.caltech.edu/~murray/courses/cds110/sp2024/maglev-diagram.png

Copy link
Member

Choose a reason for hiding this comment

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

  • In code comments in section Estimator, "equiblirum" -> "equilibrium"
  • "if you plot" -> "if your plot"

Copy link
Member

Choose a reason for hiding this comment

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

Link to control docs in the section "More information..." is broken; try https://python-control.readthedocs.io/en/latest/ (which updates automatically with new releases) or http://python-control.org/ (currently redirects to the docs).

Copy link
Member

Choose a reason for hiding this comment

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

Markdown syntax mistake in first paragraph:

`BasisFamil`y

Also, in the section "Look inside the code", URL to flatsys.py should use main branch: https://github.com/python-control/python-control/blob/main/control/flatsys/flatsys.py
(redirect is automatic but somewhat distracting)

@murrayrm murrayrm merged commit 3d79ce3 into python-control:main Aug 11, 2024
23 checks passed
@murrayrm murrayrm deleted the cds_examples-06Jul2024 branch August 11, 2024 19:36
@murrayrm murrayrm added this to the 0.10.1 milestone Aug 17, 2024
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