@@ -869,33 +869,40 @@ def constraints_from_frame(self, frame_WCF, tolerance_position, tolerances_axes,
869869 oc = self .orientation_constraint_from_frame (frame_WCF , tolerances_axes , group )
870870 return [pc , oc ]
871871
872- def constraints_from_configuration (self , configuration , tolerances , group = None ):
872+ def constraints_from_configuration (self , configuration , tolerances_above , tolerances_below , group = None ):
873873 """Returns joint constraints on all joints of the configuration.
874874
875875 Parameters
876876 ----------
877877 configuration: :class:`compas_fab.robots.Configuration`
878878 The target configuration.
879- tolerances: list of float
880- The tolerances (as +/-) on each of the joints defining the bound in radian
881- to be achieved. If only one value is passed it will be used to create
882- bounds for all joint constraints.
879+ tolerances_above: list of float
880+ The tolerances above the targeted configuration's joint value on each
881+ of the joints, defining the upper bound in radian to be achieved.
882+ If only one value is passed, it will be used to create upper bounds
883+ for all joint constraints.
884+ tolerances_below: list of float
885+ The tolerances below the targeted configuration's joint value on each
886+ of the joints, defining the upper bound in radian to be achieved.
887+ If only one value is passed, it will be used to create lower bounds
888+ for all joint constraints.
883889 group: str, optional
884890 The planning group for which we specify the constraint. Defaults to
885891 the robot's main planning group.
886892
887893 Examples
888894 --------
889895 >>> configuration = Configuration.from_revolute_values([-0.042, 4.295, -4.110, -3.327, 4.755, 0.])
890- >>> tolerances = [math.radians(5)] * 6
896+ >>> tolerances_above = [math.radians(1)] * 6
897+ >>> tolerances_below = [math.radians(1)] * 6
891898 >>> group = robot.main_group_name
892- >>> robot.constraints_from_configuration(configuration, tolerances , group)
893- [JointConstraint('shoulder_pan_joint', -0.042, 0.08726646259971647 , 1.0), \
894- JointConstraint('shoulder_lift_joint', 4.295, 0.08726646259971647 , 1.0), \
895- JointConstraint('elbow_joint', -4.11, 0.08726646259971647 , 1.0), \
896- JointConstraint('wrist_1_joint', -3.327, 0.08726646259971647 , 1.0), \
897- JointConstraint('wrist_2_joint', 4.755, 0.08726646259971647 , 1.0), \
898- JointConstraint('wrist_3_joint', 0.0, 0.08726646259971647 , 1.0)]
899+ >>> robot.constraints_from_configuration(configuration, tolerances_above, tolerances_below , group)
900+ [JointConstraint('shoulder_pan_joint', -0.042, 0.017453292519943295, 0.017453292519943295 , 1.0), \
901+ JointConstraint('shoulder_lift_joint', 4.295, 0.017453292519943295, 0.017453292519943295 , 1.0), \
902+ JointConstraint('elbow_joint', -4.11, 0.017453292519943295, 0.017453292519943295 , 1.0), \
903+ JointConstraint('wrist_1_joint', -3.327, 0.017453292519943295, 0.017453292519943295 , 1.0), \
904+ JointConstraint('wrist_2_joint', 4.755, 0.017453292519943295, 0.017453292519943295 , 1.0), \
905+ JointConstraint('wrist_3_joint', 0.0, 0.017453292519943295, 0.017453292519943295 , 1.0)]
899906
900907 Raises
901908 ------
@@ -917,15 +924,20 @@ def constraints_from_configuration(self, configuration, tolerances, group=None):
917924 if len (joint_names ) != len (configuration .values ):
918925 raise ValueError ("The passed configuration has %d values, the group %s needs however: %d" % (
919926 len (configuration .values ), group , len (joint_names )))
920- if len (tolerances ) == 1 :
921- tolerances = tolerances * len (joint_names )
922- elif len (tolerances ) != len (configuration .values ):
923- raise ValueError ("The passed configuration has %d values, the tolerances however: %d" % (
924- len (configuration .values ), len (tolerances )))
927+ if len (tolerances_above ) == 1 :
928+ tolerances_above = tolerances_above * len (joint_names )
929+ elif len (tolerances_above ) != len (configuration .values ):
930+ raise ValueError ("The passed configuration has %d values, the tolerances_above however: %d" % (
931+ len (configuration .values ), len (tolerances_above )))
932+ if len (tolerances_below ) == 1 :
933+ tolerances_below = tolerances_below * len (joint_names )
934+ elif len (tolerances_below ) != len (configuration .values ):
935+ raise ValueError ("The passed configuration has %d values, the tolerances_below however: %d" % (
936+ len (configuration .values ), len (tolerances_below )))
925937
926938 constraints = []
927- for name , value , tolerance in zip (joint_names , configuration .values , tolerances ):
928- constraints .append (JointConstraint (name , value , tolerance ))
939+ for name , value , tolerance_above , tolerance_below in zip (joint_names , configuration .values , tolerances_above , tolerances_below ):
940+ constraints .append (JointConstraint (name , value , tolerance_above , tolerance_below ))
929941 return constraints
930942
931943 # ==========================================================================
@@ -1254,9 +1266,10 @@ def plan_motion(self, goal_constraints, start_configuration=None,
12541266 1.0
12551267 >>> # Example with joint constraints (to the UP configuration)
12561268 >>> configuration = Configuration.from_revolute_values([0.0, -1.5707, 0.0, -1.5707, 0.0, 0.0])
1257- >>> tolerances = [math.radians(5)] * 6
1269+ >>> tolerances_above = [math.radians(5)] * len(configuration.values)
1270+ >>> tolerances_below = [math.radians(5)] * len(configuration.values)
12581271 >>> group = robot.main_group_name
1259- >>> goal_constraints = robot.constraints_from_configuration(configuration, tolerances , group)
1272+ >>> goal_constraints = robot.constraints_from_configuration(configuration, tolerances_above, tolerances_below , group)
12601273 >>> trajectory = robot.plan_motion(goal_constraints, start_configuration, group, planner_id='RRT')
12611274 >>> trajectory.fraction
12621275 1.0
0 commit comments