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

[WIP] Add examples from the Advanced Dynamics class at TU Delft #137

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

oliverlee
Copy link
Contributor

  • There are no merge conflicts.
  • A figure (preferrably SVG) has been added for the example.
  • The required versions of all dependencie have been noted. (For
    notebooks, the version information
    extension
    is helpful
    for this.)
  • A run.py file that executes the example is included.
  • All reviewer comments have been addressed.

I'm not sure if this branch should be used in the PR or the other.

Add additional kinetic energy terms (T) to check for equality.
Add x and y labels and legend for forces on cart axle of hw 8.4. Add eps
file for generation of latex file.
Add hyperref package to homework solution 8 tex file. Add solution for
problem 4, parts a through d. Solution for 4d is incomplete and does
not include calculation of constraint forces. Listings simulate_cart.m
and cart_equationsofmotion.m are missing necessary changes to problem 4.
In homework 8.4, find equations of motion of the cart using 3
generalized coordinates and a non-holonomic constraint in hw8.4.py.
Using the closed-form solution of lagrange multiplier lambda, fix
calculation of constraint forces on the cart axle in the x and y
directions in simulate_cart.m.
Add calculation of constrain forces. Add changed code in simulate_cart.m
and cart_equationsofmotion.m.
Add solved exercises from the Advanced Dynamics course at TU Delft.
Select problems from homework sets 2, 3, 4, 5, 7 and 8 are solved in
separate python files and the problem statements are provided in the
associated pdf files.
@moorepants
Copy link
Member

This is awesome. I think you by far now have the most examples :)

As I mentioned in chat, I'd rather not commit the pdfs. We should go ahead an just convert them to the format proposed here: #44 (comment)

@chrisdembia
Copy link
Contributor

Awesome! Can you clarify in a README file the name of the exact class this comes from?

@moorepants
Copy link
Member

FYI: Some notes on sharing this from the course instructors.

Oliver:

While TAing the class, I wrote some python code to solve homework problems which I keep in a repository here:
https://github.com/oliverlee/advanced_dynamics

Jason has asked if I we could include the code and a pdf of the problem statement in this repository:
https://github.com/pydy/pydy/tree/master/examples

Please let me know if you do not want the homework problems posted online (or if you want me to remove the existing python solutions)

Arend:

Hi Oliver,

Nice. Please do, I have no problem with that.

Yours,

-Arend L. Schwab

Heike:

Hi Oliver,

yes this is nice. I cannot check or endorse correctness, but I have no objections agains providing the material openly (please indicate the source of the problems though, so our course). You can also also add my own code that I provided to students on Blackboard, for homework 8.

Best

Heike

@oliverlee
Copy link
Contributor Author

Should this README go in the advanced_dynamics directory or one of the higher level directories?

@moorepants
Copy link
Member

Can we make examples/tu_delft_class (choose better more informative name) and then one dir per problem examples/tu_delft_class/hw01? Then each problem dir can contain a notebook, the script, and the image. A README in the examples/tu_delft_class can give some context.

@oliverlee
Copy link
Contributor Author

Sure but it'll probably be a few days until I get around it.

@moorepants
Copy link
Member

NP, Like I said. I'll give you a hand with this too. I may not be able to get to it properly to till the weekend though.

@oliverlee oliverlee self-assigned this Feb 10, 2015
@moorepants
Copy link
Member

Or should we just make a top level example directory for each problem? If the problems are independent from one another it migth be better to do that. We are eventually going to scrape each directory in pydy/examples to generate the gallery on the website. If we have one dir per unique example problem, then the scraping will be a bit easier to manage.

@oliverlee
Copy link
Contributor Author

Are we planning to do that for the Kane1985 examples?

@moorepants
Copy link
Member

I'm not sure yet how to deal with the kane examples. It would be nice to put that in a format that is more digestible without having the book. For now, no I guess, but if someone wants to morph those examples into something better, that would be be great.

@oliverlee
Copy link
Contributor Author

Please take a look here:
https://github.com/oliverlee/pydy/tree/feature-reformat-tud-examples
and let me know how I can improve this. I'm also not sure how to display an eps file. Do any of you?

Also, be aware that I (somewhat) frequently force push to my topic branches.

@moorepants
Copy link
Member

@moorepants
Copy link
Member

@oliverlee Looks great!

