TT Lab
Blog

한국어 English 日本語 中文

Get started
Blog

Blog

Reward Design and Action Space: Sparse vs. Shaped Rewards, Reward Hacking, Joint Limit Penalties, Direct Control vs. Hybrid

Status: Draft (2026-10-18), Measured. Numbers are simulation values directly calculated using Python 3.9.6 and numpy 2.0.2 on a laptop (Apple M1 Max, macOS 26.5). Raw data and code: working directory measure/robot-arm-basics/rl/, results ttenv.py, ppo.py, exp_rl.py. out/rl/rew_*, out/rl/hyb_*, out/rl/ppo_base_*All training uses 3 seeds, and evaluation is conducted on 1,000 balls not used in training. There are no real robot experiments (hardware not measured). References were accessed on 2026-10-18. Writing rules: Measured data is the default; unmeasured items are marked as "Unmeasured", and unverified items are marked as "Unverified".

Table of Contents

1. Intuition: Doing as Told

Reinforcement learning agents do not know the designer's intent. They only know how to maximize the sum of rewards. If you tell them "reward when hitting the ball," they will find the easiest way to hit the ball, and they do not care whether that method actually lands the ball on the table. The phenomenon where rewards exploit loopholes that deviate from the intended goal is called reward hacking. Amodei et al. (2016) cited this as one of the five concrete problems in AI safety.

The action space is a design choice of equal weight. You can have the policy determine joint accelerations every 10 ms, or you can have it decide just once "when and how hard" to hit while leaving the rest to the classical methods from Episodes 1-10. The former is flexible but requires a lot of learning; the latter learns quickly, but if the classical part is flawed, it remains trapped by those limitations.

2. Five Rewards

All use direct control (joint acceleration every 10 ms), default PPO settings (Episode 12), and 19,200 episodes.

Name Reward Intent
Sparse 1 if landed on the opponent's table, 0 otherwise Exactly what is desired
Shaped (Default) 0.3 for hitting, +1 for scoring, up to +0.5 closer to target (y = 0.9 m), penalty equal to the closest distance between racket and ball if missed (up to −0.5) Provides guidance in early training
Shaped + Limit Penalty In addition to above, −0.05 for every step touching a joint limit Safety
Hit Only 1 if hit by the racket Hacking experiment
Ball Speed Ball speed after hit ÷ 10 Hacking experiment ("Hitting hard must be good")

Training uses rewards, but evaluation always uses the same criterion, which is "did it land on the opponent's table?" This is because comparing reward numbers across experiments with different reward functions is meaningless.

3. Measurement: Rewards

보상을 바꾸면 배우는 것이 바뀐다(직접 제어, 공 1만 9천 개) 0 25 50 75 100 % 87 93 40 희소 83 93 70 형태(기본) 89 92 8 형태+ 한계 벌점 0 99 100 맞히기만 0 98 100 공 속도 성공(돌려보냄) 라켓에 맞음 관절 한계에 닿은 에피소드 평가 공 1,000개, 시드 3개 중앙값(막대)과 최소~최대(선).
Figure: Success rate by reward, hit rate on the racket, and proportion of episodes hitting joint limits
Reward Success Median (Min–Max) Hit Racket Episodes Hitting Joint Limits Median Speed of Hit Ball
Sparse 86.8% (75.4~90.7) 92~96% 5~48% 5.2 m/s
Shaped (Default) 82.9% (76.8~90.9) 88~94% 4~79% 5.3–5.6 m/s
Shaped + Limit Penalty 89.2% (77.9~90.3) 84~92% 5~8% 5.3–5.5 m/s
Hit Only 0.0% (0.0~8.9) 98~99% 100% 9–28 m/s
Ball Speed 0.0% (0.0~0.0) 98% 100% 28.6 m/s

3.1 Reward Hacking

The "Hit Only" and "Ball Speed" rewards were huge successes in terms of their reward criteria. The racket hit 98% of the balls, and the "Ball Speed" policy sent balls flying at an average of 28.6 m/s. However, almost no balls landed on the table. Both policies swung their joints to the limit in every episode. This is because maximizing racket speed makes it easier to hit the ball and makes the ball move faster. With a real robot, this policy would slam the joint stoppers on every single stroke.

