@@ -113,6 +113,27 @@ def dispose_planner(self):
113113 if hasattr (self , 'attached_collision_object_topic' ) and self .attached_collision_object_topic :
114114 self .attached_collision_object_topic .unadvertise ()
115115
116+ def _convert_constraints_to_rosmsg (self , constraints , header ):
117+ """Convert COMPAS FAB constraints into ROS Messages."""
118+ if not constraints :
119+ return None
120+
121+ ros_constraints = Constraints ()
122+ for c in constraints :
123+ if c .type == c .JOINT :
124+ ros_constraints .joint_constraints .append (
125+ JointConstraint .from_joint_constraint (c ))
126+ elif c .type == c .POSITION :
127+ ros_constraints .position_constraints .append (
128+ PositionConstraint .from_position_constraint (header , c ))
129+ elif c .type == c .ORIENTATION :
130+ ros_constraints .orientation_constraints .append (
131+ OrientationConstraint .from_orientation_constraint (header , c ))
132+ else :
133+ raise NotImplementedError
134+
135+ return ros_constraints
136+
116137 # ==========================================================================
117138 # planning services
118139 # ==========================================================================
@@ -132,22 +153,8 @@ def inverse_kinematics_async(self, callback, errback, frame, base_link, group,
132153 for acm in attached_collision_meshes :
133154 aco = AttachedCollisionObject .from_attached_collision_mesh (acm )
134155 start_state .attached_collision_objects .append (aco )
135-
136- # constraints
137- ik_constraints = Constraints ()
138- for c in constraints :
139- if c .type == c .JOINT :
140- ik_constraints .joint_constraints .append (
141- JointConstraint .from_joint_constraint (c ))
142- elif c .type == c .POSITION :
143- ik_constraints .position_constraints .append (
144- PositionConstraint .from_position_constraint (header , c ))
145- elif c .type == c .ORIENTATION :
146- ik_constraints .orientation_constraints .append (
147- OrientationConstraint .from_orientation_constraint (header , c ))
148- else :
149- raise NotImplementedError
150- constraints = ik_constraints
156+
157+ constraints = self ._convert_constraints_to_rosmsg (constraints , header )
151158
152159 ik_request = PositionIKRequest (group_name = group ,
153160 robot_state = start_state ,
0 commit comments