TODO: Write documentation.

gym_jiminy.common.utils.helpers.is_breakpoint(t, dt, eps)[source]

Check if ‘t’ is multiple of ‘dt’ at a given precision ‘eps’.

  • t (float) – Current time.

  • dt (float) – Timestep.

  • eps (float) – Precision.

Return type


gym_jiminy.common.utils.helpers.get_fieldnames(structure, namespace='')[source]

Generate generic fieldnames from gym..Space, so that it can be used in conjunction with register_variables, to register any value from gym Space to the telemetry conveniently.

  • space – Gym.Space on which to operate.

  • namespace (str) – Namespace used to prepend fields, using ‘.’ delimiter. Empty string to disable. Optional: Disabled by default.

  • structure (Union[Union[Dict[str, StructNested], Sequence[StructNested], ValueType], Union[Dict[str, StructNested], Sequence[StructNested], ValueType]]) –

Return type

Union[Dict[str, StructNested], Sequence[StructNested], ValueType]

gym_jiminy.common.utils.helpers.register_variables(controller, fieldnames, data)[source]

Register data from Gym.Space to the telemetry of a controller.


Variables are registered by reference. Consequently, the user is responsible to manage the lifetime of the data to avoid it being garbage collected, and to make sure the variables are updated when necessary, and only when it is.

  • controller (jiminy_py.core.AbstractController) – Robot’s controller of the simulator used to register variables to the telemetry.

  • fieldnames (Union[ValuesView[Union[Dict[str, StructNested], Sequence[StructNested], ValueType]], Union[Dict[str, StructNested], Sequence[StructNested], ValueType]]) – Nested variable names, as returned by get_fieldnames method. It can be a nested list or/and dict. The leaves are str corresponding to the name of each scalar data.

  • data (Union[Dict[str, StructNested], Sequence[StructNested], ValueType]) – Data from gym.spaces.Space to register. Note that the telemetry stores pointers to the underlying memory, so it only supports np.float64, and make sure to reassign data using np.copyto or [:] operator (faster).


Whether or not the registration has been successful.

Return type