| | |
| | |
| | |
| | |
| |
|
| | """This script demonstrates different types of markers. |
| | |
| | .. code-block:: bash |
| | |
| | # Usage |
| | ./isaaclab.sh -p scripts/demos/markers.py |
| | |
| | """ |
| |
|
| | """Launch Isaac Sim Simulator first.""" |
| |
|
| | import argparse |
| |
|
| | from isaaclab.app import AppLauncher |
| |
|
| | |
| | parser = argparse.ArgumentParser(description="This script demonstrates different types of markers.") |
| | |
| | AppLauncher.add_app_launcher_args(parser) |
| | |
| | args_cli = parser.parse_args() |
| |
|
| | |
| | app_launcher = AppLauncher(args_cli) |
| | simulation_app = app_launcher.app |
| |
|
| | """Rest everything follows.""" |
| |
|
| | import torch |
| |
|
| | import isaaclab.sim as sim_utils |
| | from isaaclab.markers import VisualizationMarkers, VisualizationMarkersCfg |
| | from isaaclab.sim import SimulationContext |
| | from isaaclab.utils.assets import ISAAC_NUCLEUS_DIR, ISAACLAB_NUCLEUS_DIR |
| | from isaaclab.utils.math import quat_from_angle_axis |
| |
|
| |
|
| | def define_markers() -> VisualizationMarkers: |
| | """Define markers with various different shapes.""" |
| | marker_cfg = VisualizationMarkersCfg( |
| | prim_path="/Visuals/myMarkers", |
| | markers={ |
| | "frame": sim_utils.UsdFileCfg( |
| | usd_path=f"{ISAAC_NUCLEUS_DIR}/Props/UIElements/frame_prim.usd", |
| | scale=(0.5, 0.5, 0.5), |
| | ), |
| | "arrow_x": sim_utils.UsdFileCfg( |
| | usd_path=f"{ISAAC_NUCLEUS_DIR}/Props/UIElements/arrow_x.usd", |
| | scale=(1.0, 0.5, 0.5), |
| | visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.0, 1.0, 1.0)), |
| | ), |
| | "cube": sim_utils.CuboidCfg( |
| | size=(1.0, 1.0, 1.0), |
| | visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(1.0, 0.0, 0.0)), |
| | ), |
| | "sphere": sim_utils.SphereCfg( |
| | radius=0.5, |
| | visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.0, 1.0, 0.0)), |
| | ), |
| | "cylinder": sim_utils.CylinderCfg( |
| | radius=0.5, |
| | height=1.0, |
| | visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.0, 0.0, 1.0)), |
| | ), |
| | "cone": sim_utils.ConeCfg( |
| | radius=0.5, |
| | height=1.0, |
| | visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(1.0, 1.0, 0.0)), |
| | ), |
| | "mesh": sim_utils.UsdFileCfg( |
| | usd_path=f"{ISAAC_NUCLEUS_DIR}/Props/Blocks/DexCube/dex_cube_instanceable.usd", |
| | scale=(10.0, 10.0, 10.0), |
| | ), |
| | "mesh_recolored": sim_utils.UsdFileCfg( |
| | usd_path=f"{ISAAC_NUCLEUS_DIR}/Props/Blocks/DexCube/dex_cube_instanceable.usd", |
| | scale=(10.0, 10.0, 10.0), |
| | visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(1.0, 0.25, 0.0)), |
| | ), |
| | "robot_mesh": sim_utils.UsdFileCfg( |
| | usd_path=f"{ISAACLAB_NUCLEUS_DIR}/Robots/ANYbotics/ANYmal-C/anymal_c.usd", |
| | scale=(2.0, 2.0, 2.0), |
| | visual_material=sim_utils.GlassMdlCfg(glass_color=(0.0, 0.1, 0.0)), |
| | ), |
| | }, |
| | ) |
| | return VisualizationMarkers(marker_cfg) |
| |
|
| |
|
| | def main(): |
| | """Main function.""" |
| | |
| | sim_cfg = sim_utils.SimulationCfg(dt=0.01, device=args_cli.device) |
| | sim = SimulationContext(sim_cfg) |
| | |
| | sim.set_camera_view([0.0, 18.0, 12.0], [0.0, 3.0, 0.0]) |
| |
|
| | |
| | |
| | cfg = sim_utils.DomeLightCfg(intensity=3000.0, color=(0.75, 0.75, 0.75)) |
| | cfg.func("/World/Light", cfg) |
| |
|
| | |
| | my_visualizer = define_markers() |
| |
|
| | |
| | num_markers_per_type = 5 |
| | grid_spacing = 2.0 |
| | |
| | half_width = (num_markers_per_type - 1) / 2.0 |
| | half_height = (my_visualizer.num_prototypes - 1) / 2.0 |
| | |
| | x_range = torch.arange(-half_width * grid_spacing, (half_width + 1) * grid_spacing, grid_spacing) |
| | y_range = torch.arange(-half_height * grid_spacing, (half_height + 1) * grid_spacing, grid_spacing) |
| | |
| | x_grid, y_grid = torch.meshgrid(x_range, y_range, indexing="ij") |
| | x_grid = x_grid.reshape(-1) |
| | y_grid = y_grid.reshape(-1) |
| | z_grid = torch.zeros_like(x_grid) |
| | |
| | marker_locations = torch.stack([x_grid, y_grid, z_grid], dim=1) |
| | marker_indices = torch.arange(my_visualizer.num_prototypes).repeat(num_markers_per_type) |
| |
|
| | |
| | sim.reset() |
| | |
| | print("[INFO]: Setup complete...") |
| |
|
| | |
| | yaw = torch.zeros_like(marker_locations[:, 0]) |
| | |
| | while simulation_app.is_running(): |
| | |
| | marker_orientations = quat_from_angle_axis(yaw, torch.tensor([0.0, 0.0, 1.0])) |
| | |
| | my_visualizer.visualize(marker_locations, marker_orientations, marker_indices=marker_indices) |
| | |
| | if yaw[0].item() % (0.5 * torch.pi) < 0.01: |
| | marker_indices = torch.roll(marker_indices, 1) |
| | |
| | sim.step() |
| | |
| | yaw += 0.01 |
| |
|
| |
|
| | if __name__ == "__main__": |
| | |
| | main() |
| | |
| | simulation_app.close() |
| |
|