@@ -154,35 +154,40 @@ 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 above the targeted joint value, in radians. Defaults to 0.
159+ tolerance_below: float
160+ Tolerance below the targeted joint value, in radians. Defaults to 0.
161+ The bound to be achieved is [value - tolerance_below, value + tolerance_above].
159162 weight: float, optional
160163 A weighting factor for this constraint. Denotes relative importance to
161164 other constraints. Closer to zero means less important. Defaults to 1.
162165
163166 Examples
164167 --------
165168 >>> from compas_fab.robots import JointConstraint
166- >>> jc = JointConstraint("joint_0", 1.4, 0.1)
169+ >>> jc = JointConstraint("joint_0", 1.4, 0.1, 0.1, 1.0 )
167170
168171 """
169172
170- def __init__ (self , joint_name , value , tolerance = 0. , weight = 1. ):
173+ def __init__ (self , joint_name , value , tolerance_above = 0. , tolerance_below = 0. , weight = 1. ):
171174 super (JointConstraint , self ).__init__ (self .JOINT , weight )
172175 self .joint_name = joint_name
173176 self .value = value
174- self .tolerance = tolerance
177+ self .tolerance_above = abs (tolerance_above )
178+ self .tolerance_below = abs (tolerance_below )
175179
176180 def scale (self , scale_factor ):
177181 self .value /= scale_factor
178- self .tolerance /= scale_factor
182+ self .tolerance_above /= scale_factor
183+ self .tolerance_below /= scale_factor
179184
180185 def __repr__ (self ):
181- return "JointConstraint('{0}', {1}, {2}, {3})" .format (self .joint_name , self .value , self .tolerance , self .weight )
186+ return "JointConstraint('{0}', {1}, {2}, {3}, {4} )" .format (self .joint_name , self .value , self .tolerance_above , self . tolerance_below , self .weight )
182187
183188 def copy (self ):
184189 cls = type (self )
185- return cls (self .joint_name , self .value , self .tolerance , self .weight )
190+ return cls (self .joint_name , self .value , self .tolerance_above , self . tolerance_below , self .weight )
186191
187192
188193class OrientationConstraint (Constraint ):
0 commit comments