fastdev.sim_webui.webui

Module Contents

fastdev.sim_webui.webui.AssetType[source]
fastdev.sim_webui.webui.JointValues[source]
fastdev.sim_webui.webui.JointValuesLike[source]
fastdev.sim_webui.webui.Poses[source]
fastdev.sim_webui.webui.PosesLike[source]
fastdev.sim_webui.webui.Vertices[source]
fastdev.sim_webui.webui.VerticesLike[source]
fastdev.sim_webui.webui.FacesLike[source]
fastdev.sim_webui.webui.Color[source]
fastdev.sim_webui.webui.ColorLike[source]
fastdev.sim_webui.webui.ScaleLike[source]
fastdev.sim_webui.webui.AxesPositions[source]
fastdev.sim_webui.webui.AxesPositionsLike[source]
fastdev.sim_webui.webui.AxesWXYZs[source]
fastdev.sim_webui.webui.AxesWXYZsLike[source]
class fastdev.sim_webui.webui.ViserAsset[source]
viser_asset_id: str[source]
viser_asset_type: Literal['trimesh', 'point_cloud', 'axes'][source]
color: Color | None = None[source]
scale: float = 1.0[source]
trimesh_mesh: trimesh.Trimesh | None = None[source]
points: Vertices | None = None[source]
point_size: float = 0.02[source]
axes_positions: AxesPositions | None = None[source]
axes_wxyzs: AxesWXYZs | None = None[source]
axes_length: float = 0.1[source]
axes_radius: float = 0.005[source]
class fastdev.sim_webui.webui.ViserAssetState[source]
asset_id: str[source]
viser_asset_id: str[source]
position: jaxtyping.Float[numpy.ndarray, 3][source]
wxyz: jaxtyping.Float[numpy.ndarray, 4][source]
class fastdev.sim_webui.webui.Asset[source]

Bases: abc.ABC

Base asset class.

asset_id: str[source]
class fastdev.sim_webui.webui.MeshAsset[source]

Bases: Asset

Base asset class.

trimesh_mesh: trimesh.Trimesh[source]
get_viser_asset(viser_asset_id: str) ViserAsset[source]
Parameters:

viser_asset_id (str)

Return type:

ViserAsset

get_or_create_asset_id(color: Color | None, scale: float, postfix: int = 0) str[source]
Parameters:
  • color (Optional[Color])

  • scale (float)

  • postfix (int)

Return type:

str

class fastdev.sim_webui.webui.PointCloudAsset[source]

Bases: Asset

Base asset class.

points: Vertices[source]
get_viser_asset(viser_asset_id: str) ViserAsset[source]
Parameters:

viser_asset_id (str)

Return type:

ViserAsset

get_or_create_asset_id(color: Color | None, point_size: float) str[source]
Parameters:
  • color (Optional[Color])

  • point_size (float)

Return type:

str

class fastdev.sim_webui.webui.AxesAsset[source]

Bases: Asset

Base asset class.

positions: AxesPositions[source]
wxyzs: AxesWXYZs[source]
get_viser_asset(viser_asset_id: str) ViserAsset[source]
Parameters:

viser_asset_id (str)

Return type:

ViserAsset

get_or_create_asset_id(axes_length: float, axes_radius: float) str[source]
Parameters:
  • axes_length (float)

  • axes_radius (float)

Return type:

str

class fastdev.sim_webui.webui.RobotAsset[source]

Bases: Asset

Base asset class.

robot_model: fastdev.robo.articulation.Articulation[source]
get_viser_asset(viser_asset_id: str) ViserAsset[source]
Parameters:

viser_asset_id (str)

Return type:

ViserAsset

get_or_create_asset_id(link_name: str, color: Color) str[source]
Parameters:
  • link_name (str)

  • color (Color)

Return type:

str

class fastdev.sim_webui.webui.AssetLibrary[source]

Asset library for multiple assets.

add_robot_asset(urdf_or_mjcf_path: str | None = None, mesh_dir: str | None = None, articulation: fastdev.robo.articulation.Articulation | None = None) str[source]
Parameters:
Return type:

str

add_mesh_asset(trimesh_mesh: trimesh.Trimesh, disable_cache: bool = False) str[source]
Parameters:
  • trimesh_mesh (trimesh.Trimesh)

  • disable_cache (bool)

Return type:

str

add_point_cloud_asset(points: Vertices) str[source]
Parameters:

points (Vertices)

Return type:

str

add_axes_asset(positions: AxesPositions, wxyzs: AxesWXYZs) str[source]
Parameters:
  • positions (AxesPositions)

  • wxyzs (AxesWXYZs)

Return type:

str

asset_exists(asset_id: str) bool[source]
Parameters:

asset_id (str)

Return type:

bool

get_asset(asset_id: str) Asset[source]
Parameters:

asset_id (str)

Return type:

Asset

get_viser_asset(asset_id: str, viser_asset_id: str) ViserAsset[source]
Parameters:
  • asset_id (str)

  • viser_asset_id (str)

Return type:

ViserAsset

static get_random_asset_id() str[source]
Return type:

str

fastdev.sim_webui.webui.ASSET_LIBRARY[source]
fastdev.sim_webui.webui.to_wxyz(rot: AxesWXYZsLike | None) jaxtyping.Float[numpy.ndarray, ... 4][source]
Parameters:

rot (Optional[AxesWXYZsLike])

Return type:

jaxtyping.Float[numpy.ndarray, … 4]

fastdev.sim_webui.webui.to_position_wxyz(pose: PosesLike | None) Tuple[jaxtyping.Float[numpy.ndarray, ... 3], jaxtyping.Float[numpy.ndarray, ... 4]][source]
Parameters:

pose (Optional[PosesLike])

Return type:

Tuple[jaxtyping.Float[numpy.ndarray, … 3], jaxtyping.Float[numpy.ndarray, … 4]]

fastdev.sim_webui.webui.get_random_color(r: Tuple[int, int] = (51, 180), g: Tuple[int, int] = (102, 204), b: Tuple[int, int] = (0, 102)) Color[source]
Parameters:
  • r (Tuple[int, int])

  • g (Tuple[int, int])

  • b (Tuple[int, int])

Return type:

Color

fastdev.sim_webui.webui.to_color_array(color: None) None[source]
fastdev.sim_webui.webui.to_color_array(color: ColorLike) Color
class fastdev.sim_webui.webui.AssetState[source]

Bases: abc.ABC

Asset state for multiple frames.

asset_id: str[source]
property num_frames: int[source]
Abstractmethod:

Return type:

int

abstractmethod get_frame_viser_asset_states(frame_index: int) List[ViserAssetState][source]
Parameters:

frame_index (int)

Return type:

List[ViserAssetState]

class fastdev.sim_webui.webui.MeshState[source]

Bases: AssetState

Asset state for multiple frames.

poses: Poses | None = None[source]
color: Color | None = None[source]
scale: float = 1.0[source]
property frame_range: Tuple[int, int][source]
Return type:

Tuple[int, int]

property num_frames: int[source]
Return type:

int

get_frame_viser_asset_states(frame_index: int) List[ViserAssetState][source]
Parameters:

frame_index (int)

Return type:

List[ViserAssetState]

class fastdev.sim_webui.webui.PointCloudState[source]

Bases: AssetState

Asset state for multiple frames.

poses: Poses | None = None[source]
color: Color | None = None[source]
point_size: float = 0.02[source]
property frame_range: Tuple[int, int][source]
Return type:

Tuple[int, int]

property num_frames: int[source]
Return type:

int

get_frame_viser_asset_states(frame_index: int) List[ViserAssetState][source]
Parameters:

frame_index (int)

Return type:

List[ViserAssetState]

class fastdev.sim_webui.webui.AxesState[source]

Bases: AssetState

Asset state for multiple frames.

poses: Poses | None = None[source]
axes_length: float = 0.1[source]
axes_radius: float = 0.005[source]
property num_frames: int[source]
Return type:

int

get_frame_viser_asset_states(frame_index: int) List[ViserAssetState][source]
Parameters:

frame_index (int)

Return type:

List[ViserAssetState]

class fastdev.sim_webui.webui.RobotState[source]

Bases: AssetState

Asset state for multiple frames.

joint_values: JointValues | None = None[source]
root_poses: Poses | None = None[source]
color: Color[source]
property num_frames: int[source]
Return type:

int

get_frame_viser_asset_states(frame_index: int) List[ViserAssetState][source]
Parameters:

frame_index (int)

Return type:

List[ViserAssetState]

class fastdev.sim_webui.webui.SceneState[source]

Scene state for multiple assets and frames.

set_robot_state(asset_id: str, joint_values: JointValues | None = None, root_poses: Poses | None = None, color: Color = _DEFAULT_ROBOT_COLOR)[source]
Parameters:
  • asset_id (str)

  • joint_values (Optional[JointValues])

  • root_poses (Optional[Poses])

  • color (Color)

set_mesh_state(asset_id: str, poses: Poses | None = None, scale: float = 1.0, color: Color | None = None, frame_range: Tuple[int, int] | None = None)[source]
Parameters:
  • asset_id (str)

  • poses (Optional[Poses])

  • scale (float)

  • color (Optional[Color])

  • frame_range (Optional[Tuple[int, int]])

set_point_cloud_state(asset_id: str, poses: Poses | None = None, point_size: float = 0.02, color: Color | None = None, frame_range: Tuple[int, int] | None = None)[source]
Parameters:
  • asset_id (str)

  • poses (Optional[Poses])

  • point_size (float)

  • color (Optional[Color])

  • frame_range (Optional[Tuple[int, int]])

set_axes_state(asset_id: str, poses: Poses | None = None, axes_length: float = 0.1, axes_radius: float = 0.005)[source]
Parameters:
  • asset_id (str)

  • poses (Optional[Poses])

  • axes_length (float)

  • axes_radius (float)

property num_frames: int[source]
Return type:

int

property last_updated: float[source]
Return type:

float

get_frame_viser_asset_states(frame_index: int) List[ViserAssetState][source]
Parameters:

frame_index (int)

Return type:

List[ViserAssetState]

__repr__() str[source]
Return type:

str

__str__() str[source]
Return type:

str

class fastdev.sim_webui.webui.StateManager[source]

State manager for multiple scenes.

set_robot_state(asset_id: str, scene_index: int, joint_values: JointValues | None = None, root_poses: Poses | None = None, color: Color = _DEFAULT_ROBOT_COLOR)[source]
Parameters:
  • asset_id (str)

  • scene_index (int)

  • joint_values (Optional[JointValues])

  • root_poses (Optional[Poses])

  • color (Color)

set_mesh_state(asset_id: str, scene_index: int, poses: Poses | None = None, scale: float = 1.0, color: Color | None = None, frame_range: Tuple[int, int] | None = None)[source]
Parameters:
  • asset_id (str)

  • scene_index (int)

  • poses (Optional[Poses])

  • scale (float)

  • color (Optional[Color])

  • frame_range (Optional[Tuple[int, int]])

set_point_cloud_state(asset_id: str, scene_index: int, poses: Poses | None = None, point_size: float = 1.0, color: Color | None = None, frame_range: Tuple[int, int] | None = None)[source]
Parameters:
  • asset_id (str)

  • scene_index (int)

  • poses (Optional[Poses])

  • point_size (float)

  • color (Optional[Color])

  • frame_range (Optional[Tuple[int, int]])

set_axes_state(asset_id: str, scene_index: int, poses: Poses | None = None, axes_length: float = 0.1, axes_radius: float = 0.005)[source]
Parameters:
  • asset_id (str)

  • scene_index (int)

  • poses (Optional[Poses])

  • axes_length (float)

  • axes_radius (float)

get_scene_num_frames(scene_index: int) int[source]
Parameters:

scene_index (int)

Return type:

int

get_scene_last_updated(scene_index: int) float[source]
Parameters:

scene_index (int)

Return type:

float

get_frame_viser_asset_states(scene_index: int, frame_index: int) List[ViserAssetState][source]
Parameters:
  • scene_index (int)

  • frame_index (int)

Return type:

List[ViserAssetState]

property num_scenes: int[source]
Return type:

int

validate_scene_index(scene_index: int) bool[source]

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.

Parameters:

scene_index (int) – Scene index.

Return type:

bool

reset()[source]
__getitem__(scene_index: int) SceneState[source]
Parameters:

scene_index (int)

Return type:

SceneState

__repr__() str[source]
Return type:

str

__str__() str[source]
Return type:

str

fastdev.sim_webui.webui.IS_PLAYING_EVENT[source]
class fastdev.sim_webui.webui.ViserHelper(state_manager: StateManager, host: str = 'localhost', port: int = 8080, enable_geometry_option: bool = False)[source]

Helper class for Viser server.

Parameters:
  • state_manager (StateManager)

  • host (str)

  • port (int)

  • enable_geometry_option (bool)

update_server(*args, **kwargs)[source]

Update the Viser server.

reset()[source]
class fastdev.sim_webui.webui.SimWebUI(host: str = 'localhost', port: int = 8080, enable_geometry_option: bool = False)[source]

WebUI for simulator and 3D scene visualization.

Parameters:
  • host (str)

  • port (int)

  • enable_geometry_option (bool)

__repr__() str[source]
Return type:

str

__str__() str[source]
Return type:

str

property scene_index: int[source]
Return type:

int

set_scene_index(value: int)[source]
Parameters:

value (int)

add_robot_asset(urdf_or_mjcf_path: str | pathlib.Path | None = None, mesh_dir: str | pathlib.Path | None = None, articulation: fastdev.robo.articulation.Articulation | None = None) str[source]

Add a robot asset to the asset library.

Parameters:
  • urdf_or_mjcf_path (Union[str, Path]) – Path to the URDF or MJCF file of the robot.

  • mesh_dir (Optional[Union[str, Path]], optional) – Directory path of the robot meshes. Will use the directory of the URDF/MJCF file if not provided. Defaults to None.

  • articulation (Optional[fastdev.robo.articulation.Articulation])

Returns:

Asset ID of the robot asset.

Return type:

str

add_mesh_asset(vertices: VerticesLike | None = None, faces: FacesLike | None = None, trimesh_mesh: trimesh.Trimesh | None = None, mesh_path: str | pathlib.Path | None = None, disable_cache: bool = False) str[source]

Add a mesh asset to the asset library.

Parameters:
  • vertices (Optional[VerticesLike], optional) – Vertices of the mesh. Defaults to None.

  • faces (Optional[FacesLike], optional) – Faces of the mesh. Defaults to None.

  • trimesh_mesh (Optional[trimesh.Trimesh], optional) – Trimesh mesh object. Defaults to None.

  • mesh_path (Optional[Union[str, Path]], optional) – Path to the mesh file. Defaults to None.

  • disable_cache (bool)

Returns:

Asset ID of the mesh asset.

Return type:

str

Note

Either trimesh_mesh or vertices and faces or mesh_path must be provided, but not both.

add_sphere_asset(radius: ScaleLike, subdivisions: int = 3, disable_cache: bool = False) str[source]

Add a single sphere asset to the asset library.

Parameters:
  • radius (float) – Radius of the sphere.

  • subdivisions (int, optional) – Number of subdivisions. Defaults to 3.

  • disable_cache (bool)

Returns:

Asset ID of the sphere asset.

Return type:

str

add_point_cloud_asset(points: VerticesLike) str[source]

Add a point cloud asset to the asset library.

Parameters:

points (VerticesLike) – Points of the point cloud.

Returns:

Asset ID of the point cloud asset.

Return type:

str

add_axes_asset(positions: AxesPositionsLike, rotations: AxesWXYZsLike) str[source]

Add an axes asset to the asset library.

Parameters:
  • positions (AxesPositionLike) – Positions of the axes.

  • rotations (AxesWXYZsLike) – Rotations of the axes, could be in rotation matrices or wxyz quaternions.

Returns:

