def visualize_atoms(viewer, atoms): conf = get_config(atoms) holding = get_holding(atoms) viewer.draw_robot(ROBOT_ROW, conf) if holding is not None: viewer.draw_block(ROBOT_ROW, conf, color=get_color(holding)) for atom in atoms: if isinstance(atom, Atom) and atom.predicate == AtPose: b, p = atom.args viewer.draw_block(0, get_value(p), color=get_color(get_value(b)))
def visualize_atoms(viewer, atoms): for atom in atoms: if atom.predicate == AtConf: q, = atom.args viewer.draw_robot(get_value(q)) elif atom.predicate == AtPose: b, p = atom.args viewer.draw_block(get_value(b), get_value(p)) elif atom.predicate == Holding: b, = atom.args viewer.draw_holding(get_value(b), get_config(atoms))
def get_holding(atoms): for atom in atoms: if atom.predicate == Holding: b, = atom.args return get_value(b) return None
def get_config(atoms): for atom in atoms: if atom.predicate == AtConf: q, = atom.args return get_value(q) return None
def str_atom(atom): #return str(atom.predicate.name) + str(tuple(map(get_value, atom.args))) return atom.predicate.name + '(' + ' '.join( repr(get_value(arg)) for arg in atom.args) + ')'