Skip to content

Commit 6ec076b

Browse files
committed
Merge pull request #107 from personalrobotics/bugfix/OMPLFailureCheck
Fixed the OMPL planner creation test
2 parents 0873c50 + 45c2fe1 commit 6ec076b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/prpy/planning/ompl.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,20 @@
3636

3737
logger = logging.getLogger('pypy.planning.ompl')
3838

39+
3940
class OMPLPlanner(BasePlanner):
4041
def __init__(self, algorithm='RRTConnect'):
4142
super(OMPLPlanner, self).__init__()
4243

4344
self.setup = False
4445
self.algorithm = algorithm
4546

46-
try:
47-
self.planner = openravepy.RaveCreatePlanner(self.env, 'OMPL_' + algorithm)
48-
except openravepy.openrave_exception:
49-
raise UnsupportedPlanningError('Unable to create OMPL planner.')
47+
planner_name = 'OMPL_{:s}'.format(algorithm)
48+
self.planner = openravepy.RaveCreatePlanner(self.env, planner_name)
49+
50+
if self.planner is None:
51+
raise UnsupportedPlanningError(
52+
'Unable to create "{:s}" planner.'.format(planner_name))
5053

5154
def __str__(self):
5255
return 'OMPL {0:s}'.format(self.algorithm)
@@ -118,6 +121,7 @@ def _TSRPlan(self, robot, tsrchains, **kw_args):
118121

119122
return self._Plan(robot, formatted_extra_params=extraParams, **kw_args)
120123

124+
121125
class RRTConnect(OMPLPlanner):
122126
def __init__(self):
123127
OMPLPlanner.__init__(self, algorithm='RRTConnect')
@@ -185,10 +189,12 @@ class OMPLSimplifier(BasePlanner):
185189
def __init__(self):
186190
super(OMPLSimplifier, self).__init__()
187191

188-
try:
189-
self.planner = openravepy.RaveCreatePlanner(self.env, 'OMPL_Simplifier')
190-
except openravepy.openrave_exception:
191-
raise UnsupportedPlanningError('Unable to create OMPL planner.')
192+
planner_name = 'OMPL_Simplifier'
193+
self.planner = openravepy.RaveCreatePlanner(self.env, planner_name)
194+
195+
if self.planner is None:
196+
raise UnsupportedPlanningError(
197+
'Unable to create OMPL_Simplifier planner.')
192198

193199
def __str__(self):
194200
return 'OMPL Simplifier'

0 commit comments

Comments
 (0)