grutopia.core.task¶
task¶
- class grutopia.core.task.task.BaseTask(runtime: TaskRuntime, scene: Scene)[source]¶
wrap of omniverse isaac sim’s base task
enable register for auto register task
contains scene/robots/objects.
- calculate_metrics() dict [source]¶
Calculates and aggregates the results of all metrics registered within the instance.
This method iterates over the stored metrics, calling their respective calc methods to compute the metric values. The computed values are then compiled into a dictionary, where each key corresponds to the metrics’ name and each value is the result of the metric calculation.
- Returns:
A dictionary containing the calculated results of all metrics, with metric names as keys.
- Return type:
dict
Note
Ensure that all metrics added to the instance have a calc method implemented.
Example Usage:
`python # Assuming `self.metrics` is populated with metric instances. results = calculate_metrics() print(results) # Output: {'metric1': 0.85, 'metric2': 0.92, 'metric3': 0.78} `
- cleanup() None [source]¶
Called before calling a reset() on the world to removed temporary objects that were added during simulation for instance.
- get_observations() Dict[str, Any] [source]¶
Returns current observations from the objects needed for the behavioral layer.
- Returns:
observation of robots in this task
- Return type:
Dict[str, Any]
- is_done() bool [source]¶
Returns True of the task is done. The result should be decided by the state of the task.
- load()[source]¶
Loads the environment scene and initializes robots and objects.
This method first checks if a scene asset path is defined in the runtime configuration. If so, it creates a scene using the provided path and specified parameters such as scaling and positioning. The scene is then populated with robots and objects based on the configurations stored within self.runtime.
Raises: - Exceptions may be raised during file operations or USD scene creation, but specific exceptions are not documented here.
Attributes Modified: - self.robots: A collection of initialized robots set up within the scene. - self.objects: A dictionary mapping object names to their respective initialized instances within the scene. - self.loaded: A boolean flag indicating whether the environment has been successfully loaded, set to True upon successful completion of this method.
Logs: - Information about the initialized robots and objects is logged using the log.info method after successful setup.
- pre_step(time_step_index: int, simulation_time: float) None [source]¶
called before stepping the physics simulation.
- Parameters:
time_step_index (int) – [description]
simulation_time (float) – [description]
- classmethod register(name: str)[source]¶
Register a task with its name(decorator). :param name: name of the task :type name: str
- set_up_scene(scene: Scene) None [source]¶
Adding assets to the stage as well as adding the encapsulated objects such as XFormPrim..etc to the task_objects happens here.
- Parameters:
scene (Scene) – [description]
- update_metrics()[source]¶
Updates all metrics stored within the instance.
Scans through the dictionary of metrics kept by the current instance, invoking the ‘update’ method on each one. This facilitates the aggregation or recalculation of metric values as needed.
Note: This method does not return any value; its purpose is to modify the state of the metric objects internally.
metric¶
- class grutopia.core.task.metric.BaseMetric(config: MetricCfg, task_runtime: TaskRuntime)[source]¶
- abstract calc()[source]¶
This function is called to calculate the metrics when the episode is terminated.