polysim package

Subpackages

Submodules

polysim.grpc_sim_client module

class polysim.grpc_sim_client.GrpcSimulationClient(metadata_cfg: Optional[DictConfig] = None, env: Optional[AbstractControlledEnv] = None, env_cfg: Optional[DictConfig] = None, ip: str = 'localhost', port: int = 50051, log_interval: int = 0, max_ping: float = 0.0, mirror_hz: float = 24.0)

Bases: AbstractRobotClient

A RobotClient which wraps a PyBullet simulation.

Parameters:
  • metadata_cfg – A Hydra config which sepcifies the metadata required to initialize a RobotClient with the server.

  • env – A simulation environment implementing AbstractControlledEnv.

  • env_cfg – If env is not passed, this is a Hydra config which specifies an env to instantiate an equivalent env.

  • ip – Server IP.

  • log_interval – Log every log_interval number of timesteps. 0 if no logging.

  • max_ping – The amount of time in seconds; if a request takes long than this, send a debug message warning.

execute_rpc_call(request_func: Callable, args=[], log_request_time=False)

Executes an RPC call and performs round trip time intervals checks and logging

Parameters:
  • request_func – A Python function to call an RPC.

  • args – List of arguments to pass to request_func.

  • log_request_time – Whether to log the debug messages.

init_robot_client()
kill_run()
run(time_horizon=inf, threaded=False)

Start running the simulation and querying the server.

Parameters:

time_horizon – If finite, the number of timesteps to stop the simulation.

run_no_wait(time_horizon=inf)
set_robot_state(robot_state: RobotState)
sync(tgt_robot: RobotInterface, timesteps: int = -1)
unsync()

polysim.test_utils module

Utilities for unit testing.

class polysim.test_utils.FakeConnection(channel)

Bases: object

ControlUpdate(robot_state)
InitRobotClient(metadata)
class polysim.test_utils.FakeEnv(n_dim=1)

Bases: AbstractControlledEnv

apply_joint_torques(torques)
input:

np.ndarray: Desired torques

get_current_joint_pos_vel()
Returns:

Joint positions np.ndarray: Joint velocities

Return type:

np.ndarray

get_current_joint_torques()
Returns:

Torques received from apply_joint_torques np.ndarray: Torques sent to robot (e.g. after clipping) np.ndarray: Torques generated by the actuators (e.g. after grav comp) np.ndarray: Torques exerted onto the robot

Return type:

np.ndarray

get_num_dofs()

Get the number of degrees of freedom for controlling the simulation.

Returns:

Number of control input dimensions

Return type:

int

reset()

Reset the environment.

set_robot_state(robot_state)
input:

RobotState: Desired state of robot

class polysim.test_utils.FakeMetadata(hz)

Bases: RobotClientMetadata

get_proto()

Returns the underlying protobuf message.

polysim.test_utils.fake_metadata_cfg = {'_target_': 'polysim.test_utils.FakeMetadata', 'hz': 10}

A fake metadata for testing.

Module contents