Design
The Design module creates Hand, Finger, and
GraspObject objects for simulations. The module creates the objects
based on user-given dimensions and geometries, and outputs the generated
objects to Klamp’t .rob files.
-
Design.run_blender_script(args)
Run a blender python script to transform geometries from .stl files.
Arguments are [FILE, -s, SCALE, (-o, OUTPUT_FILE)]. Arguments in
parenthesis are optional.
Parameters: | args (list[str]) – The arguments to pass to the blender script. |
-
class Design.Hand(palmPos=[0, 0, 0.1])
Generates a hand robot for simulating with Klamp’t.
Parameters: | palmPos (list[float]) – The position of the palm in 3D space. |
-
addFinger(finger, fingerOrient, fingerBasePos, fingerType='fixedBase')
Adds a new finger to the hand with the given orientation and position.
The order in which fingers does matter when setting their parameters
later on.
Parameters: |
- finger (Finger) – The Finger to add to the hand.
- fingerOrient (float) – The orientation of the finger on the palm
plane in degrees. 0 deg points in the direction of the positive x
axis.
- fingerBasePos (list[float]) – The position of the finger base
rotary/tilted center in the format [X, Y, Z].
- fingerType (str) – Determines how the finger base may move. Must be
either 'fixedBase', 'rotaryBase', or 'tiltedBase'.
|
-
setPalmPos(palmPos)
Parameters: | palmPos (list[float]) – The position of the palm in 3D space in the
form [X, Y, Z]. |
-
setBaseJointMass(baseJointMassList)
Parameters: | baseJointMassList (list[float]) – The masses of the base of each
finger in the hand in the order in which the fingers were added to
the hand. |
-
setBaseJointInitPos(baseJointInitPosList)
Parameters: | baseJointInitPosList (list[int]) – The initial rotation of each base
joint in degrees in the order in which the fingers were added to the
hand. |
-
setBaseJointTorqueLimit(baseJointTorqueLimit)
Parameters: | baseJointTorqueLimit (list[int]) – The maximum torque that can be
applied to each finger in the order in which the fingers were added
to the hand. |
-
setBaseJointPosLimit(baseJointPosLimit)
Parameters: | baseJointPosLimit (list[list[int]]) – A list of the min and max
angles each base joint can rotate in degrees. The list for a hand
with N fingers should contain N lists of two integers. The first
should be the minimum angle, and the second should be the maximum
angle. The order of the limits should be the same as the order in
which the fingers were added to the hand. |
-
setBaseJointVelLimit(baseJointVelLimit)
Parameters: | baseJointVelLimit (list[int]) – A list of the maximum angular
velocity of each base joint in deg/sec in the order in which the
fingers were added to the hand. |
-
setBaseJointAccLimit(baseJointAccLimit)
Parameters: | baseJointAccLimit (list[int]) – A list of the maximum angular
acceleration of each base joint in deg/sec2.
The order should be the same as the order in which the fingers were
added to the hand. |
-
setControllerPID(PID)
Parameters: | PID (list[float]) – PID values separated into a list. |
-
setDryFriction(dryFriction)
Parameters: | dryFriction (float) – Coefficient of dry friction. |
-
setViscousFriction(viscousFriction)
Parameters: | viscousFriction (float) – Coefficient of viscous friction. |
-
setPalmGeometry(palmGeometryFile, palmDiameter=0.1, palmMass=1)
Sets the geometry and physical attributes of the palm.
In your geometry file, you should make sure that the:
Parameters: |
- palmGeometryFile (str) – Path to the file containing the palm
geometry.
- palmDiameter (float) – How much to scale the palm geometry.
- palmMass (int) – The mass of the palm object in the simulation.
|
-
setfingerBaseGeometry(fingerBaseGeometryFile, fingerBaseDiameter=0.03)
The origin is at the center of the geometry for default geometry.
Parameters: |
- fingerBaseGeometryFile (str) – Path to the file containing the
finger base geometry, relative to the data/hands directory.
- fingerBaseDiameter (float) – How much to scale the finger base
geometry.
|
-
getControllableDofInfo()
Get an ordered list of controllable base joints and joints. The list
for a finger with N fingers and M joints per finger is in the format
['BaseJoint_Finger0', 'BaseJointFinger1', ... , 'BaseJointFingerN-1',
'Joint0_Finger0', 'Joint1_Finger0', ... , 'JointM-1_FingerN-1'].
Returns: | A list of controllable DOFs. |
Return type: | list[str] |
-
getControllableDofIndex(fingerIndex, jointIndex)
Dof index used in the controller (0 based index, doesn’t include fixed joints)
Parameters: |
- fingerIndex (int) – Which finger to get the DOF from.
- jointIndex (int) – Which joint of the finger (starting from -1 at
the base).
|
-
getSensorizedDofIndex(fingerIndex, jointIndex)
Dof index that is consistent with sensor data (0 based index).
Parameters: |
- fingerIndex (int) – Which finger to get the DOF from.
- jointIndex (int) – Which joint of the finger (starting from -1 at
the base).
|
-
getLinkIndex(fingerIndex, phalanxIndex)
link index used in .rob file (0 based index).
Parameters: |
- fingerIndex (int) – Which finger to get the DOF from.
- phalanxIndex (int) – Which phalanx of the finger (starting from 0 at
the base).
|
-
buildFile(handFileName='hand_default')
Build a Klamp’t .rob file for the hand.
Parameters: | handFileName (str) – Path to where the .rob file should be
saved. |
-
class Design.Finger(phalangesLength=[0.06, 0.05, 0.04], phalangesDiameters=[0.06, 0.05, 0.04], phalangesMass=[0.12, 0.1, 0.08])
Generates a finger robot for simulating with Klamp’t.
Creates a finger with phalanges with the given physical attributes.
Parameters: |
- phalangesLength (list[float]) – A list of how much each phalanx
should be scaled height-wise.
- phalangesDiameters (list[float]) – A list of how much the diameter
of each phalanx should be scaled.
- phalangesMass (list[float]) – The masses of each phalanx.
|
-
setGeometry(phalangesGeometryFile)
Sets the geometry and physical attributes of the finger.
Geometry file can be stl, pcd, tri, or anything else supported by
Klamp’t.
In your geometry file, you should make sure that the:
Proximal joint points along the Z-axis.
- Phalange is along the X-axis, and that the X-axis is pointing towards
distal.
Y-axis is pointing towards the palm.
Origin is the midpoint of the joint axis.
Parameters: | phalangesGeometryFile (str) – Path to the phalanx geometry file. |
-
setBaseJointOffset(baseJointOffset)
Parameters: | baseJointOffset (float) – The distance between the proximal axis
center and the base rotation certer. |
-
setInitConfig(initConfig)
Parameters: | initConfig (list[int]) – The initial rotation of each phalanx in
degrees. |
-
setJointPosLimit(jointPosLimit)
Parameters: | jointPosLimit (list[list[int]]) – A list of the min and max angles
each joint can rotate in degrees. The list for a finger with N
joints should contain N lists of two integers. The first should
be the minimum angle, and the second should be the maximum angle. |
-
setJointVelLimit(jointVelLimit)
Parameters: | jointVelLimit (list[int]) – A list of the maximum angular velocity
of each joint in deg/sec. |
-
setJointAccLimit(jointAccLimit)
Parameters: | jointAccLimit (list[int]) – A list of the maximum angular
acceleration of each joint in deg/sec2. |
-
setJointTorqueLimit(jointTorqueLimit)
Parameters: | jointTorqueLimit (list[int]) – A list of the maximum torque that
can be applied to each joint. |
-
setControllerPID(PID)
Parameters: | PID (list[float]) – PID values separated into a list. |
-
setDryFriction(dryFriction)
Parameters: | dryFriction (float) – Coefficient of dry friction. |
-
setViscousFriction(viscousFriction)
Parameters: | viscousFriction (float) – Coefficient of viscous friction. |
-
buildFile(fingerFileName='finger_default')
Build a Klamp’t .rob file for the finger.
Parameters: | fingerFileName (str) – Path to where the .rob file should be
saved. |
-
class Design.GraspObject(objectType='sphere', objectPos=[0, 0, 0.3], objectFriction=0.1)
Generates an object for a hand to grasp in Klamp’t. It allows for three
basic object types: 'spheres', 'cylinders' and 'cubes'.
Alternatively, you can set the object type to 'customized' in order to
provide your own geomtery. The coordinate origin for the basic object is
located at the center of object. Dimensions for the object are in meters.
You can also define your own object using a stl/pcd/tri file, but please
make sure that the coordinate origin is located at the center of the object.
Parameters: |
- objectType (str) – What type of object to generate. It can be one
of the predefined types, 'sphere', 'cylinder', or
'cube', or 'customized' in order to use external geometry.
- objectPos (list[float]) – The initial position of the object in 3D
space.
- objectFriction (float) – The friction coefficient for the object.
|
-
setObjectType(objectType)
Parameters: | objectType (str) – The type of the object. It can be one
of the predefined types, 'sphere', 'cylinder', or
'cube', or 'customized' in order to use external geometry. |
-
setPosition(objectPos)
Parameters: | objectPos (list[float]) – The position of the object center of mass
in 3D space. |
-
setDimension(objectDimension)
Parameters: | objectDimension (list[float]) – The scaling factors for the three
corresponding axes in the geometry file. Units are in meters. |
-
setMass(objectMass)
Parameters: | objectMass (float) – The mass of the object in kilograms. |
-
setGeometry(objectGeometryFile=None)
Set the geometry for the object. If objectGeometryFile is
None, a predefined object file corresponding to the
objectType is loaded. If objectGeometryFile is not
None, the objectType is automatically set to
'customized'. Custom geometry files can be in stl, pcd, tri, or any
other format the Klamp’t supports. Make sure that the origin is at the
center of the object, or else it may not be simulated properly.
Parameters: | objectGeometryFile (str) – None or the path to the custom
geometry file relative to the data/objects directory. |
-
setOrient(objectOrient)
Orientation is set using the Z-Y-X representation: based on original
coordinates in the geometry file, the object is rotated according to the
following 3 steps:
Rotate it about the Z-axis by Z-degrees.
- Based on the new coordinates, rotate about the Y-axis by
Y-degrees.
- Based on the new coordinates, rotate about the X-axis by
X-degrees.
Parameters: | objectOrient (list[int]) – Orientation of the object in the format
[Z-degrees, Y-degrees, X-degrees]. |
-
setFriction(objectFriction)
Parameters: | objectFriction (float) – The dynamic coefficient of friction. |
-
setRestitution(objectRestitution)
Parameters: | objectRestitution (float) – The coefficient of restitution. |
-
setDamping(objectDamping)
Parameters: | objectDamping (int) – The coefficient of damping. |
-
setStiffness(objectStiffness)
Parameters: | objectStiffness (int) – The stiffness of the object. |
-
buildFile(objectFileName='object_default')
Build a Klamp’t .obj file for the grasp object.
Parameters: | objectFileName (str) – Path to where the .obj file should be
saved. |