internutopia.core.task#

task#

class internutopia.core.task.task.BaseTask(config: TaskCfg, scene: IScene)[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]#

Used to clean up the resources loaded in the task.

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 task config. 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.config.

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.

post_reset() None[source]#

Calls while doing a .reset() on the world.

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 an task class with the given name(decorator).

Parameters:

name (str) – name of the task

restore_info()[source]#

Restores the information and statuses of rigid bodies and robots.

save_info()[source]#

Saves the robot information and rigidbody statuses.

save_robot_info()[source]#

Saves information of all robots in the task instance.

set_up_runtime(task_name, env_id, env_offset)[source]#

Sets up info (task_name, env_id, env_offset) for this task.

TODO: refactor and rename

Parameters:
  • task_name (str) – The name of the task.

  • env_id (int) – The env ID of this task.

  • env_offset (List[float]) – The env offset for the task.

set_up_scene(scene: IScene) 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 internutopia.core.task.metric.BaseMetric(config: MetricCfg, task_config: TaskCfg)[source]#
abstract calc()[source]#

This function is called to calculate the metrics when the episode is terminated.

classmethod register(name: str)[source]#

Register a metric class with the given name(decorator).

Parameters:

name (str) – name of the metric

abstract update(*args)[source]#

This function is called at each world step.

reward#

class internutopia.core.task.reward.BaseReward(task: BaseTask, settings: Dict[str, Any])[source]#
classmethod register(name: str)[source]#

Register an reward class with the given name(decorator).

Parameters:

name (str) – name of the reward