-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[Newton] Adding visualizer support for Newton #4099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev/newton
Are you sure you want to change the base?
Conversation
Signed-off-by: matthewtrepte <mtrepte@nvidia.com>
Signed-off-by: matthewtrepte <mtrepte@nvidia.com>
…s default cfgs if no visualizers are specified
Greptile OverviewGreptile SummaryThis PR introduces a comprehensive visualizer system for Isaac Lab 3.0, replacing the single Important Files Changed
Confidence score: 3/5
Sequence DiagramsequenceDiagram
participant User
participant AppLauncher
participant SimulationContext
participant SceneDataProvider
participant NewtonManager
participant NewtonVisualizer
participant NewtonViewerGL
participant TrainingLoop
User->>AppLauncher: "python train.py --visualizer newton"
AppLauncher->>AppLauncher: "parse --visualizer flag"
AppLauncher->>AppLauncher: "store visualizer type in carb settings"
AppLauncher->>SimulationContext: "create simulation context"
SimulationContext->>SimulationContext: "read visualizer setting from carb"
alt visualizer requested
SimulationContext->>SimulationContext: "_create_default_visualizer_configs()"
SimulationContext->>SceneDataProvider: "create provider with visualizer configs"
SceneDataProvider->>SceneDataProvider: "determine active backends"
end
SimulationContext->>NewtonManager: "start_simulation()"
NewtonManager->>NewtonManager: "initialize physics model and state"
SimulationContext->>SimulationContext: "reset()"
SimulationContext->>SimulationContext: "initialize_visualizers()"
alt newton visualizer enabled
SimulationContext->>NewtonVisualizer: "create_visualizer() from config"
SimulationContext->>NewtonVisualizer: "initialize(scene_data)"
NewtonVisualizer->>SceneDataProvider: "get_model() and get_state()"
SceneDataProvider->>NewtonManager: "access physics data"
NewtonManager-->>SceneDataProvider: "return model and state"
SceneDataProvider-->>NewtonVisualizer: "return physics data"
NewtonVisualizer->>NewtonViewerGL: "create viewer with metadata"
NewtonViewerGL->>NewtonViewerGL: "set_model() and configure camera"
NewtonViewerGL-->>NewtonVisualizer: "viewer initialized"
NewtonVisualizer-->>SimulationContext: "visualizer ready"
end
loop training/simulation
TrainingLoop->>SimulationContext: "step(render=True)"
SimulationContext->>NewtonManager: "step()"
NewtonManager->>NewtonManager: "simulate physics"
SimulationContext->>SceneDataProvider: "update()"
SceneDataProvider->>NewtonManager: "sync fabric transforms for OV"
SimulationContext->>SimulationContext: "step_visualizers(dt)"
SimulationContext->>NewtonVisualizer: "step(dt, state=None)"
NewtonVisualizer->>SceneDataProvider: "get updated state"
SceneDataProvider->>NewtonManager: "access latest physics state"
NewtonManager-->>SceneDataProvider: "return current state"
SceneDataProvider-->>NewtonVisualizer: "return updated state"
alt not paused and update frequency met
NewtonVisualizer->>NewtonViewerGL: "begin_frame(sim_time)"
NewtonVisualizer->>NewtonViewerGL: "log_state(state)"
NewtonVisualizer->>NewtonViewerGL: "end_frame()"
NewtonViewerGL->>NewtonViewerGL: "render 3D scene"
end
end
User->>TrainingLoop: "stop training"
TrainingLoop->>SimulationContext: "close_visualizers()"
SimulationContext->>NewtonVisualizer: "close()"
NewtonVisualizer->>NewtonViewerGL: "cleanup resources"
SimulationContext->>SimulationContext: "clear_instance()"
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
31 files reviewed, 11 comments
| visualizer_train_mode: bool = True | ||
| """Whether the visualizer is in training mode (True) or play mode (False).""" | ||
|
|
||
| solver_cfg: NewtonSolverCfg = MJWarpSolverCfg() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Missing docstring for the solver_cfg attribute
| solver_cfg: NewtonSolverCfg = MJWarpSolverCfg() | |
| solver_cfg: NewtonSolverCfg = MJWarpSolverCfg() | |
| """Configuration for the Newton solver.""" |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| This module uses a registry pattern to decouple visualizer instantiation from specific types. | ||
| Visualizer implementations can register themselves using the `register_visualizer` decorator, | ||
| and configs can create visualizers via the `create_visualizer()` factory method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Documentation mentions register_visualizer decorator and create_visualizer() factory method that don't exist in the implementation
| This module uses a registry pattern to decouple visualizer instantiation from specific types. | |
| Visualizer implementations can register themselves using the `register_visualizer` decorator, | |
| and configs can create visualizers via the `create_visualizer()` factory method. | |
| This module uses a registry pattern to decouple visualizer instantiation from specific types. | |
| Visualizer implementations are lazy-loaded through the `get_visualizer_class()` factory function. |
| # Calculate camera direction vector (from position to target) | ||
| cam_pos = self.cfg.camera_position | ||
| cam_target = self.cfg.camera_target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: camera position and target are retrieved but not used in the blueprint configuration. Should these camera parameters be applied to the blueprint's Spatial3DView configuration?
| for visualizer in self.env.sim._visualizers: | ||
| # Check if visualizer supports live plots and has it enabled | ||
| if hasattr(visualizer, "cfg") and hasattr(visualizer.cfg, "enable_live_plots"): | ||
| if visualizer.supports_live_plots() and visualizer.cfg.enable_live_plots: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: This method call could raise an AttributeError if the visualizer object doesn't implement supports_live_plots(). Consider adding a hasattr check.
| # Handle training pause - block until resumed | ||
| while visualizer.is_training_paused() and visualizer.is_running(): | ||
| # Visualizers fetch backend-specific state themselves | ||
| visualizer.step(0.0, state=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: This blocking while loop could cause the main thread to hang if a visualizer never resumes from pause. Consider adding a timeout or making this non-blocking with a sleep.
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Kelly Guo <kellyg@nvidia.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Kelly Guo <kellyg@nvidia.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Kelly Guo <kellyg@nvidia.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Kelly Guo <kellyg@nvidia.com>
Description
Building on top of #3979 from @matthewtrepte
Adds additional
--visualizerflag for specifying which visualizer(s) to enable.Updates numpy to >=2 to support new rerun package that resolves a flashing screen issue.
Introduces default visualizer configs in the simulation config so that users can launch any visualizer without explicitly adding new configs into the environments.
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there