MATLAB code

This MATLAB code is documented with Sphinx using the matlabdomain extension.

src


src module contains the following source code files:

src.main

Main function

Example on the application of Lie group integrators for the solution of the equations of motion of a multibody system, August 2022, Andrea Leone @ NTNU

Ref.: E. Celledoni, E. Çokaj, A. Leone, D. Murari, B. Owren. “Lie group integrators for mechanical systems”, International Journal of Computer Mathematics, 99:1, 58-88.


src/integrators


src.integrators.LieEuler(vector_field, exponential, action, p, h, sigma0, trajectory, t)

Lie-Euler time integrator (Runge-Kutta-Munthe-Kaas method of order 1)

Parameters:
  • vector_field – right hand side of the ODE [type: function handle]

  • exponential – exponential map from the Lie algebra to the Lie group [type: function handle]

  • action – Lie group action [type: function handle]

  • p – solution at time t_n [type: float, 3x14 matrix]

  • h – time step size [type: float]

  • sigma0 – initial value of the curve sigma on the Lie algebra [type: float, 30x1 vector]

  • trajectory – desired trajectory [type: function handle]

  • t – discrete time t_n [type: float]

Returns:

solution at time t_(n+1) [type: float, 3x14 matrix]


src.integrators.RKMK2Heun(vector_field, exponential, action, p, h, sigma0, trajectory, t)

Runge-Kutta-Munthe-Kaas time integrator order 2, based on the Heun scheme

Parameters:
  • vector_field – right hand side of the ODE [type: function handle]

  • exponential – exponential map from the Lie algebra to the Lie group [type: function handle]

  • action – Lie group action [type: function handle]

  • p – solution at time t_n [type: float, 3x14 matrix]

  • h – time step size [type: float]

  • sigma0 – initial value of the curve sigma on the Lie algebra [type: float, 30x1 vector]

  • trajectory – desired trajectory [type: function handle]

  • t – discrete time t_n [type: float]

Returns:

solution at time t_(n+1) [type: float, 3x14 matrix]


src.integrators.RKMK3(vector_field, exponential, action, p, h, sigma0, trajectory, t)

Runge-Kutta-Munthe-Kaas time integrator order 3

Parameters:
  • vector_field – right hand side of the ODE [type: function handle]

  • exponential – exponential map from the Lie algebra to the Lie group [type: function handle]

  • action – Lie group action [type: function handle]

  • p – solution at time t_n [type: float, 3x14 matrix]

  • h – time step size [type: float]

  • sigma0 – initial value of the curve sigma on the Lie algebra [type: float, 30x1 vector]

  • trajectory – desired trajectory [type: function handle]

  • t – discrete time t_n [type: float]

Returns:

solution at time t_(n+1) [type: float, 3x14 matrix]


src.integrators.RKMK4

Runge-Kutta-Munthe-Kaas time integrator order 4

Parameters:
  • vector_field – right hand side of the ODE [type: function handle]

  • exponential – exponential map from the Lie algebra to the Lie group [type: function handle]

  • action – Lie group action [type: function handle]

  • p – solution at time t_n [type: float, 3x14 matrix]

  • h – time step size [type: float]

  • sigma0 – initial value of the curve sigma on the Lie algebra [type: float, 30x1 vector]

  • trajectory – desired trajectory [type: function handle]

  • t – discrete time t_n [type: float]

Returns:

solution at time t_(n+1) [type: float, 3x14 matrix]


src.integrators.CFree4(f, action, exponential, h, p, trajectory, t)

Commutator-free time integrator of order 4

Parameters:
  • f – map f from the phase space (on which the vector field is defined) to the Lie algebra [type: function handle]

  • action – Lie group action [type: function handle]

  • exponential – exponential map from the Lie algebra to the Lie group [type: function handle]

  • h – time step size [type: float]

  • p – solution at time t_n [type: float, 3x14 matrix]

  • trajectory – desired trajectory [type: function handle]

  • t – discrete time t_n [type float]

Returns:

solution at time t_(n+1) [type: float, 3x14 matrix]


src/lie_group_functions


src.lie_group_functions.hat(v)

