Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation sim2sim, sim2real #42

Draft
wants to merge 89 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
69105aa
Modified g1 urdf with rubber hand and correct collision mesh; Modifie…
YoontaeCho Feb 2, 2025
84a01f0
support policy learning with rospy
junhyekh Feb 4, 2025
0a0f467
sav
yjinzero Feb 11, 2025
52a50f4
arm ik ctrl
yycho0108 Feb 12, 2025
d6a314c
make things work
yjinzero Feb 13, 2025
701ca6b
abs-ik, test ik
yycho0108 Feb 13, 2025
06529d5
lower kp
yjinzero Feb 13, 2025
4b8a920
state pub
yjinzero Feb 13, 2025
55cf041
rm _node
yjinzero Feb 13, 2025
9ace3b0
debug qlen
yjinzero Feb 13, 2025
a81f4fc
why do we have 35 joints?
yjinzero Feb 13, 2025
fa299cc
reorg a bit
yjinzero Feb 13, 2025
86779e8
state pub
yjinzero Feb 13, 2025
0fc5cc4
mystery
yjinzero Feb 13, 2025
d32a4cd
add note for arbitrary scaling...
yjinzero Feb 13, 2025
d7745c9
wip
yycho0108 Feb 12, 2025
05ed68c
eetrack
yjinzero Feb 14, 2025
2743714
working on observations
yjinzero Feb 14, 2025
791c467
formatting a bunch
yjinzero Feb 14, 2025
5af22cb
axa conversion
yycho0108 Feb 14, 2025
9bfd9ae
proj-com
yjinzero Feb 14, 2025
aba4d60
index mapping et al.
yjinzero Feb 14, 2025
fa6f1bc
update
yycho0108 Feb 14, 2025
22abdda
added com computing functions
HYUNHONOH98 Feb 14, 2025
4ba4f84
populate dummy values
yjinzero Feb 14, 2025
6e44134
cleanup a bit
yjinzero Feb 14, 2025
46fad1f
make things work
yycho0108 Feb 14, 2025
d56e03e
Add eetrack class for observation
minjoonkim01 Feb 14, 2025
a18a3ea
disable eetrack/ctrl
yjinzero Feb 14, 2025
3c333f8
change policy path
yjinzero Feb 14, 2025
f09ab90
act integration, etc
yjinzero Feb 14, 2025
5fc670e
technically working...
yjinzero Feb 14, 2025
12febca
fix imap, etc.
yycho0108 Feb 14, 2025
e825ee0
map test
yjinzero Feb 15, 2025
187ee32
move xyzw
yjinzero Feb 15, 2025
30d5e03
add ikctrl i guess
yjinzero Feb 15, 2025
6e1d48a
add cfg
yjinzero Feb 15, 2025
9bff4e2
add cfg
yjinzero Feb 15, 2025
1a92a43
fix cfg
yjinzero Feb 15, 2025
8a2fce5
add qmot
yjinzero Feb 15, 2025
2e7355a
add pin_from_lab
yjinzero Feb 15, 2025
016fd44
temoprarily copy noramlize()
yjinzero Feb 15, 2025
a7bdde6
working...integration...??
yjinzero Feb 15, 2025
f96356c
eetrack integration
yjinzero Feb 15, 2025
412e1c8
fix
yjinzero Feb 15, 2025
2376b94
fixing et al.
yjinzero Feb 15, 2025
379d393
fake world-tf pub + @
yycho0108 Feb 16, 2025
9408613
init vel with zeros
yjinzero Feb 16, 2025
6e8cb33
q0
yjinzero Feb 16, 2025
3a31f44
main
yjinzero Feb 16, 2025
2417e6a
pinfrommot
yjinzero Feb 16, 2025
e040d2c
load motor joint
yjinzero Feb 16, 2025
2c26a25
dtype designation
yjinzero Feb 16, 2025
e19e43f
dtype designation
yjinzero Feb 16, 2025
5523771
fix typo
yjinzero Feb 16, 2025
da645b8
map to floats
yjinzero Feb 16, 2025
4f75102
apply correct transforms
yycho0108 Feb 16, 2025
04ce90f
vec3->list
yycho0108 Feb 16, 2025
ae0300e
vec3->list
yycho0108 Feb 16, 2025
d9a14fd
npmap
yycho0108 Feb 16, 2025
3ff1403
translation.z
yycho0108 Feb 16, 2025
4427a4c
dtype -> 32
yycho0108 Feb 16, 2025
ff972e1
concat typo
yycho0108 Feb 16, 2025
b15754f
quat_from_angle_axis mapping
yycho0108 Feb 16, 2025
636dce9
float->array
yycho0108 Feb 16, 2025
d613178
world-frame hands command
yycho0108 Feb 16, 2025
c77bd33
comment out validation
yycho0108 Feb 16, 2025
3f1ad05
fix...
yjinzero Feb 16, 2025
3d4707d
debug act-dof map (seems correct)
yycho0108 Feb 16, 2025
8b2e6d1
add navigation yaml, py file
HYUNHONOH98 Feb 17, 2025
37926bf
disable clip
yycho0108 Feb 17, 2025
461a2da
edit action space
HYUNHONOH98 Feb 17, 2025
a752872
Merge branch 'eetrack' of github.com:YoontaeCho/unitree_rl_gym into n…
HYUNHONOH98 Feb 17, 2025
828a73e
fix
yjinzero Feb 17, 2025
22559fe
Merge branch 'eetrack' of github.com:YoontaeCho/unitree_rl_gym into n…
HYUNHONOH98 Feb 17, 2025
e49bc34
sim2sim implemented
HYUNHONOH98 Feb 17, 2025
a2a5586
localization
junhyekh Feb 18, 2025
e95d062
remove debug code
HYUNHONOH98 Feb 18, 2025
0eb4927
Merge branch 'localization' of github.com:YoontaeCho/unitree_rl_gym i…
HYUNHONOH98 Feb 18, 2025
daee040
pelvis pub
junhyekh Feb 18, 2025
7fb210f
Implemented first version of sim2real pipeline for step command
junhyekh Feb 19, 2025
a0e4825
change policy_path to step-policy
junhyekh Feb 19, 2025
bd34f59
polciy work but not work
junhyekh Feb 19, 2025
68656d7
need debug
junhyekh Feb 20, 2025
ef6e47d
wtf
junhyekh Feb 20, 2025
6bfb0a9
Merge branch 'localization' of github.com:YoontaeCho/unitree_rl_gym i…
HYUNHONOH98 Feb 20, 2025
209fdce
add navigation command
HYUNHONOH98 Feb 21, 2025
9134416
update mujoco sim2sim - heading direction command added
HYUNHONOH98 Feb 21, 2025
1d5830f
debugging on real robot
HYUNHONOH98 Feb 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions MUJOCO_LOG.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Sat Jan 25 16:14:06 2025
WARNING: Nan, Inf or huge value in QACC at DOF 0. The simulation is unstable. Time = 0.1650.

Sat Jan 25 16:23:57 2025
WARNING: Nan, Inf or huge value in QACC at DOF 18. The simulation is unstable. Time = 0.1150.

52 changes: 40 additions & 12 deletions deploy/deploy_mujoco/configs/g1.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,54 @@
#
policy_path: "{LEGGED_GYM_ROOT_DIR}/deploy/pre_train/g1/motion.pt"
xml_path: "{LEGGED_GYM_ROOT_DIR}/resources/robots/g1_description/scene.xml"
# policy_path: "{LEGGED_GYM_ROOT_DIR}/deploy/pre_train/g1/motion.pt"
# policy_path: "{LEGGED_GYM_ROOT_DIR}/logs/g1/walk_with_dr_test_v21/exported/policy.pt"
policy_path: "{LEGGED_GYM_ROOT_DIR}/logs/g1/walk_with_dr_test_v22/exported/policy.pt"
# xml_path: "{LEGGED_GYM_ROOT_DIR}/resources/robots/g1_description/scene.xml"
xml_path: "{LEGGED_GYM_ROOT_DIR}/resources/robots/g1_description/g1_29dof_rev_1_0.xml"

# Total simulation time
simulation_duration: 60.0
# simulation_duration: 5.
# Simulation time step
simulation_dt: 0.002
# Controller update frequency (meets the requirement of simulation_dt * controll_decimation=0.02; 50Hz)
control_decimation: 10

kps: [100, 100, 100, 150, 40, 40, 100, 100, 100, 150, 40, 40]
kds: [2, 2, 2, 4, 2, 2, 2, 2, 2, 4, 2, 2]
# kps: [100, 100, 100, 150, 40, 40, 100, 100, 100, 150, 40, 40]
kps: [
100, 100, 100, 150, 40, 40, 100, 100, 100, 150, 40, 40,
150, 150, 150,
100, 100, 50, 50, 20, 20, 20,
100, 100, 50, 50, 20, 20, 20
]
kds: [
2, 2, 2, 4, 2, 2, 2, 2, 2, 4, 2, 2,
3, 3, 3,
2, 2, 2, 2, 1, 1, 1,
2, 2, 2, 2, 1, 1, 1
]

default_angles: [-0.1, 0.0, 0.0, 0.3, -0.2, 0.0,
-0.1, 0.0, 0.0, 0.3, -0.2, 0.0]
default_angles: [
-0.2, 0.0, 0.0, 0.42, -0.23, 0.0,
-0.2, 0.0, 0.0, 0.42, -0.23, 0.0,
0., 0., 0.,
0.35, 0.16, 0., 0.87, 0., 0., 0.,
0.35, -0.16, 0., 0.87, 0., 0., 0.,
]

ang_vel_scale: 0.25
# ang_vel_scale: 0.25
ang_vel_scale: 1.0
dof_pos_scale: 1.0
dof_vel_scale: 0.05
action_scale: 0.25
cmd_scale: [2.0, 2.0, 0.25]
num_actions: 12
num_obs: 47
# dof_vel_scale: 0.05
dof_vel_scale: 1.0
# action_scale: 0.25
# action_scale: 1.0
action_scale: 0.5
# cmd_scale: [2.0, 2.0, 0.25]
cmd_scale: [1.0, 1.0, 1.0]
# cmd_scale: [0., 0., 0.]
# num_actions: 12
num_actions: 29
# num_obs: 47
num_obs: 96

cmd_init: [0.5, 0, 0]
120 changes: 120 additions & 0 deletions deploy/deploy_mujoco/configs/g1_nav.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#
# policy_path: "{LEGGED_GYM_ROOT_DIR}/deploy/pre_train/g1/motion.pt"
# policy_path: "{LEGGED_GYM_ROOT_DIR}/logs/g1/walk_with_dr_test_v21/exported/policy.pt"
policy_path: "{LEGGED_GYM_ROOT_DIR}/policies/navigation_less_obs/policy.pt"
# xml_path: "{LEGGED_GYM_ROOT_DIR}/resources/robots/g1_description/scene.xml"
xml_path: "{LEGGED_GYM_ROOT_DIR}/resources/robots/g1_description/g1_29dof_rev_1_0.xml"


lab_joint: [
'left_hip_pitch_joint',
'right_hip_pitch_joint',
'waist_yaw_joint',
'left_hip_roll_joint',
'right_hip_roll_joint',
'waist_roll_joint',
'left_hip_yaw_joint',
'right_hip_yaw_joint',
'waist_pitch_joint',
'left_knee_joint',
'right_knee_joint',
'left_shoulder_pitch_joint',
'right_shoulder_pitch_joint',
'left_ankle_pitch_joint',
'right_ankle_pitch_joint',
'left_shoulder_roll_joint',
'right_shoulder_roll_joint',
'left_ankle_roll_joint',
'right_ankle_roll_joint',
'left_shoulder_yaw_joint',
'right_shoulder_yaw_joint',
'left_elbow_joint',
'right_elbow_joint',
'left_wrist_roll_joint',
'right_wrist_roll_joint',
'left_wrist_pitch_joint',
'right_wrist_pitch_joint',
'left_wrist_yaw_joint',
'right_wrist_yaw_joint'
]

motor_joint: [
'left_hip_pitch_joint',
'left_hip_roll_joint',
'left_hip_yaw_joint',
'left_knee_joint',
'left_ankle_pitch_joint',
'left_ankle_roll_joint',
'right_hip_pitch_joint',
'right_hip_roll_joint',
'right_hip_yaw_joint',
'right_knee_joint',
'right_ankle_pitch_joint',
'right_ankle_roll_joint',
'waist_yaw_joint',
'waist_roll_joint',
'waist_pitch_joint',
'left_shoulder_pitch_joint',
'left_shoulder_roll_joint',
'left_shoulder_yaw_joint',
'left_elbow_joint',
'left_wrist_roll_joint',
'left_wrist_pitch_joint',
'left_wrist_yaw_joint',
'right_shoulder_pitch_joint',
'right_shoulder_roll_joint',
'right_shoulder_yaw_joint',
'right_elbow_joint',
'right_wrist_roll_joint',
'right_wrist_pitch_joint',
'right_wrist_yaw_joint'
]

# Total simulation time
simulation_duration: 60.0
# simulation_duration: 5.
# Simulation time step
simulation_dt: 0.002
# Controller update frequency (meets the requirement of simulation_dt * controll_decimation=0.02; 50Hz)
control_decimation: 10

# kps: [100, 100, 100, 150, 40, 40, 100, 100, 100, 150, 40, 40]
kps: [
100, 100, 100, 150, 40, 40, 100, 100, 100, 150, 40, 40,
150, 150, 150,
100, 100, 50, 50, 20, 20, 20,
100, 100, 50, 50, 20, 20, 20
]
kds: [
2, 2, 2, 4, 2, 2, 2, 2, 2, 4, 2, 2,
3, 3, 3,
2, 2, 2, 2, 1, 1, 1,
2, 2, 2, 2, 1, 1, 1
]

default_angles: [
-0.2, 0.0, 0.0, 0.42, -0.23, 0.0,
-0.2, 0.0, 0.0, 0.42, -0.23, 0.0,
0., 0., 0.,
0.35, 0.16, 0., 0.87, 0., 0., 0.,
0.35, -0.16, 0., 0.87, 0., 0., 0.,
]

# ang_vel_scale: 0.25
ang_vel_scale: 1.0
dof_pos_scale: 1.0
# dof_vel_scale: 0.05
dof_vel_scale: 1.0
# action_scale: 0.25
# action_scale: 1.0
action_scale: 0.4
# cmd_scale: [2.0, 2.0, 0.25]
cmd_scale: [1.0, 1.0, 1.0, 1.0]
# cmd_scale: [0., 0., 0.]
# num_actions: 12
num_actions: 29
# num_obs: 47
# num_obs: 96
num_obs: 97

cmd_init: [3, 0, 0, 0]
101 changes: 100 additions & 1 deletion deploy/deploy_mujoco/deploy_mujoco.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,81 @@ def pd_control(target_q, q, kp, target_dq, dq, kd):

if __name__ == "__main__":
# get config file name from command line
isaaclab_joint_order = [
'left_hip_pitch_joint',
'right_hip_pitch_joint',
'waist_yaw_joint',
'left_hip_roll_joint',
'right_hip_roll_joint',
'waist_roll_joint',
'left_hip_yaw_joint',
'right_hip_yaw_joint',
'waist_pitch_joint',
'left_knee_joint',
'right_knee_joint',
'left_shoulder_pitch_joint',
'right_shoulder_pitch_joint',
'left_ankle_pitch_joint',
'right_ankle_pitch_joint',
'left_shoulder_roll_joint',
'right_shoulder_roll_joint',
'left_ankle_roll_joint',
'right_ankle_roll_joint',
'left_shoulder_yaw_joint',
'right_shoulder_yaw_joint',
'left_elbow_joint',
'right_elbow_joint',
'left_wrist_roll_joint',
'right_wrist_roll_joint',
'left_wrist_pitch_joint',
'right_wrist_pitch_joint',
'left_wrist_yaw_joint',
'right_wrist_yaw_joint'
]

