Readme and comments and reward pdated
readme was outdated env rewards got a penalty for standing still while it should move instead of 0 reward
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
"""
|
||||
ml/env.py - Gymnasium Environment for JackBot Hexapod RL Training
|
||||
ml/env.py - Gymnasium environment for JackBot RL training and evaluation.
|
||||
|
||||
This file defines JackBotEnv, the main training/evaluation environment used by PPO.
|
||||
It wraps the PyBullet simulation and Robot interfaces into a Gymnasium-compatible
|
||||
step/reset loop, manages command sampling, curriculum progression, and reward
|
||||
calculation, and exposes metrics that the training callbacks can log.
|
||||
"""
|
||||
import time
|
||||
import math
|
||||
@@ -363,7 +368,10 @@ class JackBotEnv(gym.Env):
|
||||
target_speed = math.hypot(target_vx, target_vy)
|
||||
|
||||
if not is_moving:
|
||||
total_reward = 0.0
|
||||
# If the command says move but the robot stays effectively still,
|
||||
# give a real penalty instead of a neutral reward.
|
||||
stillness_penalty = -0.10
|
||||
total_reward = stillness_penalty
|
||||
else:
|
||||
lin_vel_error = (filtered_vx - target_vx)**2 + (filtered_vy - target_vy)**2
|
||||
r_lin_vel = math.exp(-25.0 * lin_vel_error)
|
||||
@@ -371,7 +379,7 @@ class JackBotEnv(gym.Env):
|
||||
|
||||
if target_speed > 0.08 and raw_speed < 0.03:
|
||||
r_lin_vel = 0.0
|
||||
stillness_penalty = -0.1 # Softened from -0.25
|
||||
stillness_penalty = -0.05
|
||||
|
||||
w_lin_vel, w_ang_vel, w_height, w_stability, w_smoothness = 0.55, 0.15, 0.10, 0.12, 0.08
|
||||
total_reward = (
|
||||
@@ -381,7 +389,7 @@ class JackBotEnv(gym.Env):
|
||||
|
||||
step_reward = float(total_reward / 10.0)
|
||||
alive_bonus = 0.01
|
||||
final_reward = max(0.0, step_reward + jitter_penalty + alive_bonus)
|
||||
final_reward = step_reward + jitter_penalty + alive_bonus
|
||||
|
||||
self.last_reward_components = {
|
||||
"height": float(r_height),
|
||||
|
||||
Reference in New Issue
Block a user