Custom environment

A customized environment is the junction of a task and a robot. You can choose to define your own task, or use one of the tasks present in the package. Similarly, you can choose to define your own robot, or use one of the robots present in the package.

Then, you have to inherit from the RobotTaskEnv class, in the following way.

from panda_gym.envs.core import RobotTaskEnv
from panda_gym.pybullet import PyBullet


class MyRobotTaskEnv(RobotTaskEnv):
    """My robot-task environment."""

    def __init__(self, render=False):
        sim = PyBullet(render=render)
        robot = MyRobot(sim)
        task = MyTask(sim)
        super().__init__(robot, task)

That’s it.

Test it

You can now test your environment by running the following code.

env = MyRobotTaskEnv(render=True)

obs = env.reset()
done = False
while not done:
    action = env.action_space.sample() # random action
    obs, reward, done, info = env.step(action)
    env.render() # wait a bit to give a realistic temporal rendering