Module: robotics.motion

functionality for motion including generation of trajectories with acceleration profiles, path planning and motion

  • Author: Johannes Gerstmayr

  • Date: 2022-02-16

CLASS ProfileConstantAcceleration (in module robotics.motion)

class description:

class to create a constant acceleration (optimal) PTP trajectory; trajectory ignores global max. velocities and accelerations

  • input:
    finalCoordinates: list or numpy array with final coordinates for profile
    duration: duration (time) for profile
  • output:
    returns profile object, which is then used to compute interpolated trajectory

Class function: __init__

__init__(self, finalCoordinates, duration)

  • classFunction:
    initialize ProfileConstantAcceleration with vector of final coordinates and duration (time span)

Class function: GetBasicProfile

GetBasicProfile(self, initialTime, initialCoordinates, globalMaxVelocities, globalMaxAccelerations)

  • classFunction:
    return a class representing profile which is used in Trajectory

Relevant Examples (Ex) and TestModels (TM) with weblink to github:

CLASS ProfileLinearAccelerationsList (in module robotics.motion)

class description:

class to create a linear acceleration PTP profile, using a list of accelerations to define the profile; the (joint) coordinates and velocities are computed relative to values of previous profiles; ignores global max. accelerations and velocities of Trajectory

  • input:
    accelerationList: list of tuples (relativeTime, accelerationVector) in which relativeTime is the time relative to the start of the profile (first time must be zero!) and accelerationVector is the list of accelerations of this time point, which is then linearly interpolated
  • output:
    returns profile object, which is then used to compute interpolated trajectory in class Trajectory
  • example:
profile = ProfileLinearAccelerationsList([(0,[0.,1.,2]), (0,[1.,1.,-2])])

Class function: __init__

__init__(self, accelerationList)

  • classFunction:
    initialize ProfileLinearAccelerationsList with a list of tuples containing time and acceleration vector

Class function: GetBasicProfile

GetBasicProfile(self, initialTime, initialCoordinates, globalMaxVelocities, globalMaxAccelerations)

  • classFunction:
    return a class representing profile which is used in Trajectory

CLASS ProfilePTP (in module robotics.motion)

class description:

class to create a synchronous motion PTP trajectory, using max. accelerations and max velocities; duration automatically computed

  • input:
    finalCoordinates: list or numpy array with final coordinates for profile
    maxVelocities: list or numpy array with maximum velocities; may be empty list []; used if smaller than globalMaxVelocities
    maxAccelerations: list or numpy array with maximum accelerations; may be empty list []; used if smaller than globalMaxAccelerations
  • output:
    returns profile object, which is then used to compute interpolated trajectory

Class function: __init__

__init__(self, finalCoordinates, syncAccTimes = True, maxVelocities = [], maxAccelerations = [])

  • classFunction:
    initialize ProfilePTP with final coordinates of motion, optionally max. velocities and accelerations just for this profile (overrides global settings)

Class function: GetBasicProfile

GetBasicProfile(self, initialTime, initialCoordinates, globalMaxVelocities, globalMaxAccelerations)

  • classFunction:
    return a class representing profile which is used in Trajectory

Relevant Examples (Ex) and TestModels (TM) with weblink to github:

CLASS Trajectory (in module robotics.motion)

class description:

class to define (PTP) trajectories for robots and multibody systems; trajectories are defined for a set of coordinates (e.g. joint angles or other coordinates which need to be interpolated over time)

  • example:
#create simple trajectory for two joint coordinates:
traj = Trajectory(initialCoordinates=[1,1], initialTime=1)
#add optimal trajectory with max. accelerations:
traj.Add(ProfileConstantAcceleration([2.,3.],2.))
traj.Add(ProfileConstantAcceleration([3.,-1.],2.))
#add profile with limited velocities and accelerations:
traj.Add(ProfilePTP([1,1],syncAccTimes=False, maxVelocities=[1,1], maxAccelerations=[5,5]))
#now evaluate trajectory at certain time point (this could be now applied in a user function)
[s,v,a] = traj.Evaluate(t=0.5)

Class function: __init__

__init__(self, initialCoordinates, initialTime = 0, maxVelocities = [], maxAccelerations = [])

  • classFunction:
    initialize robot link with parameters, being self-explaining
  • input:
    initialTime: initial time for initial coordinates
    initialCoordinates: initial coordinates for profile
    maxVelocities: list or numpy array to describe global maximum velocities per coordinate
    maxAccelerations: list or numpy array to describe global maximum accelerations per coordinate

Class function: GetFinalCoordinates

GetFinalCoordinates(self)

  • classFunction:
    returns the coordinates at the end of the (currently) Final profile

Class function: Add

Add(self, profile)

  • classFunction:
    add successively profiles, using MotionProfile class

Class function: GetTimes

GetTimes(self)

  • classFunction:
    return vector of times of start/end of profiles

Class function: Initialize

Initialize(self)

  • classFunction:
    initialize some parameters for faster evaluation

Class function: Evaluate

Evaluate(self, t)

  • classFunction:
    return interpolation of trajectory for coordinates, velocities and accelerations at given time
  • output:
    [s, v, a] as numpy arrays representing coordinates, velocities and accelerations

Class function: EvaluateCoordinate

EvaluateCoordinate(self, t, coordinate)

  • classFunction:
    return interpolation of trajectory for coordinate, including velocity and acceleration coordinate at given time
  • output:
    [s, v, a] being scalar position, velocity and acceleration
  • notes:
    faster for single coordinate than Evaluate(…)

Class function: __iter__

__iter__(self)

  • classFunction:
    iterator allows to use for x in trajectory: … constructs

Class function: __getitem__

__getitem__(self, key)

  • classFunction:
    access to profiles via operator [], allowing trajectory[0], etc.

Class function: __len__

__len__(self)

  • classFunction:
    allow using len(trajectory)

Class function: __repr__

__repr__(self)

  • classFunction:
    representation of Trajectory is given a list of profiles, allowing easy inspection of data

Relevant Examples (Ex) and TestModels (TM) with weblink to github: