fastdev.sim_webui.webui ======================= .. py:module:: fastdev.sim_webui.webui Module Contents --------------- .. py:data:: AssetType .. py:data:: JointValues .. py:data:: JointValuesLike .. py:data:: Poses .. py:data:: PosesLike .. py:data:: Vertices .. py:data:: VerticesLike .. py:data:: FacesLike .. py:data:: Color .. py:data:: ColorLike .. py:data:: ScaleLike .. py:data:: AxesPositions .. py:data:: AxesPositionsLike .. py:data:: AxesWXYZs .. py:data:: AxesWXYZsLike .. py:class:: ViserAsset .. py:attribute:: viser_asset_id :type: str .. py:attribute:: viser_asset_type :type: Literal['trimesh', 'point_cloud', 'axes'] .. py:attribute:: color :type: Optional[Color] :value: None .. py:attribute:: scale :type: float :value: 1.0 .. py:attribute:: trimesh_mesh :type: Optional[trimesh.Trimesh] :value: None .. py:attribute:: points :type: Optional[Vertices] :value: None .. py:attribute:: point_size :type: float :value: 0.02 .. py:attribute:: axes_positions :type: Optional[AxesPositions] :value: None .. py:attribute:: axes_wxyzs :type: Optional[AxesWXYZs] :value: None .. py:attribute:: axes_length :type: float :value: 0.1 .. py:attribute:: axes_radius :type: float :value: 0.005 .. py:class:: ViserAssetState .. py:attribute:: asset_id :type: str .. py:attribute:: viser_asset_id :type: str .. py:attribute:: position :type: jaxtyping.Float[numpy.ndarray, 3] .. py:attribute:: wxyz :type: jaxtyping.Float[numpy.ndarray, 4] .. py:class:: Asset Bases: :py:obj:`abc.ABC` Base asset class. .. py:attribute:: asset_id :type: str .. py:class:: MeshAsset Bases: :py:obj:`Asset` Base asset class. .. py:attribute:: trimesh_mesh :type: trimesh.Trimesh .. py:method:: get_viser_asset(viser_asset_id: str) -> ViserAsset .. py:method:: get_or_create_asset_id(color: Optional[Color], scale: float, postfix: int = 0) -> str .. py:class:: PointCloudAsset Bases: :py:obj:`Asset` Base asset class. .. py:attribute:: points :type: Vertices .. py:method:: get_viser_asset(viser_asset_id: str) -> ViserAsset .. py:method:: get_or_create_asset_id(color: Optional[Color], point_size: float) -> str .. py:class:: AxesAsset Bases: :py:obj:`Asset` Base asset class. .. py:attribute:: positions :type: AxesPositions .. py:attribute:: wxyzs :type: AxesWXYZs .. py:method:: get_viser_asset(viser_asset_id: str) -> ViserAsset .. py:method:: get_or_create_asset_id(axes_length: float, axes_radius: float) -> str .. py:class:: RobotAsset Bases: :py:obj:`Asset` Base asset class. .. py:attribute:: robot_model :type: fastdev.robo.articulation.Articulation .. py:method:: get_viser_asset(viser_asset_id: str) -> ViserAsset .. py:method:: get_or_create_asset_id(link_name: str, color: Color) -> str .. py:class:: AssetLibrary Asset library for multiple assets. .. py:method:: add_robot_asset(urdf_or_mjcf_path: Optional[str] = None, mesh_dir: Optional[str] = None, articulation: Optional[fastdev.robo.articulation.Articulation] = None) -> str .. py:method:: add_mesh_asset(trimesh_mesh: trimesh.Trimesh, disable_cache: bool = False) -> str .. py:method:: add_point_cloud_asset(points: Vertices) -> str .. py:method:: add_axes_asset(positions: AxesPositions, wxyzs: AxesWXYZs) -> str .. py:method:: asset_exists(asset_id: str) -> bool .. py:method:: get_asset(asset_id: str) -> Asset .. py:method:: get_viser_asset(asset_id: str, viser_asset_id: str) -> ViserAsset .. py:method:: get_random_asset_id() -> str :staticmethod: .. py:data:: ASSET_LIBRARY .. py:function:: to_wxyz(rot: Optional[AxesWXYZsLike]) -> jaxtyping.Float[numpy.ndarray, ... 4] .. py:function:: to_position_wxyz(pose: Optional[PosesLike]) -> Tuple[jaxtyping.Float[numpy.ndarray, ... 3], jaxtyping.Float[numpy.ndarray, ... 4]] .. py:function:: get_random_color(r: Tuple[int, int] = (51, 180), g: Tuple[int, int] = (102, 204), b: Tuple[int, int] = (0, 102)) -> Color .. py:function:: to_color_array(color: None) -> None to_color_array(color: ColorLike) -> Color .. py:class:: AssetState Bases: :py:obj:`abc.ABC` Asset state for multiple frames. .. py:attribute:: asset_id :type: str .. py:property:: num_frames :type: int :abstractmethod: .. py:method:: get_frame_viser_asset_states(frame_index: int) -> List[ViserAssetState] :abstractmethod: .. py:class:: MeshState Bases: :py:obj:`AssetState` Asset state for multiple frames. .. py:attribute:: poses :type: Optional[Poses] :value: None .. py:attribute:: color :type: Optional[Color] :value: None .. py:attribute:: scale :type: float :value: 1.0 .. py:property:: frame_range :type: Tuple[int, int] .. py:property:: num_frames :type: int .. py:method:: get_frame_viser_asset_states(frame_index: int) -> List[ViserAssetState] .. py:class:: PointCloudState Bases: :py:obj:`AssetState` Asset state for multiple frames. .. py:attribute:: poses :type: Optional[Poses] :value: None .. py:attribute:: color :type: Optional[Color] :value: None .. py:attribute:: point_size :type: float :value: 0.02 .. py:property:: frame_range :type: Tuple[int, int] .. py:property:: num_frames :type: int .. py:method:: get_frame_viser_asset_states(frame_index: int) -> List[ViserAssetState] .. py:class:: AxesState Bases: :py:obj:`AssetState` Asset state for multiple frames. .. py:attribute:: poses :type: Optional[Poses] :value: None .. py:attribute:: axes_length :type: float :value: 0.1 .. py:attribute:: axes_radius :type: float :value: 0.005 .. py:property:: num_frames :type: int .. py:method:: get_frame_viser_asset_states(frame_index: int) -> List[ViserAssetState] .. py:class:: RobotState Bases: :py:obj:`AssetState` Asset state for multiple frames. .. py:attribute:: joint_values :type: Optional[JointValues] :value: None .. py:attribute:: root_poses :type: Optional[Poses] :value: None .. py:attribute:: color :type: Color .. py:property:: num_frames :type: int .. py:method:: get_frame_viser_asset_states(frame_index: int) -> List[ViserAssetState] .. py:class:: SceneState Scene state for multiple assets and frames. .. py:method:: set_robot_state(asset_id: str, joint_values: Optional[JointValues] = None, root_poses: Optional[Poses] = None, color: Color = _DEFAULT_ROBOT_COLOR) .. py:method:: set_mesh_state(asset_id: str, poses: Optional[Poses] = None, scale: float = 1.0, color: Optional[Color] = None, frame_range: Optional[Tuple[int, int]] = None) .. py:method:: set_point_cloud_state(asset_id: str, poses: Optional[Poses] = None, point_size: float = 0.02, color: Optional[Color] = None, frame_range: Optional[Tuple[int, int]] = None) .. py:method:: set_axes_state(asset_id: str, poses: Optional[Poses] = None, axes_length: float = 0.1, axes_radius: float = 0.005) .. py:property:: num_frames :type: int .. py:property:: last_updated :type: float .. py:method:: get_frame_viser_asset_states(frame_index: int) -> List[ViserAssetState] .. py:method:: __repr__() -> str .. py:method:: __str__() -> str .. py:class:: StateManager State manager for multiple scenes. .. py:method:: set_robot_state(asset_id: str, scene_index: int, joint_values: Optional[JointValues] = None, root_poses: Optional[Poses] = None, color: Color = _DEFAULT_ROBOT_COLOR) .. py:method:: set_mesh_state(asset_id: str, scene_index: int, poses: Optional[Poses] = None, scale: float = 1.0, color: Optional[Color] = None, frame_range: Optional[Tuple[int, int]] = None) .. py:method:: set_point_cloud_state(asset_id: str, scene_index: int, poses: Optional[Poses] = None, point_size: float = 1.0, color: Optional[Color] = None, frame_range: Optional[Tuple[int, int]] = None) .. py:method:: set_axes_state(asset_id: str, scene_index: int, poses: Optional[Poses] = None, axes_length: float = 0.1, axes_radius: float = 0.005) .. py:method:: get_scene_num_frames(scene_index: int) -> int .. py:method:: get_scene_last_updated(scene_index: int) -> float .. py:method:: get_frame_viser_asset_states(scene_index: int, frame_index: int) -> List[ViserAssetState] .. py:property:: num_scenes :type: int .. py:method:: validate_scene_index(scene_index: int) -> bool Validate the scene index. Valid scene index should be in the range [0, num_scenes], including both ends. When the scene index equals to num_scenes, it means the scene is the new scene to be added. :param scene_index: Scene index. :type scene_index: int .. py:method:: reset() .. py:method:: __getitem__(scene_index: int) -> SceneState .. py:method:: __repr__() -> str .. py:method:: __str__() -> str .. py:data:: IS_PLAYING_EVENT .. py:class:: ViserHelper(state_manager: StateManager, host: str = 'localhost', port: int = 8080, enable_geometry_option: bool = False) Helper class for Viser server. .. py:method:: update_server(*args, **kwargs) Update the Viser server. .. py:method:: reset() .. py:class:: SimWebUI(host: str = 'localhost', port: int = 8080, enable_geometry_option: bool = False) WebUI for simulator and 3D scene visualization. .. py:method:: __repr__() -> str .. py:method:: __str__() -> str .. py:property:: scene_index :type: int .. py:method:: set_scene_index(value: int) .. py:method:: add_robot_asset(urdf_or_mjcf_path: Optional[Union[str, pathlib.Path]] = None, mesh_dir: Optional[Union[str, pathlib.Path]] = None, articulation: Optional[fastdev.robo.articulation.Articulation] = None) -> str Add a robot asset to the asset library. :param urdf_or_mjcf_path: Path to the URDF or MJCF file of the robot. :type urdf_or_mjcf_path: Union[str, Path] :param mesh_dir: Directory path of the robot meshes. Will use the directory of the URDF/MJCF file if not provided. Defaults to None. :type mesh_dir: Optional[Union[str, Path]], optional :returns: Asset ID of the robot asset. :rtype: str .. py:method:: add_mesh_asset(vertices: Optional[VerticesLike] = None, faces: Optional[FacesLike] = None, trimesh_mesh: Optional[trimesh.Trimesh] = None, mesh_path: Optional[Union[str, pathlib.Path]] = None, disable_cache: bool = False) -> str Add a mesh asset to the asset library. :param vertices: Vertices of the mesh. Defaults to None. :type vertices: Optional[VerticesLike], optional :param faces: Faces of the mesh. Defaults to None. :type faces: Optional[FacesLike], optional :param trimesh_mesh: Trimesh mesh object. Defaults to None. :type trimesh_mesh: Optional[trimesh.Trimesh], optional :param mesh_path: Path to the mesh file. Defaults to None. :type mesh_path: Optional[Union[str, Path]], optional :returns: Asset ID of the mesh asset. :rtype: str .. note:: Either trimesh_mesh or vertices and faces or mesh_path must be provided, but not both. .. py:method:: add_sphere_asset(radius: ScaleLike, subdivisions: int = 3, disable_cache: bool = False) -> str Add a single sphere asset to the asset library. :param radius: Radius of the sphere. :type radius: float :param subdivisions: Number of subdivisions. Defaults to 3. :type subdivisions: int, optional :returns: Asset ID of the sphere asset. :rtype: str .. py:method:: add_point_cloud_asset(points: VerticesLike) -> str Add a point cloud asset to the asset library. :param points: Points of the point cloud. :type points: VerticesLike :returns: Asset ID of the point cloud asset. :rtype: str .. py:method:: add_axes_asset(positions: AxesPositionsLike, rotations: AxesWXYZsLike) -> str Add an axes asset to the asset library. :param positions: Positions of the axes. :type positions: AxesPositionLike :param rotations: Rotations of the axes, could be in rotation matrices or wxyz quaternions. :type rotations: AxesWXYZsLike :returns: Asset ID of the axes asset. :rtype: str .. py:method:: set_robot_state(asset_id: str, scene_index: Optional[int] = None, joint_values: Optional[JointValuesLike] = None, root_poses: Optional[PosesLike] = None, color: ColorLike = 'silver') Set the state of a robot asset. :param asset_id: Asset ID of the robot asset. :type asset_id: str :param joint_values: Multi-frame (or single-frame) joint values. Defaults to None. :type joint_values: Optional[JointValuesT], optional :param root_poses: Multi-frame (or single-frame) root poses. Defaults to None. :type root_poses: Optional[PosesT], optional :param scene_index: Scene index. Defaults to None. :type scene_index: Optional[int], optional .. note:: The number of frames of the asset state is determined by the number of joint values provided. .. py:method:: set_mesh_state(asset_id: str, scene_index: Optional[int] = None, poses: Optional[PosesLike] = None, scale: ScaleLike = 1.0, color: Optional[ColorLike] = None, frame_range: Optional[Union[int, Tuple[int, int]]] = None) Set the state of a mesh asset. :param asset_id: Asset ID of the mesh asset. :type asset_id: str :param scene_index: Scene index. Defaults to None. :type scene_index: Optional[int], optional :param poses: Multi-frame (or single-frame) poses. Defaults to None. :type poses: Optional[PosesLike], optional :param scale: Scale factor. Defaults to 1.0. :type scale: ScaleLike, optional :param color: Color of the mesh, use random color if not provided. Defaults to None. :type color: ColorLike, optional .. note:: The number of frames of the asset state is determined by the number of poses provided. .. py:method:: set_sphere_state(asset_id: str, scene_index: Optional[int] = None, poses: Optional[PosesLike] = None, scale: ScaleLike = 1.0, color: Optional[ColorLike] = None, frame_range: Optional[Union[int, Tuple[int, int]]] = None) Set the state of a sphere asset. :param asset_id: Asset ID of the sphere asset. :type asset_id: str :param scene_index: Scene index. Defaults to None. :type scene_index: Optional[int], optional :param poses: Multi-frame (or single-frame) poses. Defaults to None. :type poses: Optional[PosesLike], optional :param scale: Scale factor. Defaults to 1.0. :type scale: ScaleLike, optional :param color: Color of the sphere. Defaults to None. :type color: Optional[ColorLike], optional .. note:: The number of frames of the asset state is determined by the number of poses provided. .. py:method:: set_point_cloud_state(asset_id: str, scene_index: Optional[int] = None, poses: Optional[PosesLike] = None, point_size: ScaleLike = 0.02, color: Optional[ColorLike] = None, frame_range: Optional[Union[int, Tuple[int, int]]] = None) Set the state of a point cloud asset. :param asset_id: Asset ID of the point cloud asset. :type asset_id: str :param scene_index: Scene index. Defaults to None. :type scene_index: Optional[int], optional :param poses: Multi-frame (or single-frame) poses. Defaults to None. :type poses: Optional[PosesLike], optional :param scale: Scale factor. Defaults to 1.0. :type scale: ScaleLike, optional :param color: Color of the point cloud. Defaults to None. :type color: Optional[ColorLike], optional .. note:: The number of frames of the asset state is determined by the number of poses provided. .. py:method:: set_axes_state(asset_id: str, scene_index: Optional[int] = None, axes_length: ScaleLike = 0.1, axes_radius: ScaleLike = 0.005, poses: Optional[PosesLike] = None) Set the state of a point cloud asset. :param asset_id: Asset ID of the point cloud asset. :type asset_id: str :param scene_index: Scene index. Defaults to None. :type scene_index: Optional[int], optional :param axes_length: Length of the axes. Defaults to 0.1. :type axes_length: ScaleLike, optional :param axes_radius: Radius of the axes. Defaults to 0.005. :type axes_radius: ScaleLike, optional :param poses: Multi-frame (or single-frame) poses. Defaults to None. :type poses: Optional[PosesLike], optional .. note:: The number of frames of the asset state is determined by the number of poses provided. .. py:method:: reset() Reset the state manager and Viser server.