Skip to content

Commit bdba407

Browse files
author
Michael Koval
committed
Print a warning if GetTrajectoryTags is not JSON.
1 parent 946e1dc commit bdba407

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/prpy/util.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
import logging, numpy, openravepy, scipy.misc, time, threading, math
3333
import scipy.optimize
3434

35+
36+
logger = logging.getLogger('prpy.util')
37+
38+
3539
def create_sensor(env, args, anonymous=True):
3640
sensor = openravepy.RaveCreateSensor(env, args)
3741
if sensor is None:
@@ -281,10 +285,16 @@ def GetTrajectoryTags(traj):
281285
"""
282286
import json
283287

284-
try:
285-
return json.loads(traj.GetDescription())
286-
except ValueError:
288+
description = traj.GetDescription()
289+
290+
if description == '':
287291
return dict()
292+
else:
293+
try:
294+
return json.loads(description)
295+
except ValueError as e:
296+
logger.warning('Failed reading tags from trajectory: %s', e.message)
297+
return dict()
288298

289299

290300
def SetTrajectoryTags(traj, tags, append=False):

0 commit comments

Comments
 (0)