Polysim¶
The package containing the Polymetis simulation client. Includes a wrapper around PyBullet.
Developing custom environments¶
All simulation environments must inherit from the abstract simulation environment class AbstractControlledEnv to work with the Simulation Client.
from polysim.envs import AbstractControlledEnv
class MyCustomEnv(AbstractControlledEnv):
... # define methods here
The created simulation environment must define the following functions (see abstract_env.py for details):
resetget_num_dofsget_current_joint_pos_velget_current_joint_torquesapply_joint_torques
Sample simulation environments can also be found in polysim/envs
You must also define metadata around your simulation environment which instantiates a RobotClientMetadata object. An example configuration is in the default config under metadata_cfg.
The Simulation Client is implemented as a wrapper around the simulation environment. To connect a simulation environment to a local server and run for 1000 steps:
from polysim import GrpcSimulationClient
from polymetis.robot_client_metadata import RobotClientMetadata
env = MyCustomEnv(...)
metadata_cfg = {"key": "value"}
sim = GrpcSimulationClient(
env=env,
metadata=metadata_cfg,
ip="localhost",
)
sim.run(time_horizon=1000)
Notes:
ipis the IP of the Controller Manager Server.If the
time_horizonargument is not specified, the simulation will run indefinitely unless terminated.