Motor simulator#

A single DC-motor joint: simulated dynamics, a noisy encoder and a privileged PD expert.

Classes

OneMotor

One position-controlled motor joint (simulated).

Functions

expert_command

Saturated PD command toward target (used as the demonstrator; it sees the true target).

class OneMotor(gain=8.0, damping=2.0, coulomb=0.3, dt=0.05, encoder_noise=0.005, velocity_filter=0.4, randomise=True)[source]#

Bases: object

One position-controlled motor joint (simulated).

dtheta = omega, domega = gain*u - damping*omega - coulomb*tanh(omega/0.02) with the command u clipped to [-1, 1]. The joint position is normalised to the workspace [-1, 1]. The encoder reads the position with Gaussian noise; the velocity estimate is a filtered finite difference of the noisy readings, as on a real drive.

randomise draws the gain and damping per episode (domain randomisation), so a policy cannot memorise one plant.

Parameters:
measure(first=False)[source]#

Noisy (theta, omega) as the controller sees them.

expert_command(target, theta, omega, kp=3.0, kd=1.0)[source]#

Saturated PD command toward target (used as the demonstrator; it sees the true target).