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

Fixed tmp random initial index selection and non valid stat selection #319

Open
wants to merge 1 commit into
base: noetic-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion behavior_metrics/pilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,10 @@ def calculate_metrics(self, experiment_metrics):
if hasattr(self.brains.active_brain, 'inference_times'):
self.brains.active_brain.inference_times = self.brains.active_brain.inference_times[10:-10]
mean_inference_time = sum(self.brains.active_brain.inference_times) / len(self.brains.active_brain.inference_times)
frame_rate = self.sensors.get_camera('camera_0').total_frames / experiment_metrics['experiment_total_simulated_time']
try:
frame_rate = self.sensors.get_camera('camera_0').total_frames / experiment_metrics['experiment_total_simulated_time']
except:
frame_rate = 0
gpu_inference = self.brains.active_brain.gpu_inference
real_time_update_rate = self.real_time_update_rate
first_image = self.brains.active_brain.first_image
Expand Down
15 changes: 11 additions & 4 deletions behavior_metrics/utils/tmp_world_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,20 @@ def tmp_world_generator(current_world, stats_perfect_lap, real_time_update_rate,
root = tree.getroot()

perfect_lap_checkpoints, circuit_diameter = metrics.read_perfect_lap_rosbag(stats_perfect_lap)

check_point_offset = 5
if randomize:
random_index = random.randint(0, int(len(perfect_lap_checkpoints)))
random_point = perfect_lap_checkpoints[random_index]
random_index = random.randint(0, int(len(perfect_lap_checkpoints) - check_point_offset - 1))

try:
random_point = perfect_lap_checkpoints[random_index]
except Exception as exc:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this exception ever going to be raised?

random_index = 2
random_point = perfect_lap_checkpoints[random_index]



p1 = perfect_lap_checkpoints[random_index]
p2 = perfect_lap_checkpoints[random_index + 5]
p2 = perfect_lap_checkpoints[random_index + check_point_offset]
delta_y = p2['pose.pose.position.y'] - p1['pose.pose.position.y']
delta_x = p2['pose.pose.position.x'] - p1['pose.pose.position.x']
result = math.atan2(delta_y, delta_x)
Expand Down