Product
Training a Franka Panda to Push a Cube With Reinforcement Learning
Reinforcement learning lets a robot learn by trial and error. Drift sets up the Gymnasium environment to train a Franka Panda to push a cube with PPO in MuJoCo.

What happens when you stop telling a robot exactly how to move, and let it work the task out for itself? That's the whole idea behind reinforcement learning.
Our earlier Franka Panda demos told the arm exactly what to do, every grasp and placement scripted in advance. This one is different. We use reinforcement learning to train a Franka Panda to push a cube onto a target, which means we don't program the motion at all. We give the robot a goal and let it discover how to reach it through trial and error, with Drift generating the whole training setup from a prompt.
What reinforcement learning actually means here?
Reinforcement learning (RL) is a way for a robot to learn a task by trying it many times and getting feedback on how well it did. Rather than being told the exact motions, the robot takes an action, receives a reward score for how close it got to the goal and gradually adjusts its behaviour to earn more reward. Over thousands of attempts, it converges on a strategy that works.
A few plain-language terms show up in this build:
- Policy: The robot's learned strategy, its internal rule for what to do given what it currently sees.
- Reward: A score the environment gives after each action, telling the robot how good or bad that action was. Pushing the cube toward the target earns more reward.
- PPO: Proximal Policy Optimization, a popular and reliable RL algorithm. It's the method that actually improves the policy from all those attempts.
- Gymnasium environment: The standard wrapper that defines the task, what the robot senses, what actions it can take, how reward is calculated, and when an episode ends, so an RL algorithm like PPO can train against it.
This is the hands-on version of why robots train in simulation: the robot needs thousands of attempts, and only a simulator can provide them safely and fast.
Setting up the training environment
We start from the existing Franka Panda scene in MuJoCo, the same one from the pick-and-place walkthrough, and create a separate Python virtual environment for the training code, so the RL setup stays isolated from the rest of the project. Then we launch Drift and initialize a new project for the task.
Keeping the training setup in its own environment is good practice, since RL training pulls in specific libraries, and you don't want them tangled up with your simulation scene.
The prompt that defines the whole RL task
Rather than writing the RL code by hand, we give Drift the key constraints for the task: reuse the existing Franka scene, set up a Gymnasium environment, randomize the cube's starting position on each reset, and define the rewards and success detection needed to train and evaluate a PPO policy.
That single prompt describes the whole training pipeline at a high level. Randomizing the cube position matters, because it forces the robot to learn to push a cube from anywhere, not just memorize one fixed motion. That's the difference between a policy that generalizes and one that only works in a single rehearsed case.
The training pipeline Drift generates
From that prompt, Drift generates the full setup: the Gymnasium environment, randomized resets, the reward function, and success detection, along with two separate scripts, one to train the policy and one to evaluate it.
Writing all of this by hand is fiddly and error-prone. The reward function alone usually takes careful tuning, since a poorly shaped reward can teach the robot the wrong thing entirely. Having the pipeline generated as a working starting point means you can go straight to training and iteration instead of debugging boilerplate.
Training the PPO policy
With the pipeline in place, we run the training script and let PPO go to work. The robot attempts the push over and over, and after each attempt PPO nudges the policy toward whatever earned more reward.
In the training output you can watch the numbers tick up: steps, episodes, and the reward per episode climbing as the policy improves. Early on the arm flails and misses. As training continues, the reward trends upward, a sign the robot is genuinely learning the task rather than moving at random. This is the part that takes time and compute, which is exactly why it happens in simulation and not on a real arm.
Watching the learned policy in action
Once training finishes, we run the evaluation script and MuJoCo opens so we can see what the policy actually learned. Each episode starts with the cube in a new position, so the robot has to apply what it learned rather than repeat a memorised path.
The arm moves in, tries to push the cube toward the target, and the script reports whether each attempt succeeded, a simple true or false per episode. It isn't perfect. You'll see some misses and clumsy attempts mixed with clean successes. But across the episodes you can watch the policy starting to genuinely figure out the task, which is the whole point: nobody told it how to push the cube, it worked that out on its own.
Why this matters for robot learning?
That's reinforcement learning in action. Instead of programming every movement, we gave the robot a goal, a reward, and a place to practice, and it learned how to reach the goal through trial and error.
This is the same principle behind much of modern robot learning, from locomotion to manipulation, and it's a foundational technique in embodied AI. With Drift generating the training pipeline, the tedious setup is handled, so you can focus on the interesting parts: shaping better rewards, training longer, or trying harder tasks. Change the reward, retrain, and watch how the behavior shifts. The full walkthrough is in the video above.
FAQ
- What is reinforcement learning in robotics? Reinforcement learning is a method where a robot learns a task by trial and error. It takes an action, receives a reward score for how well it did, and gradually adjusts its strategy to earn more reward. Over many attempts it learns a behavior without being explicitly programmed with the motions.
- What is PPO? PPO (Proximal Policy Optimization) is a widely used reinforcement learning algorithm. It's popular because it's relatively stable and reliable at improving a robot's policy from repeated attempts, which makes it a common default choice for training control tasks.
- What is a Gymnasium environment? Gymnasium is a standard interface for reinforcement learning that defines a task: what the agent observes, what actions it can take, how reward is calculated, and when an episode ends. Wrapping a robot task in a Gymnasium environment lets standard RL algorithms like PPO train against it.
- Why randomize the cube's position during training? Randomizing the starting position forces the robot to learn a general pushing skill instead of memorizing one fixed motion. A policy trained only on a single position would fail as soon as the cube moved, so randomization is what makes the learned behavior robust.
- How does Drift set up reinforcement learning? From a single prompt, Drift generates the full RL pipeline: a Gymnasium environment, randomized resets, a reward function, success detection, and separate training and evaluation scripts, reusing the existing MuJoCo scene, so you can train a PPO policy without hand-coding the setup.


