Skip to content

Instantly share code, notes, and snippets.

@zenfiric
Created August 21, 2017 11:29
Show Gist options
  • Save zenfiric/b2e4153c2ddd1e74bb7689c6906a0f81 to your computer and use it in GitHub Desktop.
Save zenfiric/b2e4153c2ddd1e74bb7689c6906a0f81 to your computer and use it in GitHub Desktop.
Load saved robots
@trollius.coroutine
def generate_population(self, n):
"""
Generates population of `n` valid robots robots.
:param n: Number of robots
:return: Future with a list of valid robot trees and corresponding
bounding boxes.
"""
yaml_robots = ['75', '76', '77', '78', '79',
'80', '81', '82', '83', '84',
'85', '86', '87', '88', '89',
'90', '91', '92', '93', '94', ]
trees = []
bboxes = []
body_spec = get_body_spec(self.conf)
brain_spec = get_brain_spec(self.conf)
for i in xrange(n):
robot_name = yaml_robots[i]
with open("robots/robot_{}.yaml".format(robot_name)) as yaml_file:
bot_yaml = yaml_file.read()
bot = yaml_to_robot(body_spec, brain_spec, bot_yaml)
robot_tree = Tree.from_body_brain(body=bot.body,
brain=bot.brain,
body_spec=body_spec)
ret = yield From(self.analyze_tree(robot_tree))
coll, bbox, robot = ret
# raise RuntimeError("Analyze is HERE")
# TODO: fill in trees and bboxes
trees.append(robot_tree)
bboxes.append(bbox)
raise Return(trees, bboxes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment