Skip to content

Commit

Permalink
Merge pull request #155 from moorepants/update-nonholo-eom
Browse files Browse the repository at this point in the history
Update the nonholonomic equation of motion chapter
  • Loading branch information
moorepants authored May 11, 2023
2 parents b858aa0 + 9384e19 commit 4f2f30a
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 13 deletions.
51 changes: 38 additions & 13 deletions nonholonomic-eom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Equations of Motion with Nonholonomic Constraints
=================================================

.. warning:: This page as not yet been updated for the 2022-2023 course.

.. note::

You can download this example as a Python script:
Expand Down Expand Up @@ -42,6 +40,18 @@ Equations of Motion with Nonholonomic Constraints
**kwargs)
me.ReferenceFrame = ReferenceFrame
Learning Objectives
===================

After completing this chapter readers will be able to:

- formulate the :math:`p` dynamical differential equations for a nonholonomic system
- simulate a nonholonomic multibody system
- calculate trajectories of dependent speeds

Introduction
============

In chapters, :ref:`Holonomic Constraints` and :ref:`Nonholonomic Constraints`,
I introduced two types of constraints: holonomic (configuration) constraints
and nonholonomic (motion) constraints. Holonomic constraints are nonlinear
Expand All @@ -52,9 +62,6 @@ of motion first, as they are slightly easier to deal with.
.. [#] They can be linear in the coordinates, but then there is little reason
not to solve for the depedendent coordinates and eliminate them.
Nonholonomic Equations of Motion
================================

Nonholonomic constraint equations are linear in both the independent and
dependent generalized speeds (see Sec. :ref:`Snakeboard`). We have shown that
you can explicitly solve for the dependent generalized speeds :math:`\bar{u}_r`
Expand All @@ -73,7 +80,15 @@ and :math:`u_r` can be solved for as so:
.. math::
:label: eq-dep-speeds-solve
\bar{u}_r = -\mathbf{M}_n(\bar{q}, t)^{-1}\bar{g}_n(\bar{u}_s, \bar{q}, t) \\
\bar{u}_r = -\mathbf{M}_n(\bar{q}, t)^{-1}\bar{g}_n(\bar{u}_s, \bar{q}, t)
which is the same as Eq. :math:numref:`eq-contraint-linear-form-solve` we
originally developed:

.. math::
:label: eq-dep-speeds-repeat
\bar{u}_r = \mathbf{A}_n \bar{u}_s + \bar{b}_n\\
Using Eq. :math:numref:`eq-dep-speeds-solve` equation we can now write our
equations of motion as :math:`n` kinematical differential equations and
Expand All @@ -93,6 +108,11 @@ and these can be written in explicit form:
\dot{\bar{q}} = -\mathbf{M}_k(\bar{q}, t)^{-1} \bar{g}_k(\bar{u}_s, \bar{q}, t) \\
\dot{\bar{u}}_s = -\mathbf{M}_d(\bar{q}, t)^{-1} \bar{g}_d(\bar{u}_s, \bar{q}, t) \\
This leaves us with :math:`n+p` equations of motion, instead of :math:`2n`
equations seen in a holonomic system. Nonholonomic constraints reduce the
number of degrees of freedom and thus fewer dynamical differential equations
are necessary to fully describe the motion.

Snakeboard Equations of Motion
==============================

Expand All @@ -104,6 +124,7 @@ inertia of the three bodies are the same.

.. figure:: figures/motion-snakeboard.svg
:align: center
:width: 80%

Configuration diagram of a planar Snakeboard model.

Expand Down Expand Up @@ -150,7 +171,11 @@ expressions we create.
urd_zero = {udi: 0 for udi in urd}
usd_zero = {udi: 0 for udi in usd}

qd_zero, ur_zero, us_zero, urd_zero, usd_zero
qd_zero, ur_zero, us_zero

.. jupyter-execute::

urd_zero, usd_zero

2. Establish the kinematics
---------------------------
Expand Down Expand Up @@ -477,19 +502,19 @@ coordinates.
We now have :math:`\mathbf{M}_k, \bar{g}_k, \mathbf{M}_d` and :math:`\bar{g}_d`
and can proceed to numerical evaluation.

.. todo:: Also show how Fr and Frs can be formed using An.

Simulate the Snakeboard
=======================

We now move to numerical evaluation for the simulation. First, create a
function that evaluates the matrices of the equations of motion.

.. todo:: lambdify(cse=True) fail for this. Open an issue on SymPy.

.. todo:: sm.Matrix.count_ops() doesn't seem like it exists. Open an issue.

.. jupyter-execute::

eval_kd = sm.lambdify((q, us, p), (Mk, gk, Md, gd))
eval_kd = sm.lambdify((q, us, p), (Mk, gk, Md, gd), cse=True)

Now create a function that evaluates the right hand side of the explicit
ordinary differential equations for use with ``solve_ivp()``.
Expand Down Expand Up @@ -563,7 +588,7 @@ later use in the animation of the motion.

.. jupyter-execute::

t0, tf = 0.0, 10.0
t0, tf = 0.0, 8.0

.. jupyter-execute::

Expand Down Expand Up @@ -638,7 +663,7 @@ the points we want to plot given the generalized coordinates.
for point in [Co, Cr, Co, Ao, Bo, Bl, Br]:
coordinates = coordinates.row_join(point.pos_from(O).to_matrix(N))

eval_point_coords = sm.lambdify((q, p), coordinates)
eval_point_coords = sm.lambdify((q, p), coordinates, cse=True)
eval_point_coords(q0, p_vals)

Now create a plot of the initial configuration:
Expand Down Expand Up @@ -699,7 +724,7 @@ the constraint equations. Here I loop through time to calculate
.. jupyter-execute::

x = sm.Matrix([q1, q2, q3, q4, q5, u3, u4, u5])
eval_ur = sm.lambdify((x, p), ur_sol)
eval_ur = sm.lambdify((x, p), ur_sol, cse=True)

ur_vals = []
for xi in xs:
Expand Down
37 changes: 37 additions & 0 deletions notation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ Angular and Translational Kinematics
Constraints
===========

.. todo:: Add Y_k, kin diff eqs.

:math:`N,M,n,m,p`
:math:`N` coordinates, :math:`M` holonomic constraints, :math:`n`
generalized coordinates and generalized speeds, :math:`m` nonholonomic
Expand All @@ -101,6 +103,21 @@ Constraints
:math:`\bar{f}_n(u_1, \ldots, u_n, q_1, \ldots, q_n, t) = 0 \textrm{ where } \bar{f}_n \in \mathbb{R}^m`, ``fn``
Vector function of :math:`m` nonholonomic constraint equations among the
:math:`n` generalized speeds and generalized coordinates.
:math:`\mathbf{A}_r`
Linear coefficient matrix for :math:`\bar{u}_r` in the nonholonomic
constraint equations.
:math:`\mathbf{A}_s`
Linear coefficient matrix for :math:`\bar{u}_s` in the nonholonomic
constraint equations.
:math:`\bar{b}_{rs}`
Terms not linear in :math:`\bar{u}_s` or :math:`\bar{u}_r` in the
nonholonomic constraint equations.
:math:`\mathbf{A}_n`
Linear coefficient matrix for :math:`\bar{u}_s` in the equation for
:math:`\bar{u}_r=\mathbf{A}_n\bar{u}_s + \bar{b}_n`.
:math:`\bar{b}_n`
Terms not linear in :math:`\bar{u}_s` in the equation for
:math:`\bar{u}_r=\mathbf{A}_n\bar{u}_s + \bar{b}_n`.

Mass Distribution
=================
Expand Down Expand Up @@ -194,6 +211,26 @@ Unconstrained Equations of Motion
:math:`\bar{g}_m`
Terms not linear in :math:`\dot{\bar{x}}` in the equations of motion.

Equations of Motion with Nonholonomic Constraints
=================================================

:math:`\bar{f}_n(\bar{u}_s, \bar{u}_r, \bar{q}, t) = 0`
Nonholonomic constraint equations.
:math:`\mathbf{M}_n=\mathbf{A}_r`
Linear coefficient matrix for :math:`\bar{u}_r` in the nonholonomic
constraint equations.
:math:`\bar{g}_n=\mathbf{A}_s\bar{u}_s+\bar{b}_{rs}`
Terms not linear in :math:`\bar{u}_r` in the nonholonomic constraint
equations.
:math:`\dot{\bar{f}}_n(\dot{\bar{u}}_s, \dot{\bar{u}}_r, \bar{u}_s, \bar{u}_r, \bar{q}, t) = 0`
Time derivative of the nonholonomic constraint equations.
:math:`\mathbf{M}_{nd}`
Linear coefficient matrix for :math:`\dot{\bar{u}}_r` in the time
differentiated nonholonomic constraint equations.
:math:`\bar{g}_{nd}`
Terms not linear in :math:`\dot{\bar{u}}_r` in the time differentiated
nonholonomic constraint equations.

.. |notation-scalar| image:: figures/notation-scalar.svg
:height: 10px

Expand Down

0 comments on commit 4f2f30a

Please sign in to comment.