-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_rods_move.py
More file actions
27 lines (22 loc) · 920 Bytes
/
debug_rods_move.py
File metadata and controls
27 lines (22 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# debug_rods_move.py
import numpy as np
from ai_agents.v2.gym.full_information_protagonist_antagonist_gym import FoosballEnv
import mujoco
env = FoosballEnv(antagonist_model=None, verbose_mode=False)
obs, info = env.reset()
for t in range(20):
# Big positive push on one linear joint, others zero
action = np.zeros(env.protagonist_action_size, dtype=np.float32)
action[0] = 20.0 # first rod linear joint
obs, reward, terminated, truncated, info = env.step(action)
# Print that rod’s qpos and qvel
model = env.model
data = env.data
jname = "y_goal_linear" # or whatever the first joint actually is in your XML
j_id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_JOINT, jname)
qpos_adr = model.jnt_qposadr[j_id]
qvel_adr = model.jnt_dofadr[j_id]
print(
f"t={t} qpos={float(data.qpos[qpos_adr]):.4f}, "
f"qvel={float(data.qvel[qvel_adr]):.4f}"
)