The 6-DOF robot arm in PyBullet, reaching for a red cube, with a red cross marking the target

Teaching My Robot Arm to Pick and Place with Reinforcement Learning

SAC vs PPO on a custom 6-DOF arm in PyBullet

Spring 2026 · CS 5180, Northeastern University

For my reinforcement learning class (CS 5180), I trained my own 6-DOF robot arm to pick up a cube and place it on a target, entirely in simulation. I compared two popular deep RL algorithms, Soft Actor-Critic (SAC) and Proximal Policy Optimization (PPO), against a scripted controller that knows exactly where everything is.

SAC came out well ahead. At their best checkpoints, all five SAC runs succeeded 91 to 100% of the time, and three of them kept that to the end of training. PPO learned the task on only one run out of five. This page covers how I built the environment, the results, and what the training logs show about why runs failed.

Why Build My Own Environment?

Most RL manipulation research uses ready-made environments for well-known robots like the Franka Panda, with the rewards and observations already tuned. My arm is my own design, and its robot description (URDF) was built alongside the real hardware so that a trained policy could one day run on the real arm. That meant there was no pre-tuned environment to use. I had to build the simulation, the reward function, the observations and the actions from scratch, and getting those right turned out to be most of the project.

The Environment

The simulation runs in PyBullet, wrapped in the standard Gymnasium interface. To keep the problem small enough to train on a laptop, I simplified the task:

What the agent sees

The agent gets a 10-number observation every step:

What the agent controls

The agent outputs 4 numbers between −1 and 1: \((a_x, a_y, a_z, a_{\text{grip}})\). The first three move the gripper by up to 5 mm in each direction, and the sign of the fourth opens or closes the gripper. An inverse kinematics solver turns the target gripper position into joint angles every step, and keeps the gripper pointing straight down.

I started out letting the agent control the joint speeds directly, but that space was too big and the agent never learned anything useful. Switching to moving the gripper in \(x\), \(y\), \(z\) made the problem much smaller and lined the actions up with the task, and the agent started learning right away.

The reward

Before the agent grabs the cube, it's rewarded for getting the gripper closer to the cube. While it holds the cube, it's rewarded for getting the cube closer to the target:

\[r_{\text{progress}} = \begin{cases} 10\,(d_{\text{gripper→cube}}^{\,\text{before}} - d_{\text{gripper→cube}}^{\,\text{after}}) & \text{not holding} \\[4pt] 10\,(d_{\text{cube→target}}^{\,\text{before}} - d_{\text{cube→target}}^{\,\text{after}}) & \text{holding} \end{cases}\]

On top of that:

EventReward
Every step−0.02
First grasp of the episode+5
Each step holding the cube+0.01
Release within 5 cm of the target (episode ends)+50
Release anywhere else−3
Arm or gripper touching the floor, per step−1 or −0.5
Arm hitting itself (episode ends)−20
Hints before the first grasp: far from the cube with the gripper open / close to it and closing / close to it and open+0.01 / up to +0.02 / −0.02

My first version penalized the absolute distance to the goal, and the agent learned to hover next to the cube without grabbing it, collecting reward just for being close. Rewarding progress instead fixed that for SAC. As it turned out, the small hint terms brought a version of the problem back for PPO (more on that below).

Episodes

An episode ends on success, when the arm hits itself, or after 150 steps. Dropping the cube doesn't end it, so the agent can try to grab it again.

Getting the physics to behave

PyBullet kept reporting contacts that weren't really there on the gripper's sliding fingers, which ended episodes for no reason. The fingers were using detailed mesh models for collisions. I replaced them with simple boxes, and the phantom collisions went away.

How the environment changed

WhatChangeWhyResult
ActionsJoint speeds → gripper \(x\), \(y\), \(z\) movesAgent couldn't learn in the larger spaceLearned from scratch
RewardAbsolute distance → progressAgent hovered next to the cubeSAC stopped hovering
Dropping the cubeEnds episode → doesn't end episodeAgent couldn't recover from a bad graspRecovers from failed grasps
CollisionsMeshes → simple boxesPhantom collisions ended episodesStable contact physics

