def engine(): print("Creating UnrealCVWrapper") cv_wrapper = UnrealCVWrapper() print("Yielding UnrealCVWrapper") yield cv_wrapper print("Closing UnrealCVWrapper") cv_wrapper.close() print("Closed UnrealCVWrapper")
def _configure(self, client_id, remotes): address = '127.0.0.1' port = 9900 + client_id engine = UnrealCVWrapper( address=address, port=port, max_depth_viewing_angle=math_utils.degrees_to_radians(70.)) self._environment._engine = engine
pc = ros_utils.point_cloud2_ros_to_numpy(response.point_cloud) pc = np.unique(pc) bbox_mask = get_bbox_mask(pc, bounding_box) pc = pc[bbox_mask] print(pc.shape) uncertain_mask = get_uncertain_mask(pc) pc = pc[uncertain_mask] tentative_reward = len(pc) rospy.loginfo("Tentative reward: {}".format(tentative_reward)) rospy.loginfo("") raycast_pc_msg = response.point_cloud raycast_pc_msg.header.stamp = timestamp raycast_pc_msg.header.frame_id = 'map' raycast_pc_pub.publish(raycast_pc_msg) pc_xyz = ros_utils.structured_to_3d_array(pc) print("pc_xyz.shape: ", pc_xyz.shape) uncertain_pc_msg = ros_utils.point_cloud2_numpy_to_ros(pc_xyz) uncertain_pc_msg.header.stamp = timestamp uncertain_pc_msg.header.frame_id = 'map' uncertain_pc_pub.publish(uncertain_pc_msg) rate.sleep() if __name__ == '__main__': rospy.init_node('test_mapping', anonymous=False) engine = UnrealCVWrapper() raycast_topic = 'raycast_camera' location_origin = np.array([0, 0, 0]) run(engine, raycast_topic, location_origin)
# engine.set_orientation_rpy(roll, pitch, yaw) # Update camera location # engine.set_location(location) # rospy.logdebug("location: {} {} {}".format(*new_location)) # rospy.logdebug("rotation: {} {} {}".format(roll * 180 / np.pi, pitch * 180 / np.pi, yaw * 180 / np.pi)) # Read new pose, camera info and depth image depth_image = engine.get_depth_image() depth_point_cloud = engine.get_depth_point_cloud_rpy(engine.get_location(), engine.get_orientation_rpy()) # rospy.loginfo("mode={}, min depth={}, max depth={}".format( # mode, np.min(depth_image.flatten()), np.max(depth_image.flatten()))) # if mode == 0: # assert(np.min(depth_image) < 4) # elif mode == 1: # assert(np.min(depth_image) > 6) # elif mode == 2: # assert(np.min(depth_image) > 6) # else: # assert(np.min(depth_image) < 4) # Update camera state mode += 1 mode = mode % 4 rate.sleep() if __name__ == '__main__': rospy.init_node('test_depth_maps', anonymous=False) engine = UnrealCVWrapper(image_scale_factor=0.5) run(engine)