Skip to content

Commit

Permalink
feature(yzj): add metric save path in team_code
Browse files Browse the repository at this point in the history
  • Loading branch information
jayyoung0802 committed Aug 31, 2024
1 parent 4040054 commit 40ec4b5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 59 deletions.
55 changes: 0 additions & 55 deletions clear.py

This file was deleted.

12 changes: 9 additions & 3 deletions team_code/uniad_b2d_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ def equations(vars):
self._route_planner = RoutePlanner(4.0, 50.0, lat_ref=self.lat_ref, lon_ref=self.lon_ref)
self._route_planner.set_route(self._global_plan, True)
self.initialized = True


self.metric_info = {}

def sensors(self):
sensors =[
Expand Down Expand Up @@ -393,7 +392,9 @@ def run_step(self, input_data, timestamp):
self.pid_metadata['throttle_traj'] = float(throttle_traj)
self.pid_metadata['brake_traj'] = float(brake_traj)
self.pid_metadata['plan'] = out_truck.tolist()
if SAVE_PATH is not None and self.step % 10 == 0:
metric_info = self.get_metric_info()
self.metric_info[self.step] = metric_info
if SAVE_PATH is not None and self.step % 1 == 0:
self.save(tick_data)
self.prev_control = control
return control
Expand All @@ -411,6 +412,11 @@ def save(self, tick_data):
json.dump(self.pid_metadata, outfile, indent=4)
outfile.close()

# metric info
outfile = open(self.save_path / 'metric_info.json', 'w')
json.dump(self.metric_info, outfile, indent=4)
outfile.close()

def destroy(self):
del self.model
torch.cuda.empty_cache()
Expand Down
10 changes: 9 additions & 1 deletion team_code/vad_b2d_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def equations(vars):
self._route_planner = RoutePlanner(4.0, 50.0, lat_ref=self.lat_ref, lon_ref=self.lon_ref)
self._route_planner.set_route(self._global_plan, True)
self.initialized = True
self.metric_info = {}



Expand Down Expand Up @@ -412,7 +413,9 @@ def run_step(self, input_data, timestamp):
self.pid_metadata['command'] = command
self.pid_metadata['all_plan'] = all_out_truck.tolist()

if SAVE_PATH is not None and self.step % 10 == 0:
metric_info = self.get_metric_info()
self.metric_info[self.step] = metric_info
if SAVE_PATH is not None and self.step % 1 == 0:
self.save(tick_data)
self.prev_control = control

Expand All @@ -437,6 +440,11 @@ def save(self, tick_data):
json.dump(self.pid_metadata, outfile, indent=4)
outfile.close()

# metric info
outfile = open(self.save_path / 'metric_info.json', 'w')
json.dump(self.metric_info, outfile, indent=4)
outfile.close()

def destroy(self):
del self.model
torch.cuda.empty_cache()
Expand Down

0 comments on commit 40ec4b5

Please sign in to comment.