Skip to content

Commit 7f0426e

Browse files
Update constraints.py
1 parent c08854d commit 7f0426e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/compas_fab/robots/constraints.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,35 +154,39 @@ class JointConstraint(Constraint):
154154
The name of the joint this contraint refers to.
155155
value: float
156156
The targeted value for that joint.
157-
tolerance: float
158-
The bound to be achieved is [value - tolerance, value + tolerance]
157+
tolerance_above: float
158+
tolerance_below: float
159+
The bound to be achieved is [value - tolerance_below, position + tolerance_above].
160+
JointConstraint tolerances values must be positive.
159161
weight: float, optional
160162
A weighting factor for this constraint. Denotes relative importance to
161163
other constraints. Closer to zero means less important. Defaults to 1.
162164
163165
Examples
164166
--------
165167
>>> from compas_fab.robots import JointConstraint
166-
>>> jc = JointConstraint("joint_0", 1.4, 0.1)
168+
>>> jc = JointConstraint("joint_0", 1.4, 0.1, 0.1, 1.0)
167169
168170
"""
169171

170-
def __init__(self, joint_name, value, tolerance=0., weight=1.):
172+
def __init__(self, joint_name, value, tolerance_above=0., tolerance_below=0., weight=1.):
171173
super(JointConstraint, self).__init__(self.JOINT, weight)
172174
self.joint_name = joint_name
173175
self.value = value
174-
self.tolerance = tolerance
176+
self.tolerance_above = tolerance_above
177+
self.tolerance_below = tolerance_below
175178

176179
def scale(self, scale_factor):
177180
self.value /= scale_factor
178-
self.tolerance /= scale_factor
181+
self.tolerance_above /= scale_factor
182+
self.tolerance_below /= scale_factor
179183

180184
def __repr__(self):
181-
return "JointConstraint('{0}', {1}, {2}, {3})".format(self.joint_name, self.value, self.tolerance, self.weight)
185+
return "JointConstraint('{0}', {1}, {2}, {3}, {4})".format(self.joint_name, self.value, self.tolerance_above, self.tolerance_below, self.weight)
182186

183187
def copy(self):
184188
cls = type(self)
185-
return cls(self.joint_name, self.value, self.tolerance, self.weight)
189+
return cls(self.joint_name, self.value, self.tolerance_above, self.tolerance_below, self.weight)
186190

187191

188192
class OrientationConstraint(Constraint):

0 commit comments

Comments
 (0)