@@ -20,68 +20,27 @@ class FrankaSim(RobotSim):
2020 def __init__ (self , args ):
2121 super ().__init__ (args )
2222
23- def setup_robot_dof_prop (
24- self , gym = None , envs = None , robot_asset = None , robot_handles = None
25- ):
26- from isaacgym import gymapi
27-
28- gym = self .gym if gym is None else gym
29- envs = self .envs if envs is None else envs
30- robot_asset = self .robot_asset if robot_asset is None else robot_asset
31- robot_handles = self .robot_handles if robot_handles is None else robot_handles
32-
33- # configure robot dofs
34- robot_dof_props = gym .get_asset_dof_properties (robot_asset )
35- robot_lower_limits = robot_dof_props ["lower" ]
36- robot_upper_limits = robot_dof_props ["upper" ]
37- robot_ranges = robot_upper_limits - robot_lower_limits
38- robot_mids = 0.3 * (robot_upper_limits + robot_lower_limits )
39-
40- # default dof states and position targets
41- robot_num_dofs = gym .get_asset_dof_count (robot_asset )
42- default_dof_pos = np .zeros (robot_num_dofs , dtype = np .float32 )
43- default_dof_pos = robot_mids
44-
45- default_dof_state = np .zeros (robot_num_dofs , gymapi .DofState .dtype )
46- default_dof_state ["pos" ] = default_dof_pos
47-
48- # # send to torch
49- # default_dof_pos_tensor = to_torch(default_dof_pos, device=device)
50-
51- for env , robot in zip (envs , robot_handles ):
52- # set dof properties
53- gym .set_actor_dof_properties (env , robot , robot_dof_props )
54-
55- # set initial dof states
56- gym .set_actor_dof_states (env , robot , default_dof_state , gymapi .STATE_ALL )
57-
58- # set initial position targets
59- gym .set_actor_dof_position_targets (env , robot , default_dof_pos )
60-
61- def update_robot (self , traj , attractor_handles , axes_geom , sphere_geom , index ):
62- # TODO: the traj is a little weird, need to be fixed
23+ def update_robot (self , traj , attractor_handles , axes_geom , sphere_geom , index , verbose = True ):
6324 from isaacgym import gymutil
6425
65- self .gym .clear_lines (self .viewer )
6626 for i in range (self .num_envs ):
6727 # Update attractor target from current franka state
68- attractor_properties = self .gym .get_attractor_properties (
69- self .envs [i ], attractor_handles [i ]
70- )
28+ attractor_properties = self .gym .get_attractor_properties (self .envs [i ], attractor_handles [i ])
7129 pose = attractor_properties .target
7230 # pose.p: (x, y, z), pose.r: (w, x, y, z)
73- pose .p .x = traj [index , 0 ] * 0.5
74- pose .p .y = traj [index , 2 ] * 0.5
75- pose .p .z = traj [index , 1 ] * 0.5
31+ pose .p .x = traj [index , 0 ]
32+ pose .p .y = traj [index , 1 ]
33+ pose .p .z = traj [index , 2 ]
7634 pose .r .w = traj [index , 6 ]
7735 pose .r .x = traj [index , 3 ]
78- pose .r .y = traj [index , 5 ]
79- pose .r .z = traj [index , 4 ]
36+ pose .r .y = traj [index , 4 ]
37+ pose .r .z = traj [index , 5 ]
8038 self .gym .set_attractor_target (self .envs [i ], attractor_handles [i ], pose )
8139
82- # Draw axes and sphere at attractor location
83- gymutil .draw_lines (axes_geom , self .gym , self .viewer , self .envs [i ], pose )
84- gymutil .draw_lines (sphere_geom , self .gym , self .viewer , self .envs [i ], pose )
40+ if verbose :
41+ # Draw axes and sphere at attractor location
42+ gymutil .draw_lines (axes_geom , self .gym , self .viewer , self .envs [i ], pose )
43+ gymutil .draw_lines (sphere_geom , self .gym , self .viewer , self .envs [i ], pose )
8544
8645 def run_traj (self , traj , attracted_joint = "panda_hand" ):
8746 self .run_traj_multi_joints ([traj ], [attracted_joint ])
0 commit comments