robokudo.io.semdt_raytracer_camera_interface ============================================ .. py:module:: robokudo.io.semdt_raytracer_camera_interface .. autoapi-nested-parse:: Simulated RGB-D camera interface backed by SemDT RayTracer. Classes ------- .. autoapisummary:: robokudo.io.semdt_raytracer_camera_interface.SemDTRayTracerCameraInterface Module Contents --------------- .. py:class:: SemDTRayTracerCameraInterface(camera_config) Bases: :py:obj:`robokudo.io.camera_interface.CameraInterface` Render RGB-D camera data from a Semantic Digital Twin world. The interface loads a configured world descriptor, places a virtual camera in that world, and writes the rendered color image, depth image, segmentation, camera model, and ground-truth world reference into the CAS. .. note:: The configured camera pose uses ROS optical-frame convention, while the SemDT ray tracer renders from a camera-link-like frame. .. py:attribute:: module_loader Loader used to import configured SemDT world descriptors. .. py:method:: has_new_data() -> bool Report whether rendered camera data is available. :return: Always ``True`` because simulated frames are rendered on demand. .. py:method:: set_data(cas: robokudo.cas.CAS) -> None Render a simulated RGB-D frame and write it into the CAS. :param cas: CAS that receives rendered camera data and frame metadata. .. py:method:: _load_runtime_world() -> semantic_digital_twin.world.World Load the configured SemDT world and install it as runtime world. :return: Runtime world instance used for rendering. .. py:method:: _ensure_world_frame(world: semantic_digital_twin.world.World) -> semantic_digital_twin.world_description.world_entity.Body Return the configured world frame body, creating it when needed. :param world: Runtime world that contains the scene and camera frames. :return: Body representing the configured world frame. .. py:method:: _ensure_camera_body(world: semantic_digital_twin.world.World, world_frame_body: semantic_digital_twin.world_description.world_entity.Body) -> semantic_digital_twin.world_description.world_entity.Body Return the configured camera body, creating it when needed. :param world: Runtime world that contains the scene and camera frames. :param world_frame_body: Parent frame for a newly created camera body. :return: Body representing the configured camera frame. .. py:method:: _set_camera_pose(world: semantic_digital_twin.world.World, world_frame_body: semantic_digital_twin.world_description.world_entity.Body, camera_body: semantic_digital_twin.world_description.world_entity.Body) -> Tuple[semantic_digital_twin.spatial_types.HomogeneousTransformationMatrix, semantic_digital_twin.spatial_types.HomogeneousTransformationMatrix] Apply the configured camera pose to the runtime world. :param world: Runtime world that owns the camera body connection. :param world_frame_body: Reference frame for the configured camera pose. :param camera_body: Camera frame body that receives the configured pose. :return: RayTracer render pose and ROS optical camera pose. .. py:method:: _camera_link_to_optical_np() -> numpy.ndarray :staticmethod: Return the transform from camera-link frame to ROS optical frame. :return: Numpy homogeneous transformation matrix. .. py:method:: _camera_optical_to_link_np() -> numpy.ndarray :staticmethod: Return the transform from ROS optical frame to camera-link frame. :return: Numpy homogeneous transformation matrix. .. py:method:: _render_segmentation_and_depth(ray_tracer: semantic_digital_twin.spatial_computations.raytracer.RayTracer, camera_to_world: semantic_digital_twin.spatial_types.HomogeneousTransformationMatrix, resolution: int, fov_deg: float, min_distance: float, max_distance: float) -> Tuple[numpy.ndarray, numpy.ndarray] :staticmethod: Render object segmentation and projective depth. :param ray_tracer: Renderer that creates camera rays and returns their scene intersections. :param camera_to_world: Camera pose used by the RayTracer renderer. :param resolution: Square image resolution. :param fov_deg: Horizontal camera field of view. :param min_distance: Minimum valid ray-hit distance. :param max_distance: Maximum valid ray-hit distance. :return: Segmentation indices and depth image in meters. .. py:method:: _render_color_image(world: semantic_digital_twin.world.World, ray_tracer, camera_to_world: semantic_digital_twin.spatial_types.HomogeneousTransformationMatrix, segmentation: numpy.ndarray, resolution: int, fov_deg: float) -> Tuple[numpy.ndarray, Dict[str, str]] Render a BGR color image for the current frame. :param world: Runtime world that provides semantic body colors. :param ray_tracer: SemDT ray tracer used for optional mesh rendering. :param camera_to_world: Camera pose used by the RayTracer renderer. :param segmentation: Body-index segmentation image. :param resolution: Square image resolution. :param fov_deg: Horizontal camera field of view. :return: BGR image and optional RGB-to-object-name color map. .. py:method:: _try_render_trimesh_rgb(ray_tracer, camera_to_world: semantic_digital_twin.spatial_types.HomogeneousTransformationMatrix, resolution: int, fov_deg: float) -> numpy.ndarray | None Render textured mesh colors through the RayTracer scene. :param ray_tracer: SemDT ray tracer that owns the Trimesh scene. :param camera_to_world: Camera pose used by the RayTracer renderer. :param resolution: Square image resolution. :param fov_deg: Horizontal camera field of view. :return: BGR image when rendering succeeds, otherwise ``None``. .. py:method:: _render_semantic_rgb(world: semantic_digital_twin.world.World, segmentation: numpy.ndarray) -> Tuple[numpy.ndarray, Dict[str, str]] Render deterministic semantic RGB colors from segmentation labels. :param world: Runtime world that maps body indices to bodies. :param segmentation: Body-index segmentation image. :return: RGB image and RGB-to-object-name color map. .. py:method:: _rgb_for_body(body: semantic_digital_twin.world_description.world_entity.Body) -> numpy.ndarray :staticmethod: Return the semantic RGB color for a world body. :param body: World body whose collision or visual color is used. :return: RGB color encoded as three unsigned bytes. .. py:method:: _depth_m_to_mm(depth_m: numpy.ndarray) -> numpy.ndarray :staticmethod: Convert meter depth values to unsigned millimeter depth values. :param depth_m: Depth image in meters with negative values for misses. :return: Depth image in millimeters with misses encoded as zero. .. py:method:: _build_camera_models(frame_id: str, resolution: int, fov_deg: float) -> Tuple[sensor_msgs.msg.CameraInfo, open3d.camera.PinholeCameraIntrinsic] :staticmethod: Build ROS and Open3D pinhole camera models. :param frame_id: Camera frame name stored in the ROS camera info header. :param resolution: Square image resolution. :param fov_deg: Horizontal camera field of view. :return: ROS camera info and matching Open3D intrinsic model.