Skip to content

Commit 3b8b2b7

Browse files
committed
Merge pull request #221 from personalrobotics/trajopt_tests
Trajopt tests and ConstraintViolationPlanningError modified.
2 parents 3e17aae + 0b6dea6 commit 3b8b2b7

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

src/prpy/planning/exceptions.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ class UnsupportedPlanningError(PlanningError):
88

99

1010
class ConstraintViolationPlanningError(PlanningError):
11+
def __init__(self,
12+
constraint_name,
13+
threshold = None,
14+
violation_by = None,
15+
base_message='Violates constraint'):
16+
self.constraint_name = constraint_name
17+
self.threshold = threshold
18+
self.violation_by = violation_by
19+
20+
super(ConstraintViolationPlanningError, self).__init__(
21+
'{:s}: {:s}'.format(
22+
base_message,
23+
self.constraint_name
24+
)
25+
)
26+
1127
pass
1228

1329

tests/planning/methods/PlanToEndEffectorOffset.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from prpy.planning.exceptions import (
55
CollisionPlanningError,
66
SelfCollisionPlanningError,
7+
ConstraintViolationPlanningError,
78
JointLimitError)
89

910

@@ -113,18 +114,37 @@ def test_PlanToEndEffectorOffset_GoalInSelfCollision_Throws(self):
113114

114115
class PlanToEndEffectorOffsetCollisionTest(object):
115116
""" Expects collision-specific error"""
117+
def setUp(self):
118+
self.direction = numpy.array([ 0., 0., 1. ])
119+
self.distance = 0.1
116120

117121
def test_PlanToEndEffectorOffset_StartInCollision_Throws_CollisionError(self):
118122
# Setup
119123
with self.env:
120124
self.robot.SetActiveDOFValues(self.config_feasible_goal)
121125
goal_ik = self.manipulator.GetEndEffectorTransform()
122-
123126
self.robot.SetActiveDOFValues(self.config_env_collision)
124127

125128
# Test/Assert
126129
with self.assertRaises((CollisionPlanningError,
127130
SelfCollisionPlanningError,
128-
JointLimitError)):
131+
JointLimitError,
132+
ConstraintViolationPlanningError
133+
)):
134+
self.planner.PlanToEndEffectorOffset(
135+
self.robot, direction=self.direction, distance=self.distance)
136+
137+
def test_PlanToEndEffectorOffset_GoalInEnvCollision_Throws_CollisionError(self):
138+
# Setup
139+
with self.env:
140+
self.robot.SetActiveDOFValues(
141+
PlanToEndEffectorOffsetTest.config_infeasible_env_movement)
142+
143+
# Test/Assert
144+
with self.assertRaises((CollisionPlanningError,
145+
SelfCollisionPlanningError,
146+
JointLimitError,
147+
ConstraintViolationPlanningError,
148+
)):
129149
self.planner.PlanToEndEffectorOffset(
130-
self.robot, direction=self.direction, distance=self.distance)
150+
self.robot, direction=self.direction, distance=self.distance)

tests/planning/test_TrajoptPlanner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
)
66
from methods.PlanToConfiguration import PlanToConfigurationTestCollisionTest
77
from planning_helpers import BasePlannerTest
8-
from prpy.planning.snap import SnapPlanner
98
from unittest import TestCase
109
from or_trajopt import TrajoptPlanner
1110

11+
1212
class TrajoptPlannerTest(BasePlannerTest,
1313
PlanToConfigurationTest,
14-
PlanToConfigurationStraightLineTest,
1514
PlanToEndEffectorPoseTest,
15+
PlanToConfigurationTestCollisionTest,
1616
TestCase):
1717
planner_factory = TrajoptPlanner
1818

0 commit comments

Comments
 (0)