Skip to content

Commit 09bd2b8

Browse files
committed
Convert constraints on cartesian and kinematic planners
1 parent 91a1b19 commit 09bd2b8

File tree

1 file changed

+9
-32
lines changed

1 file changed

+9
-32
lines changed

src/compas_fab/backends/ros/planner_backend_moveit.py

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from compas_fab.backends.ros.messages import PositionConstraint
3434
from compas_fab.backends.ros.messages import PositionIKRequest
3535
from compas_fab.backends.ros.messages import RobotState
36+
from compas_fab.backends.ros.messages import TrajectoryConstraints
3637
from compas_fab.backends.ros.planner_backend import PlannerBackend
3738
from compas_fab.backends.ros.planner_backend import ServiceDescription
3839
from compas_fab.robots import Configuration
@@ -206,6 +207,8 @@ def plan_cartesian_motion_async(self, callback, errback,
206207
aco = AttachedCollisionObject.from_attached_collision_mesh(acm)
207208
start_state.attached_collision_objects.append(aco)
208209

210+
path_constraints = self._convert_constraints_to_rosmsg(path_constraints, header)
211+
209212
request = dict(header=header,
210213
start_state=start_state,
211214
group_name=group,
@@ -264,38 +267,12 @@ def plan_motion_async(self, callback, errback,
264267
aco = AttachedCollisionObject.from_attached_collision_mesh(acm)
265268
start_state.attached_collision_objects.append(aco)
266269

267-
# goal constraints
268-
constraints = Constraints()
269-
for c in goal_constraints:
270-
if c.type == c.JOINT:
271-
constraints.joint_constraints.append(
272-
JointConstraint.from_joint_constraint(c))
273-
elif c.type == c.POSITION:
274-
constraints.position_constraints.append(
275-
PositionConstraint.from_position_constraint(header, c))
276-
elif c.type == c.ORIENTATION:
277-
constraints.orientation_constraints.append(
278-
OrientationConstraint.from_orientation_constraint(header, c))
279-
else:
280-
raise NotImplementedError
281-
goal_constraints = [constraints]
282-
283-
# path constraints
284-
if path_constraints:
285-
constraints = Constraints()
286-
for c in path_constraints:
287-
if c.type == c.JOINT:
288-
constraints.joint_constraints.append(
289-
JointConstraint.from_joint_constraint(c))
290-
elif c.type == c.POSITION:
291-
constraints.position_constraints.append(
292-
PositionConstraint.from_position_constraint(header, c))
293-
elif c.type == c.ORIENTATION:
294-
constraints.orientation_constraints.append(
295-
OrientationConstraint.from_orientation_constraint(header, c))
296-
else:
297-
raise NotImplementedError
298-
path_constraints = constraints
270+
# convert constraints
271+
goal_constraints = [self._convert_constraints_to_rosmsg(goal_constraints, header)]
272+
path_constraints = self._convert_constraints_to_rosmsg(path_constraints, header)
273+
274+
if trajectory_constraints is not None:
275+
trajectory_constraints = TrajectoryConstraints(constraints=self._convert_constraints_to_rosmsg(path_constraints, header))
299276

300277
request = dict(start_state=start_state,
301278
goal_constraints=goal_constraints,

0 commit comments

Comments
 (0)