@@ -563,13 +563,19 @@ def _load_track_into_sim(self, gate_spec: MjSpec, obstacle_spec: MjSpec):
563
563
frame = self .sim .spec .worldbody .add_frame ()
564
564
n_gates , n_obstacles = len (self .gates ["pos" ]), len (self .obstacles ["pos" ])
565
565
for i in range (n_gates ):
566
- gate = frame .attach_body (gate_spec .find_body ("gate" ), "" , f":{ i } " )
566
+ gate_body = gate_spec .body ("gate" )
567
+ if gate_body is None :
568
+ raise ValueError ("Gate body not found in gate spec" )
569
+ gate = frame .attach_body (gate_body , "" , f":{ i } " )
567
570
gate .pos = self .gates ["pos" ][i ]
568
571
# Convert from scipy order to MuJoCo order
569
572
gate .quat = self .gates ["quat" ][i ][[3 , 0 , 1 , 2 ]]
570
573
gate .mocap = True # Make mocap to modify the position of static bodies during sim
571
574
for i in range (n_obstacles ):
572
- obstacle = frame .attach_body (obstacle_spec .find_body ("obstacle" ), "" , f":{ i } " )
575
+ obstacle_body = obstacle_spec .body ("obstacle" )
576
+ if obstacle_body is None :
577
+ raise ValueError ("Obstacle body not found in obstacle spec" )
578
+ obstacle = frame .attach_body (obstacle_body , "" , f":{ i } " )
573
579
obstacle .pos = self .obstacles ["pos" ][i ]
574
580
obstacle .mocap = True
575
581
self .sim .build (data = False , default_data = False )
0 commit comments