It returns the skew symmetric matrix A associated to the vector v, such that hat(a)b=axb for all 3-component vectors a and b, with “x” the cross product

Parameters:

v – vector with 3 components

Returns:

element of the Lie algebra so(3) (skew symmetric 3x3 matrix)


src.lie_group_functions.invhat(A)

Inverse of the hat function

Parameters:

A – element of the Lie algebra so(3) (skew symmetric 3x3 matrix)

Returns:

3x1 column vector v


src.lie_group_functions.expSO3(x)

Exponential map on SO(3)

Parameters:

input – element of the lie algebra so(3), represented as a vector with 3 components.

Returns:

element of the group SO(3), i.e. 3x3 rotation matrix


src.lie_group_functions.expSE3(input)

Exponential map on SE(3)

Parameters:

input – element of the lie algebra se(3) represented as 6-component vector, i.e. as a pair (u,v) with with the 3-component vector u corresponding to a skew symmetric matrix hat(u) and the 3-component vector v corresponding to the translational part.

Returns:

element of the group SE(3), represented as a 3x4 matrix [A, b], with A 3x3 rotation matrix and b 3-component translation vector.


src.lie_group_functions.dexpinvSO3(v, input)

Inverse of the derivative of the exponential map on SO(3)

Parameters:
  • v – element in the lie algebra so(3), represented as a 3x1 vector

  • input – element in the lie algebra so(3), represented as a 3x1 vector

Returns:

inverse of dexp_v(input) as 3x1 vector


src.lie_group_functions.dexpinvSE3(sigma, input)

Inverse of the derivative of the exponential map on SE(3)

Parameters:
  • sigma – element in the lie algebra se(3), represented as a 6x1 vector

  • input – element in the lie algebra se(3), represented as a 6x1 vector

Returns:

inverse of dexp_sigma(input) as 6x1 vector


src/pre_post_processing


src.pre_post_processing.preprocess

Preprocessing : definition and inizialization of support variables to plot errors and trajectories


src.pre_post_processing.postprocess

Postprocessing: update of support variables to plot errors and real time plot of the tracking problem


src.pre_post_processing.plots

plots


src/control_functions


src.control_functions.controls(m1, m2, my, L1, L2, J1, J2, B, trajectory)

Main function used to define the control functions


src.control_functions.getUpar(m1, m2, my, L1, L2, B, trajectory)

Support function used to define the control functions and the vector field


src.control_functions.getUperp(m1, m2, my, L1, L2, B, trajectory)

Support function used to define the control functions and the vector field


src.control_functions.deriv1(v, vdot)

Support function used to define the control functions

Parameters:
  • v – vector

  • vdot – time derivative of vector v

Returns:

time derivative of the vector v divided by the norm of v


src.control_functions.deriv2(v, vdot, v2dot)

Support function used to define the control functions

Parameters:
  • v – vector

  • vdot – time derivative of vector v

  • v2dot – second time derivative of vector v

Returns:

time derivative of the output of deriv1


src.control_functions.deriv3(v, vdot, v2dot, v3dot)

Support function used to define the control functions

Parameters:
  • v – vector

  • vdot – time derivative of vector v

  • v2dot – second time derivative of vector v

  • v3dot – third time derivative of vector v

Returns:

time derivative of the output of deriv2


src.control_functions.deriv4(v, vdot, v2dot, v3dot, v4dot)

Support function used to define the control functions

Parameters:
  • v – vector

  • vdot – time derivative of vector v

  • v2dot – second time derivative of vector v

  • v3dot – third time derivative of vector v

  • v4dot – fourth time derivative of vector v


src.control_functions.derivhatq2w(q, w, qdot, wdot)

Support function used to define the control functions


src.control_functions.deriv2hatq2w(q, w, qdot, wdot, q2dot, w2dot)

Support function used to define the control functions


src.control_functions.deriv3hatq2w(q, w, qdot, wdot, q2dot, w2dot, q3dot, w3dot)

Support function used to define the control functions


src.control_functions.deriv4hatq2w(q, w, qdot, wdot, q2dot, w2dot, q3dot, w3dot, q4dot, w4dot)

Support function used to define the control functions