dm_robotics.panda.utils module

Utility module for the Panda MoMa model.

class dm_robotics.panda.utils.ActionPlot(runtime: Runtime, maxlen: int = 500)[source]

Bases: Plot

A plotting component for dm_control.viewer.application.Application that plots the agent’s actions.

__init__(runtime: Runtime, maxlen: int = 500) None[source]
render(context, viewport)[source]

Renders the component.

Parameters:
  • context – MjrContext instance.

  • viewport – Viewport instance.

class dm_robotics.panda.utils.ApplicationWithPlot(title='Explorer', width=1024, height=768)[source]

Bases: Application

Extends the dm_control viewer to show live plots.

__init__(title='Explorer', width=1024, height=768)[source]

Instance initializer.

class dm_robotics.panda.utils.Formatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]

Bases: Formatter

Logging formatter for the Panda MoMa model.

format(record: LogRecord) str[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

class dm_robotics.panda.utils.ObservationPlot(runtime: Runtime, maxlen: int = 500)[source]

Bases: Plot

Plotting component for dm_control.viewer.application.Application that allows you to browse through the observations.

__init__(runtime: Runtime, maxlen: int = 500) None[source]
next_obs()[source]

Go to the next observation.

prev_obs()[source]

Go to the previous observation.

render(context, viewport)[source]

Renders the component.

Parameters:
  • context – MjrContext instance.

  • viewport – Viewport instance.

update_title()[source]

Update the title to the current observation.

class dm_robotics.panda.utils.Plot(runtime: Runtime, maxlen: int)[source]

Bases: Component, ABC

Abstract base class for plotting components.

__init__(runtime: Runtime, maxlen: int) None[source]
reset_data()[source]

Reset line data.

class dm_robotics.panda.utils.PlotHelp[source]

Bases: ColumnTextModel

Displays help for navigating observation plots.

__init__() None[source]
get_columns()[source]

Returns the text to display in two columns.

Returns:

Returns an iterable of tuples of 2 strings. Each tuple has format (left_column_label, right_column_label).

class dm_robotics.panda.utils.RewardPlot(runtime: Runtime, maxlen: int = 500)[source]

Bases: Plot

A plotting component for dm_control.viewer.application.Application that plots the environment’s reward.

__init__(runtime: Runtime, maxlen: int = 500) None[source]
render(context, viewport)[source]

Renders the component.

Parameters:
  • context – MjrContext instance.

  • viewport – Viewport instance.

class dm_robotics.panda.utils.TimeSensor[source]

Bases: Sensor

MoMa sensor measuring simulation time.

__init__() None[source]
get_obs_key(obs: Enum) str[source]

Returns the key to an observable provided by this sensor.

initialize_episode(physics: Physics, random_state: RandomState) None[source]

Called on a new episode, after the environment has been reset.

This is called before the agent has got a timestep in the episode that is about to start. Sensors can reset any state they may have.

Parameters:
  • physics – The MuJoCo physics the environment uses.

  • random_state – A PRNG seed.

property name: str
property observables: Dict[str, Observable]

Get the observables for this Sensor.

This will be called after initialize_for_task.

It’s expected that the keys in this dict are values from self.get_obs_key(SOME_ENUM_VALUE), the values are Observables. See the class docstring for more information about Observable.

subclassing dm_control.composer.observation.observable.Generic is a simple way to create an Observable. Observables have many properties that are used by composer to alter how the values it produces are processed.

See the code dm_control.composer.observation for more information.

dm_robotics.panda.utils.default_arg_parser(desc: str = 'dm_robotics_panda', dual_arm: bool = False) ArgumentParser[source]

Create an ArgumentParser with default parameters. :param desc: Description shown in the help screen. :param dual_arm: Create parameters for a dual-arm setup.

dm_robotics.panda.utils.full_spec(env: Environment)[source]

Prints the full specification of the environment, i.e. action, observation and reward spec.

dm_robotics.panda.utils.init_logging() None[source]

Set the standard log format and handler.

dm_robotics.panda.utils.set_joint_damping(damping: Sequence[float], arm: Arm, physics: Physics)[source]

Update the joint actuation damping of the robot arm.

dm_robotics.panda.utils.set_joint_stiffness(stiffness: Sequence[float], arm: Arm, physics: Physics)[source]

Update the joint actuation stiffness of the robot arm.