log

Utilities for extracting structured information from log data, from reconstructing the robot to reading telemetry variables.

jiminy_py.log.extract_variables_from_log(log_vars: Dict[str, ndarray], fieldnames: Dict[str, FieldNested] | Sequence[FieldNested] | str, namespace: str | None = ENGINE_NAMESPACE, *, as_dict: Literal[False] = False) List[ndarray][source]
jiminy_py.log.extract_variables_from_log(log_vars: Dict[str, ndarray], fieldnames: Dict[str, FieldNested] | Sequence[FieldNested] | str, namespace: str | None = ENGINE_NAMESPACE, *, as_dict: Literal[True]) Dict[str, ndarray]

Extract values associated with a set of variables in a specific namespace.

Parameters:
  • log_vars – Logged variables as a dictionary.

  • fieldnames – Structured fieldnames.

  • namespace – Namespace of the fieldnames. None to disable. Optional: ENGINE_TELEMETRY_NAMESPACE by default.

  • keep_structure – Whether to return a dictionary mapping flattened fieldnames to values. Optional: True by default.

Returns:

np.ndarray or None for each fieldname individually depending if it is found or not.

jiminy_py.log.build_robot_from_log(log_data, mesh_path_dir=None, mesh_package_dirs=())[source]

Build robot from log.

Note

model options and robot.pinocchio_model will be the same as during the simulation until the next call to reset method unless the options of the robot that has been restored are overwritten manually.

Note

It returns a valid and fully initialized robot, that can be used to perform new simulation if added to a Jiminy Engine, but the original controller is lost.

Warning

It does ot require the original URDF file to exist, but the original mesh paths (if any) must be valid since they are not bundle in the log archive for now.

Parameters:
  • log_data (Dict[str, Any]) – Logged data (constants and variables) as a dictionary.

  • mesh_path_dir (str | None) – Overwrite the common root of all absolute mesh paths. It which may be necessary to read log generated on a different environment.

  • mesh_package_dirs (Sequence[str]) – Prepend custom mesh package search path directories to the ones provided by log file. It may be necessary to specify it to read log generated on a different environment.

Returns:

Reconstructed robot, and parsed log data as returned by jiminy_py.log.read_log method.

Return type:

Robot

jiminy_py.log.extract_trajectory_from_log(log_data, robot=None)[source]

Extract the minimal required information from raw log data in order to replay the simulation in a viewer.

Note

It extracts the required data for replay, namely temporal evolution of:
  • robot configuration: to display of the robot on the scene,

  • robot velocity: to update velocity-dependent markers such as DCM,

  • external forces: to update force-dependent markers.

Parameters:
  • log_data (Dict[str, Any]) – Logged data (constants and variables) as a dictionary.

  • robot (Model | None) – Jiminy robot associated with the logged trajectory. Optional: None by default. If None, then it will be reconstructed from ‘log_data’ using build_robot_from_log.

Returns:

Trajectory dictionary. The actual trajectory corresponds to the field “evolution_robot” and it is a list of State object. The other fields are additional information.

Return type:

TrajectoryDataType

jiminy_py.log.update_sensor_measurements_from_log(log_data, robot)[source]

Helper to make it easy to emulate sensor data update based on log data.

Note

It returns an update_hook that can forwarding the Viewer.replay to display sensor information such as contact forces for instance.

Parameters:
  • log_data (Dict[str, Any]) – Logged data (constants and variables) as a dictionary.

  • robot (Model) – Jiminy robot associated with the logged trajectory.

Returns:

Callable taking update time in argument and returning nothing. Note that it does not through an exception if out-of-range, but rather clip to desired time to the available data range.

Return type:

Callable[[float, ndarray, ndarray], None]