@@ -129,17 +129,22 @@ def __init__(self, vehicle_rank: int):
129129 # returns the lidar data of all vehicles
130130 def observe (self ):
131131 # gets from Vehicle
132-
133- return np .frombuffer (self .fifo_r .read (np .dtype (np .float32 ).itemsize * (n_sensors + lidar_horizontal_resolution + camera_horizontal_resolution )), dtype = np .float32 )
132+ log (f"SUPERVISOR{ simulation_rank } /{ self .vehicle_rank } : we observe" )
133+ obs = np .frombuffer (self .fifo_r .read (np .dtype (np .float32 ).itemsize * (n_sensors + lidar_horizontal_resolution + camera_horizontal_resolution )), dtype = np .float32 )
134+ log (f"SUPERVISOR{ simulation_rank } /{ self .vehicle_rank } : observing { obs = } " )
135+ return obs
136+
134137
135138 # reset the gym environment reset
136139 def reset (self , seed = None ):
140+ log (f"SUPERVISOR{ simulation_rank } /{ self .vehicle_rank } : trying to reset vehicle" )
137141 # this has to be done otherwise thec cars will shiver for a while sometimes when respawning and idk why
138142 if supervisor .getTime () - self .last_reset >= 1e-1 :
143+ log (f"SUPERVISOR{ simulation_rank } /{ self .vehicle_rank } : getting info" )
139144 self .last_reset = supervisor .getTime ()
140145
141146 vehicle = supervisor .getFromDef (f"TT02_{ self .vehicle_rank } " )
142-
147+ log ( f"SUPERVISOR { simulation_rank } / { self . vehicle_rank } : resetting all" )
143148 self .checkpoint_manager .reset (seed )
144149 trans = self .checkpoint_manager .getTranslation ()
145150 rot = self .checkpoint_manager .getRotation ()
@@ -149,8 +154,9 @@ def reset(self, seed=None):
149154 self .checkpoint_manager .update ()
150155
151156 vehicle .resetPhysics ()
157+ log (f"SUPERVISOR{ simulation_rank } /{ self .vehicle_rank } : ok it's cooooooooool" )
152158
153- obs = self . observe ( )
159+ obs = np . zeros ( n_sensors + lidar_horizontal_resolution + camera_horizontal_resolution , dtype = np . float32 )
154160 info = {}
155161 log (f"CLIENT{ simulation_rank } /{ self .vehicle_rank } : reset over" )
156162 return obs , info
@@ -162,15 +168,17 @@ def step(self):
162168
163169 # we should add a beacon sensor pointing upwards to detect the beacon
164170 obs = self .observe ()
171+ log (f"SUPERVISOR{ simulation_rank } /{ self .vehicle_rank } : observed { obs = } " )
165172 sensor_data = obs [:n_sensors ]
166-
173+ log ( f"SUPERVISOR { simulation_rank } / { self . vehicle_rank } : sensor data { sensor_data = } " )
167174 reward = 0
168175 done = np .False_
169176 truncated = np .False_
170177
171178 x , y , z = self .translation_field .getSFVec3f ()
172179 b_past_checkpoint = self .checkpoint_manager .update (x , y )
173180 b_collided , = sensor_data # unpack sensor data
181+ log (f"SUPERVISOR{ simulation_rank } /{ self .vehicle_rank } : be_collided { b_collided = } " )
174182
175183 if b_collided or (z < - 10 ):
176184 #print(f"CLIENT{simulation_rank}/{self.vehicle_rank} : {b_collided=}, {z=}")
@@ -216,7 +224,7 @@ def main():
216224 #Prédiction pour séléctionner une action à partir de l"observation
217225 for e in envs :
218226 obs , reward , done , truncated , info = e .step ()
219- if done :
227+ if done :
220228 obs , info = e .reset ()
221229
222230 log (f"SUPERVISOR{ simulation_rank } /{ e .vehicle_rank } : sending { obs = } " )
@@ -229,6 +237,8 @@ def main():
229237 e .fifo_w .write (truncated .tobytes ())
230238 e .fifo_w .flush ()
231239
240+
241+
232242
233243 for i in range (n_stupid_vehicles ):
234244 tr_field = supervisor .getFromDef (f"TT02_{ n_vehicles + i } " ).getField ("translation" )
0 commit comments