skydy.configuration package

Submodules

skydy.configuration.BaseSymbols module

class skydy.configuration.BaseSymbols.BaseSymbols(name, identifier, is_coords=False)[source]

Bases: object

__init__(name, identifier, is_coords=False)[source]

The base object for this whole package to function. It defines the sympy symbols that are used in the modelling process, whether it be translational (x,y,z), rotational (theta_x, theta_y, theta_z) coordinates, positions within a reference frame, or the direction and magnitude of forces and torques, all the symbols are generated by various combinations of this object.

Later, we have specific object thats handle these scenarios for us, but all inherit from this class. s such, we never explicility use this class

Parameters
  • name (int or str) – the name for the symbols. This will form the superscript, i.e., the body the symbols refer to.

  • identifier (int or str) – gives meaning to the symbol set as it identifies what or where the symbol set refer to. For a set of coordinates, this is “G”, the centre of mass. For a force, torque or length it is F, tau and l respectively.

  • is_coords (int or str) – defines if a sextuple is defines (representing the 6 coordinates) of a body, or a triple (representing the three Cartesian coordinates).

Example

A coordinate representation of body named “1”, at its centre of mass, G.

>>> from skydy.configuration import BaseSymbols
>>> body_name = "1"
>>> body_loc = "G"
>>> body_symbols = BaseSymbols(body_name, body_loc, True)

A vector representation of force named “2”

>>> force_name = "2"
>>> force_id = "F"
>>> force_symbols = BaseSymbols(force_name, force_id)

A vector representation of distance, or dimension for a body named “1”

>>> dim_name = "1"
>>> dim_id = "l"
>>> dim_symbols = BaseSymbols(dim_name, dim_id)
as_dict()[source]

Get the dictionary of symbol-value pairs.

assign_values(values, idx=- 1)[source]

Assign value(s) to a symbol. By defualt, the value is instantiated as 1.

Parameters
  • values (array-like object, int or float) – the values we want to assign. This must be an array-like object of the len(self.__symbols), or an integer. If an integer is provided, a valid index must be provided.

  • idx (int) – for an int or float, the index to assign the value to. This must be a valid index in 0 to len(self.__symbols)-1.

Returns

None

Example

>>> from skydy.configuration import BaseSymbols
>>> base_symbols = BaseSymbols("1", "G")
>>> # Assign all values
>>> base_symbols.assign_values([10, 20, 30, 40, 50, 60])
>>> # Assign just one value
>>> base_symbols.assign_values(24, 4)
sym_to_np(sym_matrix)[source]

Convert a numeric sympy matrix, i.e., after substituting values, to a numpy matrix. We pass in the sympy matrix for flexbility down the line as to what we can and cannot convert.

Parameters

sym_matrix (sympy.matrices.dense.MutableDenseMatrix) – a sympy matrix, with values substituted in.

Returns

a numpy matrix of same dimensions of the input matrix.

Return type

np_matrix (numpy.ndarray)

Example

>>> from skydy.configuration import BaseSymbols
>>> base_symbols = BaseSymbols("1", "G")
>>> # Assign all values
>>> base_symbols.assign_values([10, 20, 30, 40, 50, 60])
>>> # Crete a matrix of symbols
>>> sym_mat = base_symbols.symbols()
>>> # Substitute the values in
>>> sym_mat = sym_mat.subs(base_symbols.as_dict())
>>> # Convert to an numpy.ndarray.
>>> np_mat = base_symbols.sym_to_np(sym_mat)
symbols()[source]

Get the sympy.matrices.dense.MutableDenseMatrix of the symbols.

values()[source]

Return a numpy.ndarray of the values. If the values are not assigned, they return an array of ones by default.

class skydy.configuration.BaseSymbols.CoordinateSymbols(name)[source]

Bases: skydy.configuration.BaseSymbols.BaseSymbols

__init__(name)[source]

A set of coordinate symbols, inheriting from the BaseSymbols class. Coordinate symbols are simply the translational (x,y,z) and rotational (theta_x, theta_y, theta_z) coordinates about the centre of mass of a body.

As expected, use the RIGHT HAND RULE to determine coordinate directions.

Fix your x-axis appropriately, and the rest comes for free.

Parameters

name (int, float or string) – the name of the body or object we want to generate coordinates for.

Returns

None

Example

>>> from skydy.configuration import CoordinateSymbols
>>> # Create a set of symbols
>>> body_name = 1
>>> body_coords = CoordinateSymbols(body_name)
positions()[source]