Some notes:

  • If you use the string phi instead of ψ when defining your symbols, then they will be rendered properly in Python 2 or 3 and can make use of SymPy's printing infrastructure better.
  • Use sympy.init_printing() instead of mprint or better yet, you can use sympy.physics.vector.init_vprinting() for some of the niceties from mprint. All the LaTeX will then render normally.
  • Use the 'markdown' cell type for the text so that it gets rendered nicely. I'm seeing a nb raw convert when I open you notebook.
  • You don't have to spend all of the time creating the really nice notebooks. I would say the quickest (and maybe dirtiest) way to convert your examples is this:
    1. Create a notebook.
    2. Copy the text from the pdf into one markdown cell and reformat a little to get the math correct.
    3. Use Shutter to take a png screenshot of the image in the pdf and save that to the directory. Then use the IPython display functionality to render it in the notebook.
    4. Use the `%load magic to load the code from your script into the notebook.
      That would be the bare minimum way to go but least time consuming. Then if you want to spend time making the notebooks all fancy and dialed and explain each step, you can later. But this would give us minimal working examples that we can load in to the upcoming example gallery. I will do one of the problems this way to see if you like it.

@moorepants
Copy link
Member

Were you able to get the source files from them? If they wrote these in LaTeX you can use pandoc to convert them to markdown...

@moorepants
Copy link
Member

@oliverlee here is my proposed method: http://nbviewer.ipython.org/github/moorepants/pydy/blob/jasons-example/examples/advanced_dynamics/hw3.ipynb

I haven't formatted the math completely. If you can get the source files for the pdf docs, then we can autoconvert the whole thing to markdown and not have to do any manual retyping.

@oliverlee
Copy link
Contributor Author

The source for the problem statements is available so I'll take a look tomorrow.

@moorepants
Copy link
Member

@oliverlee So I used this pandoc -o hw.md HW_AD_2.tex on the tex file you sent me and it converts it to markdown which can then be more easily pasted into the notebooks. Note that I had to remove German characters on the \fancyhf{} line (in the comment) otherwise pandoc was complaining about a UTF-8 encoding issue. The markdown is:

![image](TU_d_line_P1_full_color.eps)

**Main Instructor:** Dr.-Ing. Heike Vallery **Homework Coordinator:**
Dr. ir. Arend L. Schwab

**Date:** 08-Sept-2014

**Deadline: ** Before lecture on Sept 15.

<span>**:**</span>

-   Show all work, clearly and in order, if you want to get full credit.

-   Follow the homework rules as published on Blackboard.

-   Justify your answers algebraically whenever possible to ensure full
    credit. Sketch all relevant graphs.

-   Circle or otherwise indicate your final answers.

-   Clearly distinguish between scalars and vectors, for example by
    underlining vectors ($\underline{x}$) and not underlining scalars
    ($x$). **If you use another notation, define it like this**: A
    vector will be written as ........, a scalar will be written as
    ........

-   Success!

<span>15</span> FRAME MAPPING

Consider an inertial reference coordinate system XYZ. Two further, local
Cartesian coordinate systems are given: $uvy$ and $rst$. Expressed in
the XYZ system, the unit vectors of the two local coordinate systems
are:

$$\boldsymbol{u} =
\frac{1}{3}
\begin{pmatrix}
1\\2\\-2
\end{pmatrix},
\boldsymbol{v} =
\frac{1}{\sqrt{2}}
\begin{pmatrix}
0\\1\\1
\end{pmatrix},
\boldsymbol{w}=\frac{1}{3\sqrt{2}}
\begin{pmatrix}
4\\-1\\1
\end{pmatrix}$$

and

$$\boldsymbol{r}=
\frac{1}{4}
\begin{pmatrix}
3\\-2\\ \sqrt{3}
\end{pmatrix}
,
\boldsymbol{s}=
\frac{1}{{2}}
\begin{pmatrix}
-1\\0\\ \sqrt{3}
\end{pmatrix}
,
\boldsymbol{t}=
\frac{-1}{4}
\begin{pmatrix}
\sqrt{3}\\ 2\sqrt{3}\\1
\end{pmatrix}$$

Find the rotation matrix that describes the orientation of the $uvw$
frame relative to the $rst$ frame, and the rotation matrices that map
vectors in the $XYZ$ frame into respective $uvw$ or $rst$ frame vectors.

<span>30</span> <span>MODEL PLANE</span>

![A model plane suspended from the ceiling.
](figures/modelplane.eps "fig:") [fig:modelplane]

A model plane is suspended from the ceiling of a room by a spring. The
spring has a resting length of $l_0$. The attachment point $A$ at the
ceiling is the origin of the fixed $XYZ$ coordinate system. The
coordinates of the attachment point $P$ on the plane are given as
($p_x$, 0, $p_z$) in the local $xyz$ coordinate system that is fixed to
the plane. Assuming that the plane’s orientation with respect to the
$XYZ$ coordinate system is described by type I Euler angles, with
$\psi=\pi$, $\theta=\pi/3$, and $\phi=-\pi/4$, and that the origin of
the plane’s local coordinate system is at the position $S$, with
coordinates $s_X$, $s_Y$, and $s_Z$ in the global $XYZ$ coordinate
system, find the potential energy momentarily stored in the spring in
function of the given parameters.

<span>30</span> GYRO BACKPACK

Falls are among the most frequent causes of hospitalization and death
among the elderly. A key factor leading to falls is degraded balance
control capability. At TU Delft, we are investigating a wearable robotic
solution for patients with balance disorders, which is based on an
assembly of control moment gyroscopes that is mounted onto the upper
body via a backpack. This assembly of gyroscopes can generate a
controllable moment vector on the person.

In this problem, we will consider the movement of the human
(Fig. [fig:flywheel~b~alance]), pivoting about the ankle joint while
standing on a flat surface.

![Gyroscopic support for human balance. The directions $x,y$, and $z$
are defined with respect to an inertial frame, with $z$ pointing
vertical. The directions $x',y'$, and $z'$ are defined with respect to
the human trunk, with $x'$ pointing in anterior direction, which is
aligned with the $x$ axis if all angles are zero, and $z'$ pointing
along the human’s longitudinal axis. Successive rotations by the Euler
angles $\phi$, $\theta$, and $\psi$ map the $x,y,z$ coordinate system to
the $x',y',z'$ coordinate system.
](figures/Gyroscope_Illustrations_final.eps "fig:")
[fig:flywheel~b~alance]

The origin of the body-fixed coordinate system is in the center of mass
of the body.

At a certain instant in time which we call $t=0$, the orientation of the
body-fixed coordinate system expressed in the global $xyz$ reference
system is given by $\mathbf{e}'_x=(0.7615  , -0.6304 ,  -0.1504)$,
$\mathbf{e}'_y=( 0.6454  ,  0.7589  ,  0.0868)$, and
$\mathbf{e}'_z=(  0.0594  , -0.1632  ,  0.9848 )$.

The initial angular velocity vector at $t=0$ expressed in the global
reference coordinate system is given by
$\boldsymbol{\omega}=(  -0.0297 ,   0.0816  , -0.4924  )$ rad/s. Draw a
cans-in-series representation as equivalent alternative for
Fig. [fig:flywheel~b~alance], right.

Determine for $t=0$ the rotation matrix $\mathbf{R}$ which transforms
the body-fixed coordinates $\boldsymbol{x}'$ into the reference system
coordinates $\boldsymbol{x}$ as in
$\boldsymbol{x}=\mathbf{R}\boldsymbol{x}'$.

Determine for $t=0$ from this $\mathbf{R}$ the associated Euler angles
(zxz) $\phi$, $\theta$, and $\psi$.

Determine for $t=0$ the angular velocity vector $\boldsymbol{\omega}'$
expressed in the body-fixed coordinate system.

Determine for $t=0$ the rate of change of the Euler angles:
$(\dot\phi, \dot\theta,\dot\psi)$.

<span>25</span> <span>BRYANT ANGLES</span>

Yet another way of describing orientation by Euler angles are the
so-called Bryant angles. Here we follow the notation used by Greenwood
Ch3.1. The order of rotation for Bryant angles is as follows: (1)
$\alpha$ about the $X$-axis; (2) $\beta$ about the $y'$-axis; (3)
$\gamma$ about the $z''$-axis.

Derive the overall rotation matrix $\mathbf{C}$ for these Bryant angles.

Express the time derivates of these Bryant angles in terms of the Bryant
angles $\alpha$, $\beta$, $\gamma$, and the components of the absolute
angular velocity $\omega_x$, $\omega_y$ and $\omega_z$.

At which set of Bryant angles does the singular configuration occur?
Draw a figure to check this result.

So this should help with the translation a bit.

@jcrist
Copy link
Member

jcrist commented Feb 15, 2015

Notebook version looks great!

@oliverlee
Copy link
Contributor Author

Thanks. I'll work on converting the rest when I have time during the week.

@moorepants
Copy link
Member

@oliverlee See the latest here: #44

Let's not try to convert all these to notebooks. We can leave them as scripts. We will support a script based example and notebook based one. How bout that?

@oliverlee
Copy link
Contributor Author

Ah sorry. Been busy and forgot to finish these.
On Mar 6, 2015 6:10 AM, "Jason K. Moore" notifications@github.com wrote:

@oliverlee https://github.com/oliverlee See the latest here: #44
#44

Let's not try to convert all these to notebooks. We can leave them as
scripts. We will support a script based example and notebook based one. How
bout that?


Reply to this email directly or view it on GitHub
#137 (comment).

@moorepants
Copy link
Member

That's fine. It's just quite time consuming to convert them all. If you want to do that, fine but we are going to draft 2 example templates. One for notebooks and one for pure scripts. The scripts should include an image of the system + some text description + the scripts. You have that here.

I feel like we should commit png's (or raw latex) to the repo though. I don't feel that committing all the pdf's is a good idea because we can't utlimately render it with a web browser.

@moorepants moorepants changed the title Add examples from the Advanced Dynamics class at TU Delft [WIP] Add examples from the Advanced Dynamics class at TU Delft May 6, 2015
@oliverlee oliverlee closed this Oct 7, 2015
@oliverlee oliverlee deleted the dev branch October 7, 2015 15:22
@moorepants
Copy link
Member

I hope you leave this in here. I may have some students that can work on the examples improvements coming in the winter quarter.

@oliverlee oliverlee restored the dev branch October 7, 2015 15:43
@oliverlee oliverlee reopened this Oct 7, 2015
@oliverlee
Copy link
Contributor Author

Github now displays pdfs so I guess we can just leave them in?

@moorepants
Copy link
Member

Yeh, we can leave this in for now. I just have a dream of creating an example gallery on our website akin to matplotlib's and we'll need web friendly things to include in the online material.

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.

None yet

4 participants