Asset ID of the axes asset.

Return type:

str

set_robot_state(asset_id: str, scene_index: int | None = None, joint_values: JointValuesLike | None = None, root_poses: PosesLike | None = None, color: ColorLike = 'silver')[source]

Set the state of a robot asset.

Parameters:
  • asset_id (str) – Asset ID of the robot asset.

  • joint_values (Optional[JointValuesT], optional) – Multi-frame (or single-frame) joint values. Defaults to None.

  • root_poses (Optional[PosesT], optional) – Multi-frame (or single-frame) root poses. Defaults to None.

  • scene_index (Optional[int], optional) – Scene index. Defaults to None.

  • color (ColorLike)

Note

The number of frames of the asset state is determined by the number of joint values provided.

set_mesh_state(asset_id: str, scene_index: int | None = None, poses: PosesLike | None = None, scale: ScaleLike = 1.0, color: ColorLike | None = None, frame_range: int | Tuple[int, int] | None = None)[source]

Set the state of a mesh asset.

Parameters:
  • asset_id (str) – Asset ID of the mesh asset.

  • scene_index (Optional[int], optional) – Scene index. Defaults to None.

  • poses (Optional[PosesLike], optional) – Multi-frame (or single-frame) poses. Defaults to None.

  • scale (ScaleLike, optional) – Scale factor. Defaults to 1.0.

  • color (ColorLike, optional) – Color of the mesh, use random color if not provided. Defaults to None.

  • frame_range (Optional[Union[int, Tuple[int, int]]])

Note

The number of frames of the asset state is determined by the number of poses provided.

set_sphere_state(asset_id: str, scene_index: int | None = None, poses: PosesLike | None = None, scale: ScaleLike = 1.0, color: ColorLike | None = None, frame_range: int | Tuple[int, int] | None = None)[source]

Set the state of a sphere asset.

Parameters:
  • asset_id (str) – Asset ID of the sphere asset.

  • scene_index (Optional[int], optional) – Scene index. Defaults to None.

  • poses (Optional[PosesLike], optional) – Multi-frame (or single-frame) poses. Defaults to None.

  • scale (ScaleLike, optional) – Scale factor. Defaults to 1.0.

  • color (Optional[ColorLike], optional) – Color of the sphere. Defaults to None.

  • frame_range (Optional[Union[int, Tuple[int, int]]])

Note

The number of frames of the asset state is determined by the number of poses provided.

set_point_cloud_state(asset_id: str, scene_index: int | None = None, poses: PosesLike | None = None, point_size: ScaleLike = 0.02, color: ColorLike | None = None, frame_range: int | Tuple[int, int] | None = None)[source]

Set the state of a point cloud asset.

Parameters:
  • asset_id (str) – Asset ID of the point cloud asset.

  • scene_index (Optional[int], optional) – Scene index. Defaults to None.

  • poses (Optional[PosesLike], optional) – Multi-frame (or single-frame) poses. Defaults to None.

  • scale (ScaleLike, optional) – Scale factor. Defaults to 1.0.

  • color (Optional[ColorLike], optional) – Color of the point cloud. Defaults to None.

  • point_size (ScaleLike)

  • frame_range (Optional[Union[int, Tuple[int, int]]])

Note

The number of frames of the asset state is determined by the number of poses provided.

set_axes_state(asset_id: str, scene_index: int | None = None, axes_length: ScaleLike = 0.1, axes_radius: ScaleLike = 0.005, poses: PosesLike | None = None)[source]

Set the state of a point cloud asset.

Parameters:
  • asset_id (str) – Asset ID of the point cloud asset.

  • scene_index (Optional[int], optional) – Scene index. Defaults to None.

  • axes_length (ScaleLike, optional) – Length of the axes. Defaults to 0.1.

  • axes_radius (ScaleLike, optional) – Radius of the axes. Defaults to 0.005.

  • poses (Optional[PosesLike], optional) – Multi-frame (or single-frame) poses. Defaults to None.

Note

The number of frames of the asset state is determined by the number of poses provided.

reset()[source]

Reset the state manager and Viser server.