Skip to content
Peter Corke edited this page Aug 2, 2020 · 4 revisions

Naming principles:

Variant constructors

All classes have constructors that accept a small number of different types, typically:

  • no arguments, create a null value (eg. null rotation, null pose etc.)
  • same type argument, clone the argument
  • native value, eg. numpy array or list
  • parametric representation, eg. x, y, θ
  • lists of native values or parametric representations, initialise the internal list

To handle different parameteric representations we use class methods as alternative constructors, for example:

  • SO3.RPY(roll, pitch, yaw)
  • SO3.Eul(phi, theta, psi)
  • SO3.AngVec(angle, vector)
  • SO3.Exp(twist)

These are methods on the class and are capitalised or have an initial capital letter.

Conversions

These are methods on an instance and convert to a different parameterisation, for example:

  • x.rpy() convert SO3 or SE3 to roll-pitch-yaw angles
  • x.eul() convert to Euler angles

While they have similar names to the variant constructors:

  • they perform an inverse function, the constructors are parameters → object, while the converters are object → parameters
  • there can be no ambiguity since converters operators on instances whereas constructors operate on classes

Converters are always methods, since they may accept parameters.

The .A property

A is for "array" and is the underlying NumPy representation of the type, a matrix for SO2, SE2, SO3 and SE3, or a vector for Twist2, Twist, Plane and Plucker.

Properties vs methods

Operator overload

For most types the arithmetic operators *, /, +, - and ** are overloaded. Some general principles:

  • Some inplace operations are supported, ie. *= and /= using the dunder methods __iXXX___
  • If operations is commutative the operator support this, eg. a * b or b * a are equivalent
  • If the result of an operation is not in the group the result will be a numpy array
  • The operation performed depends on the types of the left and right operands
  • Each class supports its own operators
  • For operations that involve different types, the support is implemented by the left-hand class

Supported list operations

  • reverse
  • append
  • extend
  • insert
  • len
  • clear
  • pop

Other standard list operations are not supported since they make little sense in this context: count, index, sort, remove