🏋️

Setting Up A Gym

Building on top of the previous tutorial:


In this tutorial, we walk through how to interact with the FrankaEnv environment from Ark. This interface is built to resemble OpenAI Gym, enabling easy integration with reinforcement learning and control pipelines.

🛠️ Prerequisites

Before starting, ensure:


🚀 Code Walkthrough

1. Import Required Modules

from scripts.franka_env import FrankaEnv
import time

2. Define Configuration Parameters

SIM = True  # Set to False if you want to use the real robot
CONFIG = 'config/global_config.yaml'

3. Initialise the Environment

env = FrankaEnv(sim=SIM, config=CONFIG)

This creates an instance of the environment. Internally, it:


4. Reset the Environment

observation, info = env.reset()

5. Define a Policy

def policy(observation):
    ...
    return action

This is a placeholder for your control policy. It takes in the current observation and returns an action:


6. Run the Control Loop

for _ in range(1000):
    action = policy(observation)
    observation, reward, terminated, truncated, info = env.step(action)

    if terminated or truncated:
        observation, info = env.reset()

Running the Gym

You need to run two nodes the simulation:

You should see the Franka move randomly or according to the policy you have defined.


Code can be found:

https://github.com/Robotics-Ark/franka_gym_example

Next Steps

Try writing your own Behavioural Cloning Algorithm, Diffusion Policy or even ACT!