raw_joint_order = [
'left_hip_pitch_joint',
'left_hip_roll_joint',
'left_hip_yaw_joint',
'left_knee_joint',
'left_ankle_pitch_joint',
'left_ankle_roll_joint',
'right_hip_pitch_joint',
'right_hip_roll_joint',
'right_hip_yaw_joint',
'right_knee_joint',
'right_ankle_pitch_joint',
'right_ankle_roll_joint',
'waist_yaw_joint',
'waist_roll_joint',
'waist_pitch_joint',
'left_shoulder_pitch_joint',
'left_shoulder_roll_joint',
'left_shoulder_yaw_joint',
'left_elbow_joint',
'left_wrist_roll_joint',
'left_wrist_pitch_joint',
'left_wrist_yaw_joint',
'right_shoulder_pitch_joint',
'right_shoulder_roll_joint',
'right_shoulder_yaw_joint',
'right_elbow_joint',
'right_wrist_roll_joint',
'right_wrist_pitch_joint',
'right_wrist_yaw_joint'
]

# Create a mapping tensor
# mapping_tensor = torch.zeros((len(sim_b_joints), len(sim_a_joints)), device=env.device)
mapping_tensor = torch.zeros((len(raw_joint_order), len(isaaclab_joint_order)))

# Fill the mapping tensor
for b_idx, b_joint in enumerate(raw_joint_order):
if b_joint in isaaclab_joint_order:
a_idx = isaaclab_joint_order.index(b_joint)
# mapping_tensor[b_idx, a_idx] = 1.0
mapping_tensor[a_idx, b_idx] = 1.0

import argparse

parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -81,6 +156,10 @@ def pd_control(target_q, q, kp, target_dq, dq, kd):
start = time.time()
while viewer.is_running() and time.time() - start < simulation_duration:
step_start = time.time()
from icecream import ic
# ic(
# target_dof_pos, d.qpos[7:], kps, np.zeros_like(kds), d.qvel[6:], kds
# )
tau = pd_control(target_dof_pos, d.qpos[7:], kps, np.zeros_like(kds), d.qvel[6:], kds)
d.ctrl[:] = tau
# mj_step can be replaced with code that also evaluates
Expand Down Expand Up @@ -114,12 +193,32 @@ def pd_control(target_q, q, kp, target_dq, dq, kd):
obs[9 : 9 + num_actions] = qj
obs[9 + num_actions : 9 + 2 * num_actions] = dqj
obs[9 + 2 * num_actions : 9 + 3 * num_actions] = action
obs[9 + 3 * num_actions : 9 + 3 * num_actions + 2] = np.array([sin_phase, cos_phase])
# obs[9 + 3 * num_actions : 9 + 3 * num_actions + 2] = np.array([sin_phase, cos_phase])
obs_tensor = torch.from_numpy(obs).unsqueeze(0)
obs_tensor[..., 9:38] = obs_tensor[..., 9:38] @ mapping_tensor.transpose(0, 1)
obs_tensor[..., 38:67] = obs_tensor[..., 38:67] @ mapping_tensor.transpose(0, 1)
obs_tensor[..., 67:96] = obs_tensor[..., 67:96] @ mapping_tensor.transpose(0, 1)
# from icecream import ic
# ic(

# obs[..., :9],
# obs[..., 9:38],
# obs[..., 38:67],
# obs[..., 67:96],
# )
# policy inference
action = policy(obs_tensor).detach().numpy().squeeze()
# reordered_actions = action @ mapping_tensor.detach().cpu().numpy()
action = action @ mapping_tensor.detach().cpu().numpy()
# ic(
# action
# )
# action = 0.

# transform action to target_dof_pos
# target_dof_pos = action * action_scale + default_angles
target_dof_pos = action * action_scale + default_angles
# raise NotImplementedError

# Pick up changes to the physics state, apply perturbations, update options from GUI.
viewer.sync()
Expand Down
Loading