def configure_camera():
    main_camera = rospy.get_param("MAIN_CAMERA", DEFAULT_MAIN_CAMERA)
    sub_camera = rospy.get_param("SUB_CAMERA", DEFAULT_SUB_CAMERA)
    main_camera = CameraFactory.get_instance(main_camera)
    main_camera.topic_name = "main_camera"
    sub_camera = CameraFactory.get_instance(sub_camera)
    sub_camera.topic_name = "sub_camera"
    return main_camera, sub_camera
Example #2
0
    def update(self, state, delta_time):
        """Update camera with state and delta_time

        Only cameras that are instantiated will get reset
        """
        with self.lock:
            for camera_type in self.camera_types:
                camera_class = CameraFactory.get_class(camera_type)
                if camera_class.has_instance():
                    camera = CameraFactory.get_instance(camera_type)
                    camera.update_pose(state, delta_time)
Example #3
0
    def reset(self, state):
        """Reset camera pose

        Only cameras that are instantiated will get reset
        """
        with self.lock:
            for camera_type in self.camera_types:
                camera_class = CameraFactory.get_class(camera_type)
                if camera_class.has_instance():
                    camera = CameraFactory.get_instance(camera_type)
                    camera.reset_pose(state)
def configure_camera(namespaces=None, is_wait_for_model=True):
    """configure the top and follow car camear

    Args:
        namespaces (list): a list of all racecar namespace that top down and follow car
            cameras have to be configured
        is_wait_for_model (bool): boolean for whether wait for the racecar to be ready when
            configure to camera. The default value is True and we are waiting for racecar model
            for all besides virtual event because virtual event follow car camera does not follow
            a specific car at all time

    Returns:
        tuple(list(FollowCarCamera), TopCamera): tuple of a list of FollowCarCamera instance and
        a TopCamera instance
    """
    namespaces = namespaces or ["racecar"]
    global is_configure_camera_called
    with configure_camera_function_lock:
        if not is_configure_camera_called:
            is_configure_camera_called = True
            main_camera_type = rospy.get_param("MAIN_CAMERA",
                                               DEFAULT_MAIN_CAMERA)
            sub_camera_type = rospy.get_param("SUB_CAMERA", DEFAULT_SUB_CAMERA)
            main_cameras = dict()
            for namespace in namespaces:
                if is_wait_for_model:
                    wait_for_model(model_name=namespace,
                                   relative_entity_name="")
                main_cameras[namespace] = CameraFactory.create_instance(
                    camera_type=main_camera_type,
                    model_name="/{}/{}".format(namespace, "main_camera"),
                    namespace=namespace,
                )
            sub_camera = CameraFactory.create_instance(
                camera_type=sub_camera_type,
                model_name="/{}".format("sub_camera"),
                namespace=namespace,
            )
            return main_cameras, sub_camera
        else:
            err_msg = (
                "configure_camera called more than once. configure_camera MUST be called ONLY once!"
            )
            raise GenericRolloutException(err_msg)
def configure_camera(namespaces=["racecar"]):
    global is_configure_camera_called
    with configure_camera_function_lock:
        if not is_configure_camera_called:
            is_configure_camera_called = True
            main_camera_type = rospy.get_param("MAIN_CAMERA",
                                               DEFAULT_MAIN_CAMERA)
            sub_camera_type = rospy.get_param("SUB_CAMERA", DEFAULT_SUB_CAMERA)
            main_camera = dict()
            for namespace in namespaces:
                main_camera[namespace] = CameraFactory.create_instance(
                    camera_type=main_camera_type,
                    topic_name="/{}/{}".format(namespace, "main_camera"),
                    namespace=namespace)
            sub_camera = CameraFactory.create_instance(
                camera_type=sub_camera_type,
                topic_name="/{}".format("sub_camera"),
                namespace=namespace)
            return main_camera, sub_camera
        else:
            err_msg = "configure_camera called more than once. configure_camera MUST be called ONLY once!"
            raise GenericRolloutException(err_msg)
def configure_camera(namespaces=None):
    namespaces = namespaces or ["racecar"]
    global is_configure_camera_called
    with configure_camera_function_lock:
        if not is_configure_camera_called:
            is_configure_camera_called = True
            main_camera_type = rospy.get_param("MAIN_CAMERA",
                                               DEFAULT_MAIN_CAMERA)
            sub_camera_type = rospy.get_param("SUB_CAMERA", DEFAULT_SUB_CAMERA)
            main_cameras = dict()
            for namespace in namespaces:
                wait_for_model(model_name=namespace, relative_entity_name="")
                main_cameras[namespace] = CameraFactory.create_instance(
                    camera_type=main_camera_type,
                    model_name="/{}/{}".format(namespace, "main_camera"),
                    namespace=namespace)
            sub_camera = CameraFactory.create_instance(
                camera_type=sub_camera_type,
                model_name="/{}".format("sub_camera"),
                namespace=namespace)
            return main_cameras, sub_camera
        else:
            err_msg = "configure_camera called more than once. configure_camera MUST be called ONLY once!"
            raise GenericRolloutException(err_msg)