(sec-module-robotics.motion)= # Module: robotics.motion functionality for motion including generation of trajectories with acceleration profiles, path planning and motion - **Author**: Johannes Gerstmayr - **Date**: 2022-02-16 (sec-module-robotics.motion-class-profileconstantacceleration)= ## 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 (sec-motion-profileconstantacceleration---init--)= ### Class function: __init__ [`__init__(self, finalCoordinates, duration)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L153) - **class function description**: initialize ProfileConstantAcceleration with vector of final coordinates and duration (time span) (sec-motion-profileconstantacceleration-getbasicprofile)= ### Class function: GetBasicProfile [`GetBasicProfile(self, initialTime, initialCoordinates, globalMaxVelocities, globalMaxAccelerations)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L159) - **class function description**: return a class representing profile which is used in Trajectory Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`humanRobotInteraction.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/humanRobotInteraction.py) (Ex), [`mobileMecanumWheelRobotWithLidar.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/mobileMecanumWheelRobotWithLidar.py) (Ex), [`ROSMobileManipulator.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ROSMobileManipulator.py) (Ex), [`serialRobotFlexible.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotFlexible.py) (Ex), [`serialRobotInteractiveLimits.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotInteractiveLimits.py) (Ex), [`movingGroundRobotTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/movingGroundRobotTest.py) (TM), [`serialRobotTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/serialRobotTest.py) (TM), ... (sec-module-robotics.motion-class-profilelinearaccelerationslist)= ## 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*: ```python profile = ProfileLinearAccelerationsList([(0,[0.,1.,2]), (0,[1.,1.,-2])]) ``` (sec-motion-profilelinearaccelerationslist---init--)= ### Class function: __init__ [`__init__(self, accelerationList)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L186) - **class function description**: initialize ProfileLinearAccelerationsList with a list of tuples containing time and acceleration vector (sec-motion-profilelinearaccelerationslist-getbasicprofile)= ### Class function: GetBasicProfile [`GetBasicProfile(self, initialTime, initialCoordinates, globalMaxVelocities, globalMaxAccelerations)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L197) - **class function description**: return a class representing profile which is used in Trajectory (sec-module-robotics.motion-class-profileptp)= ## 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 (sec-motion-profileptp---init--)= ### Class function: __init__ [`__init__(self, finalCoordinates, syncAccTimes = True, maxVelocities = [], maxAccelerations = [])`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L219) - **class function description**: initialize ProfilePTP with final coordinates of motion, optionally max. velocities and accelerations just for this profile (overrides global settings) (sec-motion-profileptp-getbasicprofile)= ### Class function: GetBasicProfile [`GetBasicProfile(self, initialTime, initialCoordinates, globalMaxVelocities, globalMaxAccelerations)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L233) - **class function description**: return a class representing profile which is used in Trajectory Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`serialRobotFlexible.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotFlexible.py) (Ex), [`serialRobotInteractiveLimits.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotInteractiveLimits.py) (Ex), [`serialRobotInverseKinematics.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotInverseKinematics.py) (Ex), [`serialRobotKinematicTree.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotKinematicTree.py) (Ex), [`serialRobotTSD.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotTSD.py) (Ex) (sec-module-robotics.motion-class-trajectory)= ## 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*: ```python #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) ``` (sec-motion-trajectory---init--)= ### Class function: __init__ [`__init__(self, initialCoordinates, initialTime = 0, maxVelocities = [], maxAccelerations = [])`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L313) - **class function description**: 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 (sec-motion-trajectory-getfinalcoordinates)= ### Class function: GetFinalCoordinates [`GetFinalCoordinates(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L335) - **class function description**: returns the coordinates at the end of the (currently) Final profile (sec-motion-trajectory-add)= ### Class function: Add [`Add(self, profile)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L344) - **class function description**: add successively profiles, using MotionProfile class (sec-motion-trajectory-gettimes)= ### Class function: GetTimes [`GetTimes(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L352) - **class function description**: return vector of times of start/end of profiles (sec-motion-trajectory-initialize)= ### Class function: Initialize [`Initialize(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L360) - **class function description**: initialize some parameters for faster evaluation (sec-motion-trajectory-evaluate)= ### Class function: Evaluate [`Evaluate(self, t)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L366) - **class function description**: return interpolation of trajectory for coordinates, velocities and accelerations at given time - **output**: [s, v, a] as numpy arrays representing coordinates, velocities and accelerations (sec-motion-trajectory-evaluatecoordinate)= ### Class function: EvaluateCoordinate [`EvaluateCoordinate(self, t, coordinate)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L389) - **class function description**: 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(...) (sec-motion-trajectory---iter--)= ### Class function: __iter__ [`__iter__(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L412) - **class function description**: iterator allows to use for x in trajectory: ... constructs (sec-motion-trajectory---getitem--)= ### Class function: __getitem__ [`__getitem__(self, key)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L417) - **class function description**: access to profiles via operator [], allowing trajectory[0], etc. (sec-motion-trajectory---len--)= ### Class function: __len__ [`__len__(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L422) - **class function description**: allow using len(trajectory) (sec-motion-trajectory---repr--)= ### Class function: __repr__ [`__repr__(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/motion.py#L428) - **class function description**: representation of Trajectory is given a list of profiles, allowing easy inspection of data Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`humanRobotInteraction.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/humanRobotInteraction.py) (Ex), [`mobileMecanumWheelRobotWithLidar.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/mobileMecanumWheelRobotWithLidar.py) (Ex), [`ROSMobileManipulator.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/ROSMobileManipulator.py) (Ex), [`serialRobotFlexible.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotFlexible.py) (Ex), [`serialRobotInteractiveLimits.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotInteractiveLimits.py) (Ex), [`movingGroundRobotTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/movingGroundRobotTest.py) (TM), [`serialRobotTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/serialRobotTest.py) (TM), ...