wa_simulator.chrono.visualization
¶
Classes
Chrono irrlicht visualization wrapper. Sets default values for a Vehicle irr app |
|
Chrono sensor visualization wrapper. Sets default values for a camera sensor |
-
class
WAChronoIrrlicht
(system: WAChronoSystem, vehicle: WAChronoVehicle, vehicle_inputs: WAVehicleInputs, environment: WAEnvironment = None, opponents: list = [], record: bool = False, record_folder: str = 'OUTPUT/', should_bind: bool = True)[source]¶ Bases:
wa_simulator.visualization.WAVisualization
Chrono irrlicht visualization wrapper. Sets default values for a Vehicle irr app
- Parameters
system (WAChronoSystem) – holds information regarding the simulation and performs dynamic updates
vehicle (WAChronoVehicle) – vehicle that holds the Chrono vehicle
vehicle_inputs (WAVehicleInputs) – the vehicle inputs
environment (WAEnvironment, optional) – An environment with various world assets to visualize. Defaults to None (doesn’t visualize anything).
opponents (list, optional) – Opponents present in the simulation. The camera will track
vehicle
not any opponent.record (bool, optional) – If set to true, images will be saved under record_filename. Defaults to False (doesn’t save images).
record_folder (str, optional) – The folder to save images to. Defaults to “OUTPUT/”.
should_bind (bool, optional) – After all assets have been added to the environment, irrlicht needs to “bind” and add the assets to the 3D rendered world. This can be done either on instantiation (True) or on the first update (False). Defaults to True.
-
synchronize
(self, time: float)[source]¶ Synchronize the irrlicht app with the vehicle inputs at the passed time
- Parameters
time (double) – time to synchronize the simulation to
-
advance
(self, step: float)[source]¶ Advance the state of the visualization by the specified step
Will update the render only if the simulation step is a multiple of render steps
- Parameters
step (double) – step size to update the visualization by
-
is_ok
(self)[source]¶ Checks if the irrlicht rending window is still alive
- Returns
bool – whether the simulation is still alive
-
visualize
(self, assets, *args, **kwargs)[source]¶ Helper method that visualizes some object(s) in the chosen visualizer
Different visualizations will visualize the object(s) in different ways. This is an abstract method, so it must be implemented.
- Parameters
assets (list) – The object(s) to visualize
*args – Positional arguments that are specific to the underyling visualizer implementation
**kwargs – Keyworded arguments that are specific to the underlying visualizer implementation
-
class
WAChronoSensorVisualization
(system: WAChronoSystem, vehicle: WAChronoVehicle, vehicle_inputs: WAVehicleInputs, environment: WAEnvironment = None, opponents: list = [], record: bool = False, record_folder: str = 'OUTPUT/')[source]¶ Bases:
wa_simulator.visualization.WAVisualization
Chrono sensor visualization wrapper. Sets default values for a camera sensor
- Parameters
system (WAChronoSystem) – holds information regarding the simulation and performs dynamic updates
vehicle (WAChronoVehicle) – vehicle that holds the Chrono vehicle
vehicle_inputs (WAVehicleInputs) – the vehicle inputs
environment (WAEnvironment, optional) – An environment with various world assets to visualize. Defaults to None (doesn’t visualize anything).
opponents (list, optional) – Opponents present in the simulation. The camera will track
vehicle
not any opponent.record (bool, optional) – If set to true, images will be saved under record_filename. Defaults to False (doesn’t save images).
record_folder (str, optional) – The folder to save images to. Defaults to “OUTPUT/”.
-
synchronize
(self, time: float)[source]¶ Update the state of this component at the current time.
The primary reason to decouple the update method into two separate calls (i.e.
synchronize()
andadvance()
) is to provide flexibility to the user and is essentially semantic. In most simple cases, a user will only need one of the two. Furthermore, can only useadvance()
if they prefer and just update their owntime
variable. Given the unknown use cases for the simulator at the time of writing, it was chosen to provide two different methods with similar functionality as to allow the user to choose their desired implementation, rather than the writers of this package.As opposed to
advance()
, this method gets the current time of the simulation. As menthioned earlier,advance()
and a user defined time variable could be used to instead to hold the current state of the simulation. However, to aid in generality of the package, this method is provided to simply provide the current time of the simulation to the user in a decoupled manner from theadvance()
method.- Parameters
time (float) – The current time to synchronize to
-
advance
(self, step: float)[source]¶ Advance the state of this component by the specified time step.
The primary reason to decouple the update method into two separate calls (i.e.
synchronize()
andadvance()
) is to provide flexibility to the user and is essentially semantic. In most simple cases, a user will only need one of the two. Furthermore, can only useadvance()
if they prefer and just update their owntime
variable. Given the unknown use cases for the simulator at the time of writing, it was chosen to provide two different methods with similar functionality as to allow the user to choose their desired implementation, rather than the writers of this package.- Parameters
step (float) – The step size to advance this component by
-
is_ok
(self)[source]¶ Check whether this component is still alive.
Depending the type of component, a specific element may “fail”. For example, when a visualization is used that presents a GUI/window, if the user closes that display, this would be considered a component death. Therefore,
is_ok()
should then return False.- Returns
bool – True if still alive, false otherwise
-
visualize
(self, assets, *args, **kwargs)[source]¶ Helper method that visualizes some object(s) in the chosen visualizer
Different visualizations will visualize the object(s) in different ways. This is an abstract method, so it must be implemented.
- Parameters
assets (list) – The object(s) to visualize
*args – Positional arguments that are specific to the underyling visualizer implementation
**kwargs – Keyworded arguments that are specific to the underlying visualizer implementation
Methods
Draw a WAPath representation as a ChBezierCurve in irrlicht |
|
Create and add a sphere to the chrono world |
|
Update the position of a sphere being visualized in irrlicht |
-
draw_path_in_irrlicht
(system: WAChronoSystem, path: WAPath)[source]¶ Draw a WAPath representation as a ChBezierCurve in irrlicht
Basically just copies over the path’s points into something viewable for Chrono
- Parameters
system (WAChronoSystem) – system that manages the simulation
path (WAPath) – WA path object to visualize in irrlicht
-
create_sphere_in_chrono
(system: WAChronoSystem, rgb=(1, 0, 0)) → chrono.ChBodyEasySphere[source]¶ Create and add a sphere to the chrono world
- Parameters
system (WASystem) – the system that manages the simulation
rgb (tuple, optional) – (red, green, blue). Defaults to (1, 0, 0) or red.
- Returns
chrono.ChBodyEasySphere – the sphere that was created