Returns the symbols of the positions (or coordinates) of the body.

velocities()[source]

Returns the velocities of the positions (or coordinates) of the body.

class skydy.configuration.BaseSymbols.DimensionSymbols(name)[source]

Bases: skydy.configuration.BaseSymbols.BaseSymbols

__init__(name)[source]

A set of dimension symbols, inheriting from the BaseSymbols class. Dimension symbols simply exist in x-, y-, z-coordinates. By default, these symbols are defined by l, or a length.

Parameters

name (int, float or string) – the name of the body or object we want to generate dimensions for.

Returns

None

Example

>>> from skydy.configuration import DimensionSymbols
>>> # Create a set of symbols
>>> body_name = 1
>>> body_dims = DimensionSymbols(body_name)
class skydy.configuration.BaseSymbols.ForceSymbols(name)[source]

Bases: skydy.configuration.BaseSymbols.BaseSymbols

__init__(name)[source]

A set of force symbols, inheriting from the BaseSymbols class. Force symbols simply exist in x-, y-, z-coordinates. By default, these symbols are defined by F, or a Force.

Parameters

name (int, float or string) – the name of the body or object we want to designate a force for.

Returns

None

Example

>>> from skydy.configuration import ForceSymbols
>>> # Create a set of symbols
>>> body_name = 1
>>> body_forces = ForceSymbols(body_name)
class skydy.configuration.BaseSymbols.TorqueSymbols(name)[source]

Bases: skydy.configuration.BaseSymbols.BaseSymbols

__init__(name)[source]

A set of torque symbols, inheriting from the BaseSymbols class. Torque symbols simply exist as rotations about the x-, y-, z-coordinates. By default, these symbols are defined by tau, or a Torque.

Parameters

name (int, float or string) – the name of the body or object we want to designate a Torque for.

Returns

None

Example

>>> from skydy.configuration import TorqueSymbols
>>> # Create a set of symbols
>>> body_name = 1
>>> body_torques = TorqueSymbols(body_name)

skydy.configuration.Configuration module

class skydy.configuration.Configuration.Configuration(name)[source]

Bases: skydy.configuration.BaseSymbols.CoordinateSymbols

__init__(name)[source]

A body’s configuration is nothing other than a description of its pose (where it is, and how it is oriented).

As such, it is decribed by a vector of positions, and a matrix of rotations. All bodies can have up to 6 DOFs, i.e., directions in which it can move.

By applying constraints, a body can have as little as zero DOFs.

A Configuration inherits from CoordinateSymbols, as it is solely related to a body’s name, and the 6 CoordinateSymbols that describe it.

Parameters

name (int or str) – the name for the symbols. This will form the superscript, i.e., the body the symbols refer to.

Returns

None

Example

Configuration for body named “1”.

>>> from skydy.configuration import Configuration
>>> body_name = "1"
>>> body_config = Configuration(body_name)
>>> # See the symbolic position and rotation of the body
>>> print(body_config.pos_body)
>>> print(body_config.rot_body)
accelerations()[source]

Returns the acceleration of the coordinates of the body.

apply_constraint(idx, const_value=0)[source]

Apply a coordinate constraint to the free configuration of the body. A constraint is nothing but a coordinate having constant value.

This indices for each coordinate are:

0 -> x 1 -> y 2 -> z 3 -> theta_x 4 -> theta_y 5 -> theta_z

Parameters
  • idx (int) – the index to apply the constriaint to.

  • const_value (int or float) – the constant value to substitute in for the coordinate at the index. Default value is zero.

Returns

None

Example

Constrain some coordinate for a body named “1”.

>>> from skydy.configuration import Configuration
>>> body_name = "1"
>>> body_config = Configuration(body_name)
>>> # Apply a translational constraint to the z-axis, at a height of 5 m.
>>> body_config.apply_constraint(2, 5)
>>> # Apply a rotational constraint about the y-axis
>>> body_config.apply_constraint(4, 0)
free_accelerations()[source]

Return a list of free accelerations for the body.

free_coordinates()[source]

Return a list of free coordinates for the body.

free_velocities()[source]

Return a list of free velocities for the body.

property pos_body
reset_constraints()[source]

Reset the constraints, i.e., remove any restrictions on movement.

In short, the position and rotation are the free configuration matrices determined on object instantiation.

property rot_body

Module contents