@@ -949,33 +949,40 @@ def constraints_from_frame(self, frame_WCF, tolerance_position, tolerances_axes,
949949 oc = self .orientation_constraint_from_frame (frame_WCF , tolerances_axes , group )
950950 return [pc , oc ]
951951
952- def constraints_from_configuration (self , configuration , tolerances , group = None ):
952+ def constraints_from_configuration (self , configuration , tolerances_above , tolerances_below , group = None ):
953953 """Returns joint constraints on all joints of the configuration.
954954
955955 Parameters
956956 ----------
957957 configuration: :class:`compas_fab.robots.Configuration`
958958 The target configuration.
959- tolerances: list of float
960- The tolerances (as +/-) on each of the joints defining the bound in radian
961- to be achieved. If only one value is passed it will be used to create
962- bounds for all joint constraints.
959+ tolerances_above: list of float
960+ The tolerances above the targeted configuration's joint value on each
961+ of the joints, defining the upper bound in radian to be achieved.
962+ If only one value is passed, it will be used to create upper bounds
963+ for all joint constraints.
964+ tolerances_below: list of float
965+ The tolerances below the targeted configuration's joint value on each
966+ of the joints, defining the upper bound in radian to be achieved.
967+ If only one value is passed, it will be used to create lower bounds
968+ for all joint constraints.
963969 group: str, optional
964970 The planning group for which we specify the constraint. Defaults to
965971 the robot's main planning group.
966972
967973 Examples
968974 --------
969975 >>> configuration = Configuration.from_revolute_values([-0.042, 4.295, -4.110, -3.327, 4.755, 0.])
970- >>> tolerances = [math.radians(5)] * 6
976+ >>> tolerances_above = [math.radians(1)] * 6
977+ >>> tolerances_below = [math.radians(1)] * 6
971978 >>> group = robot.main_group_name
972- >>> robot.constraints_from_configuration(configuration, tolerances , group)
973- [JointConstraint('shoulder_pan_joint', -0.042, 0.08726646259971647 , 1.0), \
974- JointConstraint('shoulder_lift_joint', 4.295, 0.08726646259971647 , 1.0), \
975- JointConstraint('elbow_joint', -4.11, 0.08726646259971647 , 1.0), \
976- JointConstraint('wrist_1_joint', -3.327, 0.08726646259971647 , 1.0), \
977- JointConstraint('wrist_2_joint', 4.755, 0.08726646259971647 , 1.0), \
978- JointConstraint('wrist_3_joint', 0.0, 0.08726646259971647 , 1.0)]
979+ >>> robot.constraints_from_configuration(configuration, tolerances_above, tolerances_below , group)
980+ [JointConstraint('shoulder_pan_joint', -0.042, 0.0174532925199, 0.0174532925199 , 1.0), \
981+ JointConstraint('shoulder_lift_joint', 4.295, 0.0174532925199, 0.0174532925199 , 1.0), \
982+ JointConstraint('elbow_joint', -4.11, 0.0174532925199, 0.0174532925199 , 1.0), \
983+ JointConstraint('wrist_1_joint', -3.327, 0.0174532925199, 0.0174532925199 , 1.0), \
984+ JointConstraint('wrist_2_joint', 4.755, 0.0174532925199, 0.0174532925199 , 1.0), \
985+ JointConstraint('wrist_3_joint', 0.0, 0.0174532925199, 0.0174532925199 , 1.0)]
979986
980987 Raises
981988 ------
@@ -997,15 +1004,20 @@ def constraints_from_configuration(self, configuration, tolerances, group=None):
9971004 if len (joint_names ) != len (configuration .values ):
9981005 raise ValueError ("The passed configuration has %d values, the group %s needs however: %d" % (
9991006 len (configuration .values ), group , len (joint_names )))
1000- if len (tolerances ) == 1 :
1001- tolerances = tolerances * len (joint_names )
1002- elif len (tolerances ) != len (configuration .values ):
1003- raise ValueError ("The passed configuration has %d values, the tolerances however: %d" % (
1004- len (configuration .values ), len (tolerances )))
1007+ if len (tolerances_above ) == 1 :
1008+ tolerances_above = tolerances_above * len (joint_names )
1009+ elif len (tolerances_above ) != len (configuration .values ):
1010+ raise ValueError ("The passed configuration has %d values, the tolerances_above however: %d" % (
1011+ len (configuration .values ), len (tolerances_above )))
1012+ if len (tolerances_below ) == 1 :
1013+ tolerances_below = tolerances_below * len (joint_names )
1014+ elif len (tolerances_below ) != len (configuration .values ):
1015+ raise ValueError ("The passed configuration has %d values, the tolerances_below however: %d" % (
1016+ len (configuration .values ), len (tolerances_below )))
10051017
10061018 constraints = []
1007- for name , value , tolerance in zip (joint_names , configuration .values , tolerances ):
1008- constraints .append (JointConstraint (name , value , tolerance ))
1019+ for name , value , tolerance_above , tolerance_below in zip (joint_names , configuration .values , tolerances_above , tolerances_below ):
1020+ constraints .append (JointConstraint (name , value , tolerance_above , tolerance_below ))
10091021 return constraints
10101022
10111023 # ==========================================================================
0 commit comments