The lesson is simple: evaluate by the real goal, not the reward numbers, and suspect hacking if rewards go up while the goal remains unchanged.

3.2 Sparse and Shaped Rewards

Shaped rewards are often recommended as "early training guides," but in this problem, the sparse reward (86.8%) actually slightly outperformed the shaped reward (82.9%) (the difference is within range given 3 seeds). Two reasons are suspected. First, since even a random policy succeeds 1.5% of the time (Episode 11), one or two out of every 64 episodes receive a success signal. When success is not extremely rare, guidance is less necessary. Second, intermediate rewards like "0.3 for hitting" teach the model that "hitting and missing the table" is better than "missing entirely," which mixes in directions slightly different from the true goal. Shaped rewards pay off in problems where success is much rarer (e.g., smashing with a 7-DOF arm from the start), and even then, they must be designed not to conflict with the goal (unmeasured).

3.3 Joint Limit Penalties

With a single penalty, episodes hitting the limits dropped from 4–79% down to 5–8%, without sacrificing success rate (89.2%). The default policy of Episode 12 hit the limits not because it needed to, but because it was never told not to. Some argue that safety conditions are more reliably handled as constraints rather than rewards. Real robots apply hard limits on the controller side separately from penalties.

4. Action Space: Direct Control vs. Hybrid

Direct controlis identical to Episode 11. There are around 100 decisions per episode, and the policy must figure out the timing, trajectory, and racket angle entirely on its own.

Hybridselects only two numbers at the first step: a correction to the contact angle Δφ (±0.15 rad) and the racket angular velocity at impact φ̇_c (0–8 rad/s). The rest is handled by classical methods. Using a ball flight model (Episode 6) to predict where and when the ball enters the racket arc, a quintic trajectory (Episode 8) is generated to reach that spot at that speed and executed as is. As a reinforcement learning problem, this becomes a single-step problem (contextual bandit). Training was conducted for 120 iterations with 64 balls per iteration (7,680 balls total).

Two predictors were tested: a predictor that ignores spin, like the "B model" in Episode 6, and a predictor that accounts for spin.

행동 공간: 매 10 ms 직접 제어 대 타격 파라미터만 0 5k 10k 14k 19k 0 25 50 75 100 학습에 쓴 에피소드(공) 수 평가 성공률(%) 격자 상한 85% 최선 상수 46% 직접 제어 83% 하이브리드(회전 모르는 예측기) 46% 하이브리드(회전 아는 예측기) 66% 하이브리드는 공 7,680개에서 멈춤. 점선은 학습 없는 기준선.
Figure: Learning curves and baselines for direct control and hybrid
Action Space Success Median (Min–Max) Number of Balls to First Exceed 40% (Seed Median) Episodes Hitting Joint Limits
Direct Control (Shaped Reward) 82.9% (76.8~90.9) 5,120 4~79%
Hybrid, Spin-Ignorant Predictor 46.3% (36.1~48.0) 1,920 0~0.7%
Hybrid, Spin-Aware Predictor 65.6% (39.0~73.8) 1,280 0.3~0.9%

Baselines without training were the best constant action in the hybrid action space at 46%, the grid planner with the spin-ignorant model at 40%, and the upper bound of the grid chosen using true outcomes at 85% (Episode 11).

4.1 What Was Read

4.2 Choices in Real Systems

System Learned by Training
Büchler et al. 2022 (v1) Pressure changes in 8 muscles (lowest level)
D'Ambrosio et al. 2023 8 joint velocities by default; task-space actions of 3 racket positions + 2 normals also compared
D'Ambrosio et al. 2024 Skill policy uses joint velocities (50 Hz), high-level controller above it chooses one of 17 skills
Tebbe et al. 2021 Racket state at impact (orientation/speed)

Going down the list delegates more to classical components (trajectory, inverse kinematics, ball prediction). For the first open-hardware robot, starting with a hybrid approach to gain sample efficiency and safety is recommended, followed by identifying weaknesses in the classical part (such as spin prediction) and then fixing them or expanding them through learning.

5. Limitations

6. Conclusion

A word from TT. "When we said 'praise the robot for hitting the ball,' the robot hit every ball and scored zero! Praise should only be given to what you truly want!"

References

All materials were accessed on 2026-10-18.

Sign in to like

Comments

No comments yet.

Sign in to leave a comment