The Two Algorithms

Soft Actor-Critic (SAC)

SAC is an off-policy algorithm, which means it saves past experience in a replay buffer and keeps learning from it. It also tries to act as randomly as it can while still doing the task, which keeps it exploring instead of locking into one behavior too early. A temperature setting \(\alpha\) (the entropy coefficient) controls how much it cares about randomness compared to reward. Its two Q-networks are trained toward this target:

\[y = r + \gamma (1 - d) \left[ \min_{i=1,2} Q_{\bar{\theta}_i}(s', \tilde{a}') - \alpha \log \pi_\theta(\tilde{a}' \mid s') \right]\]

where \(\tilde{a}'\) is an action sampled from the current policy and \(d\) marks the end of an episode.

Proximal Policy Optimization (PPO)

PPO is on-policy. It collects a batch of experience with the current policy, updates the policy, and then throws that data away. To keep any single update from changing the policy too much, it clips the ratio \(r_t(\theta)\) between the new and old policies:

\[L^{\text{CLIP}}(\theta) = \mathbb{E}_t \left[ \min\!\big( r_t(\theta)\hat{A}_t,\ \operatorname{clip}(r_t(\theta), 1-\epsilon, 1+\epsilon)\,\hat{A}_t \big) \right]\]

where \(\hat{A}_t\) is how much better an action was than expected, and \(\epsilon\) sets how far the ratio can move. I also used a KL-divergence limit, which stops an update early if the policy changes too much.

The baseline

I also wrote a scripted controller that reads the exact positions of the cube and the target from the simulator. It runs through six steps (hover, descend, close, lift, transport and release), using the same 4-number actions as the RL agents.

Training Setup

I used the SAC and PPO implementations from Stable-Baselines3. Both used neural networks with two hidden layers of 256 units, and both normalized their observations and rewards. I trained five runs of each algorithm with seeds 1 to 5. During training, each run was tested every 10k steps on 20 episodes, and the best checkpoint was saved. At the end, I tested every best checkpoint, and the final weights, on 100 fresh episodes without action noise.

SettingSACPPO
Learning rate3e-43e-4
Batch size256256
Discount \(\gamma\)0.980.99
Entropy coefficient0.01 (fixed)0.01
Replay buffer500kNone
Steps per updaten/a512 × 8 parallel envs
Epochs per updaten/a10
Clip range / target KLn/a0.2 / 0.05
Total timesteps700k2.5M

Results

RunBest checkpointFinal weights
Scripted controller81% (grasps 99%)
SAC seed 198%0%
SAC seed 299%100%
SAC seed 3100%98%
SAC seed 499%100%
SAC seed 591%0%
PPO seed 197%97%
PPO seed 20%0%
PPO seed 30%0%
PPO seed 40% (grasps 97%)0% (grasps 90%)
PPO seed 50%0%
Seeds that solved itSAC 5 of 5, PPO 1 of 5SAC 3 of 5, PPO 1 of 5

Success rates over 100 test episodes. At its best checkpoint, SAC averaged 97.4% and finished in about 48 steps. Two SAC runs, seeds 1 and 5, collapsed during training and ended at 0%. SAC seed 5's best checkpoint comes from only 70k steps in, before its collapse.

One detail of the test loop: Stable-Baselines3 resets the environment by itself at the end of each episode, and my loop reset it again. So the RL agents were tested on every other starting setup, not the same 100 as the scripted controller. Testing them on exactly the same setups changes every result by 3 points or less.

Training curves for SAC and PPO, averaged over five seeds with a shaded spread
Training reward averaged over five seeds. The SAC average drops after about 100k steps because some seeds collapse, not because every seed gets worse
Training curves for each of the five SAC and PPO seeds
Every seed on its own. SAC seeds 1, 4 and 5 all collapse at some point, and only seed 4 recovers. Only PPO seed 1 ever learns the task

What Went Wrong, and Why

The training logs and checkpoints show what was behind each of these results.

The scripted controller missed because it steered the wrong point

The scripted controller grabbed the cube 99% of the time but only placed it 81% of the time. It wasn't the cube's size, which never changes. In 18 of its 19 failures, the controller put the gripper within 2 mm of the drop point, but the cube was 4 to 9 cm off target. The simulated grasp locks the cube wherever it happens to be when the fingers close, and in some grasps that's about 5 cm above the gripper's tool point. The controller steers the tool point, while SAC sees the cube's actual position, so SAC corrects for it. Beating the controller says more about its bug than about SAC. If it steered the cube instead, it should get close to 100%.

SAC's collapses came from its critic

Every SAC collapse lines up with the critic's loss blowing up. Seed 5's went from 0.07 to about 9,000, seed 1's to about 700, and seed 4's to about 50 before it recovered. That points to the value estimates becoming unstable, rather than the policy simply running out of exploration.

Changing the entropy coefficient

I also trained SAC with a higher entropy coefficient, 0.05 instead of 0.01. None of those five runs collapsed, but none scored above 49% in the 100-episode tests either, even without action noise. Those runs trained for 500k steps instead of 700k, and 3 collapses out of 5 against 0 out of 5 isn't conclusive with this few seeds. Still, the lower setting reached a much better policy, but less reliably.

SAC training curves with entropy coefficients of 0.05 and 0.01
Training reward with entropy coefficients of 0.01 and 0.05. The 0.05 runs are stable but plateau lower, and stop at 500k steps

PPO got stuck hovering just outside the hint zone

The three PPO runs that never grabbed the cube all did the same thing: they never closed the gripper, and they stopped 5.2 to 5.3 cm from the cube. That's right at the edge of the 5 cm zone where my hint terms change. Outside the zone with the gripper open, the agent loses 0.01 per step. Inside it with the gripper open, which is how you have to approach a cube, it loses 0.04 per step. Hovering just outside the zone is a local optimum that my own hints created. Their action noise also shrank to about 0.3 early in training, so they stopped exploring. The one PPO run that succeeded kept its noise around 1.0. Seed 4 got further: it learned to grab the cube but never to place it.

The "reward sensitivity" experiment changed more than the reward

I also tried PPO with a slightly different reward: a smaller floor penalty and simpler hints. In that experiment, I had also raised PPO's entropy coefficient from 0.01 to 0.05 and trained for 4M steps instead of 2.5M. With the higher entropy bonus, PPO's action noise grew without limit, from about 5 to over 108. Two runs looked like they learned the task and then forgot it. In fact, only their noisy training behavior ever worked: tested without noise, those runs never got above about 55%, and their final weights scored 0%. The collapse came from the noise blowing up, not from the reward change. I also never ran SAC with this reward, so the experiment doesn't compare the two algorithms.

PPO training curves under the main reward and the modified reward
PPO training reward with the main reward (left) and the modified reward with a higher entropy coefficient (right). The rise and collapse on the right track the action noise growing out of control

Comparing with published work

Lobbezoo and Kwon (2023) found the opposite on a Panda arm, with PPO beating SAC (85% vs 71%). Their PPO, though, needed 8.3M steps, hyperparameter sweeps, high entropy settings and 5- to 7-layer networks. Mine had 2.5M steps and no tuning, which is enough to explain the difference.

What I'd Change

Conclusion

On this simplified pick-and-place, SAC reached about 99% on all five seeds and kept it on three. PPO learned it on one. The bigger lesson came from the logs: most of the failures traced back to choices I made in the environment and the experiments, not to the algorithms. The controller steered the wrong point, my reward hints created a trap, and one experiment changed two things at once. Most of my time went into environment design, and that's also where most of the problems were.

Thanks for reading!