feat: expanded used var doc, and added distance to target log
This commit is contained in:
parent
1c328bdde1
commit
c5a8dd2b3a
4 changed files with 35 additions and 6 deletions
|
|
@ -4,7 +4,7 @@ seed: 42
|
||||||
track: true
|
track: true
|
||||||
wandb_project_name: "Let's-find-that-bug"
|
wandb_project_name: "Let's-find-that-bug"
|
||||||
wandb_entity: "SEL3-2026-Groep-4"
|
wandb_entity: "SEL3-2026-Groep-4"
|
||||||
|
run_dir: "/data/gent/465/vsc46589"
|
||||||
num_envs: 32
|
num_envs: 32
|
||||||
num_steps: 32
|
num_steps: 32
|
||||||
total_timesteps: 102400
|
total_timesteps: 102400
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
## Default envconfig
|
## Default envconfig
|
||||||
task: Task = Task.DIRECTED_LOCOMOTION
|
task: Task = Task.DIRECTED_LOCOMOTION
|
||||||
simulation_time: float = 5.0
|
simulation_time: float = 500.0
|
||||||
num_physics_steps_per_control_step: int = 10
|
num_physics_steps_per_control_step: int = 10
|
||||||
time_scale: int = 2
|
time_scale: int = 2
|
||||||
camera_ids: list[int] = field(default_factory=lambda: [0, 1])
|
camera_ids: list[int] = field(default_factory=lambda: [0, 1])
|
||||||
|
|
@ -53,6 +53,8 @@ use_torque_control: bool = False
|
||||||
|
|
||||||
## MLPs:
|
## MLPs:
|
||||||
### Sensor & Feature_extractor:
|
### Sensor & Feature_extractor:
|
||||||
|
Both with 3 layers of 300 neurons per layer.
|
||||||
|
|
||||||
class GenericDenseLayersWithActivation(nn.Module):
|
class GenericDenseLayersWithActivation(nn.Module):
|
||||||
layer_sizes: Sequence[int] = field(default_factory=lambda: [64, 64])
|
layer_sizes: Sequence[int] = field(default_factory=lambda: [64, 64])
|
||||||
activation: Callable = nn.tanh
|
activation: Callable = nn.tanh
|
||||||
|
|
@ -80,3 +82,15 @@ class OneDenseLayerMLP(nn.Module):
|
||||||
return nn.Dense(1, kernel_init=orthogonal(1), bias_init=constant(0.0))(x)
|
return nn.Dense(1, kernel_init=orthogonal(1), bias_init=constant(0.0))(x)
|
||||||
|
|
||||||
### Observations:
|
### Observations:
|
||||||
|
_ALLOWED_OBS_KEYS = {
|
||||||
|
"joint_position",
|
||||||
|
"joint_velocity",
|
||||||
|
"joint_actuator_force",
|
||||||
|
"actuator_force",
|
||||||
|
"disk_position",
|
||||||
|
"disk_rotation",
|
||||||
|
"disk_linear_velocity",
|
||||||
|
"disk_angular_velocity",
|
||||||
|
"unit_xy_direction_to_target",
|
||||||
|
"xy_distance_to_target",
|
||||||
|
}
|
||||||
|
|
@ -31,7 +31,7 @@ class EnvConfig:
|
||||||
|
|
||||||
task: Task = Task.DIRECTED_LOCOMOTION
|
task: Task = Task.DIRECTED_LOCOMOTION
|
||||||
|
|
||||||
simulation_time: float = 5.0
|
simulation_time: float = 500.0
|
||||||
num_physics_steps_per_control_step: int = 10
|
num_physics_steps_per_control_step: int = 10
|
||||||
time_scale: int = 2
|
time_scale: int = 2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,12 @@ _ALLOWED_OBS_KEYS = {
|
||||||
}
|
}
|
||||||
# TODO: clip scaled reward?
|
# TODO: clip scaled reward?
|
||||||
|
|
||||||
|
@jax.jit
|
||||||
|
def _get_xy_distance_to_target(obs_dict: dict) -> jnp.ndarray:
|
||||||
|
"""Extract xy_distance_to_target for all environments."""
|
||||||
|
# obs_dict is a dict of arrays with leading batch dimension (num_envs, ...)
|
||||||
|
return obs_dict["xy_distance_to_target"].squeeze(-1) # shape: (num_envs,)
|
||||||
|
|
||||||
@jax.jit
|
@jax.jit
|
||||||
def _clip_action(action: jnp.ndarray, low: jnp.ndarray, high: jnp.ndarray) -> jnp.ndarray:
|
def _clip_action(action: jnp.ndarray, low: jnp.ndarray, high: jnp.ndarray) -> jnp.ndarray:
|
||||||
return jnp.clip(action, low, high)
|
return jnp.clip(action, low, high)
|
||||||
|
|
@ -143,7 +149,7 @@ def _step_env_wrapped(episode_stats, env_state, action, env_step_fn):
|
||||||
next_env_state = env_step_fn(env_state, action)
|
next_env_state = env_step_fn(env_state, action)
|
||||||
|
|
||||||
reward = next_env_state.reward
|
reward = next_env_state.reward
|
||||||
reward *= 100
|
reward *= 1000
|
||||||
terminated = next_env_state.terminated
|
terminated = next_env_state.terminated
|
||||||
truncated = next_env_state.truncated
|
truncated = next_env_state.truncated
|
||||||
done = terminated | truncated
|
done = terminated | truncated
|
||||||
|
|
@ -396,7 +402,9 @@ class PPOTrainer:
|
||||||
start_time,
|
start_time,
|
||||||
iteration_time_start,
|
iteration_time_start,
|
||||||
training_measurements,
|
training_measurements,
|
||||||
storage
|
storage,
|
||||||
|
next_obs,
|
||||||
|
xy_distance
|
||||||
):
|
):
|
||||||
data = jax.device_get({
|
data = jax.device_get({
|
||||||
'rewards': storage.rewards[0], # (num_steps,)
|
'rewards': storage.rewards[0], # (num_steps,)
|
||||||
|
|
@ -425,6 +433,9 @@ class PPOTrainer:
|
||||||
|
|
||||||
"rollout/env0/action_mean": float(np.mean(data['actions'])),
|
"rollout/env0/action_mean": float(np.mean(data['actions'])),
|
||||||
"rollout/env0/raw_action_mean": float(np.mean(data['raw_actions'])),
|
"rollout/env0/raw_action_mean": float(np.mean(data['raw_actions'])),
|
||||||
|
|
||||||
|
"charts/env0_xy_distance_to_target": float(xy_distance[0]),
|
||||||
|
"charts/env1_xy_distance_to_target": float(xy_distance[1]),
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics = {
|
metrics = {
|
||||||
|
|
@ -568,6 +579,8 @@ class PPOTrainer:
|
||||||
env_state, next_obs, next_done, iteration=iteration
|
env_state, next_obs, next_done, iteration=iteration
|
||||||
)
|
)
|
||||||
|
|
||||||
|
xy_distance = _get_xy_distance_to_target(env_state.observations)
|
||||||
|
|
||||||
global_step += self.args.num_steps * self.args.num_envs
|
global_step += self.args.num_steps * self.args.num_envs
|
||||||
self._log(
|
self._log(
|
||||||
global_step,
|
global_step,
|
||||||
|
|
@ -575,7 +588,9 @@ class PPOTrainer:
|
||||||
start_time,
|
start_time,
|
||||||
iteration_time_start,
|
iteration_time_start,
|
||||||
training_measurements,
|
training_measurements,
|
||||||
storage
|
storage,
|
||||||
|
next_obs,
|
||||||
|
xy_distance
|
||||||
)
|
)
|
||||||
|
|
||||||
sps = int(global_step / (time.time() - start_time))
|
sps = int(global_step / (time.time() - start_time))
|
||||||
|
|
|
||||||
Reference in a new issue