(sec-module-robotics)= # Module: robotics A library which includes support functions for robotics; the library is built on standard Denavit-Hartenberg Parameters and Homogeneous Transformations (HT) to describe transformations and coordinate systems; import this library e.g. with import exudyn.robotics as robotics - **Author**: Johannes Gerstmayr - **Date**: 2020-04-14 - **Example**: New robot model uses the class Robot with class RobotLink; the old dictionary structure is defined in the example in ComputeJointHT for the definition of the 'robot' dictionary. (sec-roboticscore--toht)= ## Function: _ToHT [`_ToHT(H)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L65) - **function description**: an exudyn.HT from an exudyn.HT (the same object), a 4x4 matrix or None (the identity); the robotics classes store and compute with exudyn.HT (#2821) (sec-roboticscore-stddh2ht)= ## Function: StdDH2HT [`StdDH2HT(DHparameters)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L1117) - **function description**: compute the homogeneous transformation HT, an exudyn.HT, from standard DHparameters=[theta, d, a, alpha] Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`humanRobotInteraction.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/humanRobotInteraction.py) (Ex), [`InverseKinematicsNumericalExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/InverseKinematicsNumericalExample.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), [`serialRobotKinematicTree.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotKinematicTree.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-roboticscore-moddhkk2ht)= ## Function: ModDHKK2HT [`ModDHKK2HT(DHparameters)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L1139) - **function description**: compute pre- and post- homogeneous transformations (exudyn.HT) from modified Denavit-Hartenberg DHparameters=[alpha, d, theta, r]; returns [HTpre, HTpost]; HTpre is transformation before axis rotation, HTpost includes axis rotation and everything hereafter; modified DH-Parameters according to Khalil and Kleinfinger, 1986 Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`serialRobotKinematicTree.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotKinematicTree.py) (Ex) (sec-roboticscore-projectangletopmpi)= ## Function: projectAngleToPMPi [`projectAngleToPMPi(q0)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L1149) - **function description**: This function projects an angle in the range $[-min_{float}, +max_{float}]$ fo the range $[-\pi, +\pi]$ - **input**: - `q0`: An angle either as scalar, list or array - **output**: qProj: The angle projected into the range $[-\pi to \pi]$ - **author**: Peter Manzl (sec-module-robotics-class-vrobotlink)= ## CLASS VRobotLink (in module robotics) **class description**: class to define visualization of RobotLink (sec-roboticscore-vrobotlink---init--)= ### Class function: __init__ [`__init__(self, jointRadius = 0.06, jointWidth = 0.12, linkWidth = 0.1, showMBSjoint = True, showCOM = True, linkColor = [0.4,0.4,0.4,1], graphicsData = [])`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L105) - **class function description**: initialize robot link with parameters, being self-explaining - **input**: - `jointRadius`: radius of joint to draw - `jointWidth`: length or width of joint (depending on type of joint) - `showMBSjoint`: if False, joint is not drawn - `linkWidth`: width of link for default drawing - `linkColor`: color of link for default drawing - `showCOM`: if True, center of mass is marked with cube - `graphicsData`: list of GraphicsData to represent link; if list is empty, link graphics will be generated from link geometry data; otherwise, drawing will be taken from graphicsData, and only showMBSjoint and showCOM flags will add additional graphics Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`humanRobotInteraction.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/humanRobotInteraction.py) (Ex), [`InverseKinematicsNumericalExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/InverseKinematicsNumericalExample.py) (Ex), [`kinematicTreePendulum.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreePendulum.py) (Ex), [`openAIgymNLinkAdvanced.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/openAIgymNLinkAdvanced.py) (Ex), [`openAIgymNLinkContinuous.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/openAIgymNLinkContinuous.py) (Ex), [`kinematicTreeAndMBStest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeAndMBStest.py) (TM), [`kinematicTreeConstraintTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeConstraintTest.py) (TM), [`movingGroundRobotTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/movingGroundRobotTest.py) (TM), ... (sec-module-robotics-class-robotlink)= ## CLASS RobotLink (in module robotics) **class description**: class to define one link of a robot (sec-roboticscore-robotlink---init--)= ### Class function: __init__ [`__init__(self, mass, COM, inertia, localHT = None, jointType = 'Rz', parent = -2, preHT = None, PDcontrol = (None,None), visualization = VRobotLink())`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L146) - **class function description**: initialize robot link - **input**: - `mass`: mass of robot link - `COM`: center of mass in link coordinate system - `inertia`: 3x3 matrix (list of lists / numpy array) containing inertia tensor in link coordinates, with respect to center of mass - `localHT`: exudyn.HT or 4x4 matrix (list of lists / numpy array) containing homogeneous transformation from local joint to link coordinates, stored as exudyn.HT; default (None) = identity; currently, this transformation is not available in KinematicTree, therefore the link inertia and COM must be transformed accordingly - `preHT`: exudyn.HT or 4x4 matrix (list of lists / numpy array) containing homogeneous transformation from previous link to this joint, stored as exudyn.HT; default (None) = identity - `jointType`: string containing joint type, out of: 'Rx', 'Ry', 'Rz' for revolute joints and 'Px', 'Py', 'Pz' for prismatic joints around/along the respecitive local axes - `parent`: for building robots as kinematic tree; use '-2' to automatically set parents for serial robot (on fixed base), use '-1' for ground-parent and any other 0-based index for connection to parent link - `PDcontrol`: tuple of P and D control values, defining position (rotation) proportional value P and velocitiy proportional value D - `visualization`: VRobotLink structure containing options for drawing of link and joints; see class VRobotLink (sec-roboticscore-robotlink-localht)= ### Class function: localHT [`localHT(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L172) - **class function description**: transformation from local joint to link coordinates, an exudyn.HT (sec-roboticscore-robotlink-preht)= ### Class function: preHT [`preHT(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L181) - **class function description**: transformation from previous link to this joint, an exudyn.HT (sec-roboticscore-robotlink-setpdcontrol)= ### Class function: SetPDcontrol [`SetPDcontrol(self, Pvalue, Dvalue)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L189) - **class function description**: set PD control values for drive of joint related to link using position-proportional value P and differential value (velocity proportional) D (sec-roboticscore-robotlink-haspdcontrol)= ### Class function: HasPDcontrol [`HasPDcontrol(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L194) - **class function description**: check if contrl is available (sec-roboticscore-robotlink-getpdcontrol)= ### Class function: GetPDcontrol [`GetPDcontrol(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L199) - **class function description**: get PD control values Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`humanRobotInteraction.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/humanRobotInteraction.py) (Ex), [`InverseKinematicsNumericalExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/InverseKinematicsNumericalExample.py) (Ex), [`kinematicTreeAndMBS.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreeAndMBS.py) (Ex), [`kinematicTreePendulum.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreePendulum.py) (Ex), [`openAIgymNLinkAdvanced.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/openAIgymNLinkAdvanced.py) (Ex), [`homogeneousTransformationParameterTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/homogeneousTransformationParameterTest.py) (TM), [`kinematicTreeAndMBStest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeAndMBStest.py) (TM), [`kinematicTreeConstraintTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeConstraintTest.py) (TM), ... (sec-module-robotics-class-vrobottool)= ## CLASS VRobotTool (in module robotics) **class description**: class to define visualization of RobotTool (sec-roboticscore-vrobottool---init--)= ### Class function: __init__ [`__init__(self, graphicsData = [])`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L225) - **class function description**: initialize robot tool with parameters; currently only graphicsData, which is a list of GraphicsData same as in mbs Objects Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`humanRobotInteraction.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/humanRobotInteraction.py) (Ex), [`InverseKinematicsNumericalExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/InverseKinematicsNumericalExample.py) (Ex), [`kinematicTreeAndMBS.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreeAndMBS.py) (Ex), [`kinematicTreePendulum.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreePendulum.py) (Ex), [`openAIgymNLinkAdvanced.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/openAIgymNLinkAdvanced.py) (Ex), [`kinematicTreeAndMBStest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeAndMBStest.py) (TM), [`kinematicTreeConstraintTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeConstraintTest.py) (TM), [`movingGroundRobotTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/movingGroundRobotTest.py) (TM), ... (sec-module-robotics-class-robottool)= ## CLASS RobotTool (in module robotics) **class description**: define tool of robot: containing graphics and HT (may add features in future) (sec-roboticscore-robottool---init--)= ### Class function: __init__ [`__init__(self, HT = None, visualization = VRobotTool())`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L233) - **class function description**: initialize robot tool - **input**: - `HT`: exudyn.HT or 4x4 matrix (list of lists / numpy array) containing homogeneous transformation to transform from last link to tool, stored as exudyn.HT; default (None) = identity - `graphicsData`: dictionary containing a list of GraphicsData, same as in exudyn Objects (sec-roboticscore-robottool-ht)= ### Class function: HT [`HT(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L244) - **class function description**: the homogeneous transformation, an exudyn.HT Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`humanRobotInteraction.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/humanRobotInteraction.py) (Ex), [`InverseKinematicsNumericalExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/InverseKinematicsNumericalExample.py) (Ex), [`kinematicTreeAndMBS.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreeAndMBS.py) (Ex), [`kinematicTreePendulum.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreePendulum.py) (Ex), [`openAIgymNLinkAdvanced.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/openAIgymNLinkAdvanced.py) (Ex), [`homogeneousTransformationParameterTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/homogeneousTransformationParameterTest.py) (TM), [`kinematicTreeAndMBStest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeAndMBStest.py) (TM), [`kinematicTreeConstraintTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeConstraintTest.py) (TM), ... (sec-module-robotics-class-vrobotbase)= ## CLASS VRobotBase (in module robotics) **class description**: class to define visualization of RobotBase (sec-roboticscore-vrobotbase---init--)= ### Class function: __init__ [`__init__(self, graphicsData = [])`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L262) - **class function description**: initialize robot base with parameters; currently only graphicsData, which is a list of GraphicsData same as in mbs Objects Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`humanRobotInteraction.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/humanRobotInteraction.py) (Ex), [`InverseKinematicsNumericalExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/InverseKinematicsNumericalExample.py) (Ex), [`kinematicTreeAndMBS.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreeAndMBS.py) (Ex), [`kinematicTreePendulum.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreePendulum.py) (Ex), [`openAIgymNLinkAdvanced.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/openAIgymNLinkAdvanced.py) (Ex), [`kinematicTreeAndMBStest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeAndMBStest.py) (TM), [`kinematicTreeConstraintTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeConstraintTest.py) (TM), [`movingGroundRobotTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/movingGroundRobotTest.py) (TM), ... (sec-module-robotics-class-robotbase)= ## CLASS RobotBase (in module robotics) **class description**: define base of robot: containing graphics and HT (may add features in future) (sec-roboticscore-robotbase---init--)= ### Class function: __init__ [`__init__(self, HT = None, visualization = VRobotBase())`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L271) - **class function description**: initialize robot base - **input**: - `HT`: exudyn.HT or 4x4 matrix (list of lists / numpy array) containing homogeneous transformation to transform from world coordinates to base coordinates (changes orientation and position of robot), stored as exudyn.HT; default (None) = identity - `graphicsData`: dictionary containing a list of GraphicsData, same as in exudyn Objects (sec-roboticscore-robotbase-ht)= ### Class function: HT [`HT(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L282) - **class function description**: the homogeneous transformation, an exudyn.HT Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`humanRobotInteraction.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/humanRobotInteraction.py) (Ex), [`InverseKinematicsNumericalExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/InverseKinematicsNumericalExample.py) (Ex), [`kinematicTreeAndMBS.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreeAndMBS.py) (Ex), [`kinematicTreePendulum.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreePendulum.py) (Ex), [`openAIgymNLinkAdvanced.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/openAIgymNLinkAdvanced.py) (Ex), [`homogeneousTransformationParameterTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/homogeneousTransformationParameterTest.py) (TM), [`kinematicTreeAndMBStest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeAndMBStest.py) (TM), [`kinematicTreeConstraintTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeConstraintTest.py) (TM), ... (sec-module-robotics-class-robot)= ## CLASS Robot (in module robotics) **class description**: class to define a robot (sec-roboticscore-robot---init--)= ### Class function: __init__ [`__init__(self, gravity = [0,0,-9.81], base = RobotBase(), tool = RobotTool(), referenceConfiguration = [])`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L306) - **class function description**: initialize robot class - **input**: - `base`: definition of base using RobotBase() class - `tool`: definition of tool using RobotTool() class - `gravity`: a list or 3D numpy array defining gravity - `referenceConfiguration`: a list of scalar quantities defining the parameters for reference configuration (sec-roboticscore-robot-addlink)= ### Class function: AddLink [`AddLink(self, robotLink)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L339) - **class function description**: add a link to serial robot (sec-roboticscore-robot-isserialrobot)= ### Class function: IsSerialRobot [`IsSerialRobot(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L361) - **class function description**: return True, if robot is a serial robot (sec-roboticscore-robot-getlink)= ### Class function: GetLink [`GetLink(self, i)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L366) - **class function description**: return Link object of link i (sec-roboticscore-robot-hasparent)= ### Class function: HasParent [`HasParent(self, i)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L371) - **class function description**: True if link has parent, False if not (sec-roboticscore-robot-getparentindex)= ### Class function: GetParentIndex [`GetParentIndex(self, i)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L376) - **class function description**: Get index of parent link; for serial robot this is simple, but for general trees, there is a index list (sec-roboticscore-robot-numberoflinks)= ### Class function: NumberOfLinks [`NumberOfLinks(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L382) - **class function description**: return number of links (sec-roboticscore-robot-getbaseht)= ### Class function: GetBaseHT [`GetBaseHT(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L387) - **class function description**: return base as homogeneous transformation (sec-roboticscore-robot-gettoolht)= ### Class function: GetToolHT [`GetToolHT(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L392) - **class function description**: return base as homogeneous transformation (sec-roboticscore-robot-linkht)= ### Class function: LinkHT [`LinkHT(self, q)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L397) - **class function description**: compute list of homogeneous transformations (exudyn.HT) for every link, using current joint coordinates q; leads to different results for standard and modified DH parameters because link coordinates are different! (sec-roboticscore-robot-jointht)= ### Class function: JointHT [`JointHT(self, q)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L427) - **class function description**: compute list of homogeneous transformations (exudyn.HT) for every joint (after rotation), using current joint coordinates q (sec-roboticscore-robot-comht)= ### Class function: COMHT [`COMHT(self, HT)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L455) - **class function description**: compute list of homogeneous transformations HT (exudyn.HT) from base to every COM using HT list from Robot.JointHT(...) (sec-roboticscore-robot-statictorques)= ### Class function: StaticTorques [`StaticTorques(self, HT)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L465) - **class function description**: compute list of joint torques for serial robot due to gravity (gravity and mass as given in robot), taking HT from Robot.JointHT() (sec-roboticscore-robot-jacobian)= ### Class function: Jacobian [`Jacobian(self, HT, toolPosition = [], mode = 'all', linkIndex = None)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L483) - **class function description**: compute jacobian for translation and rotation at toolPosition using joint HT; this is using the Robot functions, but is inefficient for simulation purposes - **input**: - `HT`: list of homogeneous transformations per joint , as computed by Robot.JointHT(...) - `toolPosition`: global position at which the jacobian is evaluated (e.g., COM); if empty [], it uses the origin of the last link - `mode`: 'all'...translation and rotation jacobian, 'trans'...only translation part, 'rot': only rotation part - `linkIndex`: link index for which the jacobian is evaluated; if linkIndex==None, it uses the last link provided in HT - **output**: returns jacobian with translation and rotation parts in rows (3 or 6) according to mode, and one column per HT; in the kinematic tree the columns not related to linkIndex remain zero (sec-roboticscore-robot-createkinematictree)= ### Class function: CreateKinematicTree [`CreateKinematicTree(self, mbs, name = '', forceUserFunction = 0)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L558) - **class function description**: Add a ObjectKinematicTree to existing mbs from the robot structure inside this robot class; Joints defined by the kinematics as well as links (and inertia) are transferred to the kinematic tree object; Current implementation only works for serial robots; Control can be realized simply by adding PDcontrol to RobotLink structures, then modifying jointPositionOffsetVector and jointVelocityOffsetVector in ObjectKinematicTree; force offsets (e.g., static or dynamic torque compensation) can be added to KinematicTree jointForceVector; more general control can be added by using KinematicTree forceUserFunction; The coordinates in KinematicTree (as well as jointPositionOffsetVector, etc.) are sorted in the order as the RobotLinks are added to the Robot class; Note that the ObjectKinematicTree is still under development and interfaces may change. - **input**: - `mbs`: the multibody system, which will be extended - `name`: object name in KinematicTree; transferred to KinematicTree, default = '' - `forceUserFunction`: defines the user function for computation of joint forces in KinematicTree; transferred to KinematicTree, default = 0 - **output**: the function returns a dictionary containing 'nodeGeneric': generic ODE2 node number ,'objectKinematicTree': the kinematic tree object, 'baseObject': the base object if created, otherwise None; further values will be added in future (sec-roboticscore-robot-createredundantcoordinatembs)= ### Class function: CreateRedundantCoordinateMBS [`CreateRedundantCoordinateMBS(self, mbs, baseMarker, jointSpringDamperUserFunctionList = [], jointLoadUserFunctionList = [], createJointTorqueLoads = True, rotationMarkerBase = None, rigidBodyNodeType = exudyn.NodeType.RotationEulerParameters)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L737) - **class function description**: Add items to existing mbs from the robot structure inside this robot class; robot is attached to baseMarker (can be ground object or moving/deformable body); The (serial) robot is built as rigid bodies (containing rigid body nodes), where bodies represent the links which are connected by joints; Add optional jointSpringDamperUserFunctionList for individual control of joints; otherwise use PDcontrol in RobotLink structure; additional joint torques/forces can be added via spring damper, using mbs.SetObjectParameter(...) function; See several Python examples, e.g., `serialRobotTestTSD.py`, in Examples or TestModels; For more efficient models, use CreateKinematicTree(...) function! - **input**: - `mbs`: the multibody system, which will be extended - `baseMarker`: a rigid body marker, at which the robot will be placed (usually ground); note that the local coordinate system of the base must be in accordance with the DH-parameters, i.e., the z-axis must be the first rotation axis. For correction of the base coordinate system, use rotationMarkerBase - `jointSpringDamperUserFunctionList`: NOT IMPLEMENTED yet: jointSpringDamperUserFunctionLista list of user functions for actuation of joints with more efficient spring-damper based connector (spring-damper directly emulates PD-controller); uses torsional spring damper for revolute joints and linear spring damper for prismatic joints; can be empty list (no spring dampers); if entry of list is 0, no user function is created, just pure spring damper; parameters are taken from RobotLink PDcontrol structure, which MUST be defined using SetPDcontrol(...) in RobotLink - `jointLoadUserFunctionList`: DEPRECATED: a list of user functions for actuation of joints according to a LoadTorqueVector userFunction, see serialRobotTest.py as an example; can be empty list - `createJointTorqueLoads`: DEPRECATED: if True, independently of jointLoadUserFunctionList, joint loads are created; the load numbers are stored in lists jointTorque0List/ jointTorque1List; the loads contain zero torques and need to be updated in every computation step, e.g., using a preStepUserFunction; unitTorque0List/ unitTorque1List contain the unit torque vector for the according body(link) which needs to be applied on both bodies attached to the joint - `rotationMarkerBase`: add a numpy 3x3 matrix for rotation of the base, in order that the robot can be attached to any rotated base marker; the rotationMarkerBase is according to the definition in GenericJoint; note, that for moving base, the static compensation does not work (base rotation must be updated) - `rigidBodyNodeType`: specify node type of rigid body node, e.g., exudyn.NodeType.RotationEulerParameters, etc. - **output**: the function returns a dictionary containing per link nodes and object (body) numbers, 'nodeList', 'bodyList', the object numbers for joints, 'jointList', list of load numbers for joint torques (jointTorque0List, jointTorque1List); unit torque vectors in local coordinates of the bodies to which the torques are applied (unitTorque0List, unitTorque1List); springDamperList contains the spring dampers if defined by PDcontrol of links (sec-roboticscore-robot-getkinematictree66)= ### Class function: GetKinematicTree66 [`GetKinematicTree66(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L989) - **class function description**: export kinematicTree (sec-roboticscore-robot-getlinkgraphicsdata)= ### Class function: GetLinkGraphicsData [`GetLinkGraphicsData(self, i, p0, p1, axis0, axis1, linkVisualization)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L1019) - **class function description**: create link GraphicsData (list) for link i; internally used in CreateRedundantCoordinateMBS(...); linkVisualization contains visualization dict of link (sec-roboticscore-robot-buildfromdictionary)= ### Class function: BuildFromDictionary [`BuildFromDictionary(self, robotDict)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L1064) - **class function description**: build robot structre from dictionary; this is a DEPRECATED function, which is used in older models; DO NOT USE Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`humanRobotInteraction.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/humanRobotInteraction.py) (Ex), [`kinematicTreeAndMBS.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreeAndMBS.py) (Ex), [`kinematicTreePendulum.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/kinematicTreePendulum.py) (Ex), [`openAIgymNLinkAdvanced.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/openAIgymNLinkAdvanced.py) (Ex), [`openAIgymNLinkContinuous.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/openAIgymNLinkContinuous.py) (Ex), [`kinematicTreeConstraintTest.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/TestModels/kinematicTreeConstraintTest.py) (TM), [`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-class-inversekinematicsnumerical())= ## CLASS InverseKinematicsNumerical() (in module robotics) **class description**: This class can be used to solve the inverse kinematics problem using a multibody system by solving the static problem of a serial robot - **author**: Peter Manzl, Johannes Gerstmayr - **notes**: still under development; errors in orientations of solution may occure. proviedes mtehods to calculate inverse Kinematics (sec-roboticscore-inversekinematicsnumerical()---init--)= ### Class function: __init__ [`__init__(self, robot, jointStiffness = 1e0, useRenderer = False, flagDebug = False, useAlternativeConstraints = False)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L1178) - **class function description**: initialize RigidBodyInertia with scalar mass, 3x3 inertiaTensor (w.r.t. reference point!!!) and center of mass com - **input**: - `robot`: robot class - `jointStiffness`: the stiffness used for the robot's model joints - `useRenderer`: when solving the inverse kinematics the renderer is used to show the starting/end configuration of the robot using the graphics objects definded in the robot object - **author**: Peter Manzl (sec-roboticscore-inversekinematicsnumerical()-getcurrentrobotht)= ### Class function: GetCurrentRobotHT [`GetCurrentRobotHT(self)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L1274) - **class function description**: Utility function to get current Homogeneous transformation of the robot to check inverse Kinematics solution ** output: T: homogeneous transformation (exudyn.HT) of the current TCP pose (sec-roboticscore-inversekinematicsnumerical()-interpolatehts)= ### Class function: InterpolateHTs [`InterpolateHTs(self, T1, T2, rotStep = np.pi/16, minSteps = 1)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L1286) - **class function description**: - **input**: - `T1`: 4x4 homogeneous transformation matrix representing the first Pose - `T2`: 4x4 homogeneous transformation matrix representing the second Pose - `rotStep`: the max. size of steps to take for the orientation - `minSteps`: minimum number of substeps to interpolate - **output**: T: a List of homogeneous transformations (exudyn.HT) for each step between - **author**: Peter Manzl - **notes**: still under development; interpolation may be changed to using logSE3 (sec-roboticscore-inversekinematicsnumerical()-solvesafe)= ### Class function: SolveSafe [`SolveSafe(self, T, q0 = None)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L1333) - **class function description**: This Method can be used to solve the inverse kinematics problem by solving the static problem of a serial robot using steps to interpolate between start and end position close to the function Solve. This helps the function Solve() to find the correct solutions. - **input**: - `T`: the homogeneous transformation, an exudyn.HT or a 4x4 matrix, representing the desired position and orientation of the Endeffector - `q0`: The configuration (joint angles/positions) of the robot from which the numerical methods start so calculate the solution; q0=None indicates that the stored solution (from model or previous solution) shall be used for initialization - **output**: [q, success]; q: The solution for the joint angles in which the robot's tool center point (TCP) reaches the desired homogeneous transformation matrix T; success=False indicates that all trials for inverse kinematics failed, leading to q=None success: flag to indicate if method was successful - **author**: Peter Manzl, Johannes Gerstmayr - **notes**: still under development; errors in orientations of solution may occure. works similar to ikine_LM function of the robotics toolbox from peter corke (sec-roboticscore-inversekinematicsnumerical()-solve)= ### Class function: Solve [`Solve(self, T, q0 = None)`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/exudyn/robotics/roboticsCore.py#L1390) - **class function description**: This Method can be used to solve the inverse kinematics problem by solving the static problem of a serial robot using steps to interpolate between start and end position close to the function Solve. T his helps the fucntion Solve to find the correct solutions. - **input**: - `T`: the homogeneous transformation, an exudyn.HT or a 4x4 matrix, representing the desired position and orientation of the Endeffector - `q0`: The configuration (joint angles/positions) of the robot from which the numerical methods start so calculate the solution; q0=None indicates that the stored solution (from model or previous solution) shall be used for initialization - **output**: [q, success]; q: The solution for the joint angles in which the robot's tool center point (TCP) reaches the desired homogeneous transformation matrix T; success=False indicates that all trials for inverse kinematics failed, leading to q=None - **author**: Peter Manzl, Johannes Gerstmayr - **notes**: still under development; errors in orientations of solution may occure. works similar to ikine_LM function of the robotics toolbox from peter corke Relevant Examples (Ex) and TestModels (TM) with weblink to github: [`InverseKinematicsNumericalExample.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/InverseKinematicsNumericalExample.py) (Ex), [`serialRobotInverseKinematics.py`](https://github.com/jgerstmayr/EXUDYN/blob/master/python/Examples/serialRobotInverseKinematics.py) (Ex)