コード例 #1
0
  def fn(self, edge, object_name, object_pose):
    oracle = self.oracle
    preprocess_edge(oracle, edge)

    object_aabb = oracle.get_aabb(object_name, trans_from_pose(object_pose.value))
    object_aabb_min, object_aabb_max = aabb_min(object_aabb), aabb_max(object_aabb)
    configs = [q for q in edge.configs() if fast_aabb_overlap(object_aabb_min, object_aabb_max, q.aabbs)]
    if len(configs) == 0: return False

    #distance = oracle.get_radius2('pr2') + oracle.get_radius2(object_name)
    #z = get_point(oracle.robot)[-1]
    #configs = [q for q in edge.configs() if length2(np.array([q.value[-3], q.value[-2], z]) - point_from_pose(object_pose.value)) <= distance]
    #if len(configs) == 0: return False

    # TODO - oracle.robot.SetActiveDOFValues(q.value) is the bottleneck: check each object at the same time
    with oracle.body_saver(object_name):
      oracle.set_pose(object_name, object_pose)
      with oracle.robot_saver():
        CSpace.robot_arm_and_base(oracle.robot.GetActiveManipulator()).set_active()
        with collision_saver(oracle.env, openravepy_int.CollisionOptions.ActiveDOFs): # TODO - does this really do what I think?
          for q in configs: # TODO - do this with other other collision functions
            q.saver.Restore()
            if robot_collision(oracle, object_name):
              return True
    return False
コード例 #2
0
def openrave_base_iterator(oracle, manip_iterator, random_bases=True):
  if not hasattr(oracle, 'ir_model'):
    oracle.ir_model = get_openrave_ir(oracle, random_bases)
  index_manip_iterator = ((manip_trans, manip_trans) for manip_trans in manip_iterator)
  try:
    for base_pose, manip_trans, _ in oracle.ir_model.randomBaseDistributionIterator(index_manip_iterator) if random_bases else \
        oracle.ir_model.sampleBaseDistributionIterator(index_manip_iterator, logllthresh=-INF, Nprematuresamples=1):
      yield trans_from_pose(base_pose), manip_trans
  except (ValueError, planning_error): # ValueError: low >= high because of an empty sequence
    raise StopIteration