log

class jiminy_py.log.TrajectoryDataType(**kwargs)[source]

Bases: dict

evolution_robot: Sequence[jiminy_py.state.State]
robot: Optional[jiminy_py.core.Robot]
use_theoretical_model: bool
jiminy_py.log.read_log(fullpath, file_format=None)[source]

Read a logfile from jiminy.

This function supports both text (csv) and binary log.

Parameters
  • fullpath (str) – Name of the file to load.

  • file_format (Optional[str]) – Name of the file to load.

Returns

Pair of dictionaries containing respectively the logged values, and the constants.

Return type

Tuple[Dict[str, numpy.ndarray], Dict[str, str]]

jiminy_py.log.extract_trajectory_data_from_log(log_data, robot)[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, numpy.ndarray]) – Data from the log file, in a dictionnary.

  • robot (jiminy_py.core.Model) – Jiminy robot.

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

jiminy_py.log.TrajectoryDataType

jiminy_py.log.build_robot_from_log_constants(log_constants, mesh_package_dirs=())[source]

Build robot from log constants.

Note

model options and robot.pinocchio_model are guarentee to be the same as during the simulation until the next call to reset method.

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_file – Path of the simulation log file, in any format.

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

  • log_constants (Dict[str, str]) –

Returns

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

Return type

jiminy_py.core.Robot

jiminy_py.log.emulate_sensors_data_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, numpy.ndarray]) – Data from the log file, in a dictionnary.

  • robot (jiminy_py.core.Model) – Jiminy robot.

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, None]