Skip to content

Commit

Permalink
Fix load_link_stats function
Browse files Browse the repository at this point in the history
  • Loading branch information
fsuarez6 committed Jan 2, 2018
1 parent 80e9961 commit 41fb62f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/raveutils/kinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,14 @@ def load_link_stats(robot, xyzdelta=0.01, autogenerate=True):
success: bool
`True` if succeeded, `False` otherwise
"""
success = False
success = True
statsmodel = orpy.databases.linkstatistics.LinkStatisticsModel(robot)
if not statsmodel.load() and autogenerate:
print 'Generating LinkStatistics database. Will take ~1 minute...'
statsmodel.autogenerate()
if statsmodel.load():
statsmodel.setRobotWeights()
statsmodel.setRobotResolutions(xyzdelta=xyzdelta)
success = True
else:
manip = robot.GetActiveManipulator()
indices = manip.GetArmIndices()
Expand All @@ -254,7 +253,11 @@ def load_link_stats(robot, xyzdelta=0.01, autogenerate=True):
jweights[i] = np.sum(jweights[i:])
robot_weights = np.ones(robot.GetDOF())
robot_weights[indices] = np.array(jweights) / np.max(jweights)
robot.SetDOFWeights(robot_weights)
if np.all(robot_weights >= br._EPS):
# All the weights have to be greater than 0
robot.SetDOFWeights(robot_weights)
else:
success = False
return success

def random_joint_values(robot):
Expand Down

0 comments on commit 41fb62f

Please sign in to comment.