Skip to content

Commit

Permalink
fixed error with very small episode length
Browse files Browse the repository at this point in the history
  • Loading branch information
ReykCS committed Feb 21, 2023
1 parent c092b8a commit 041bacc
Show file tree
Hide file tree
Showing 3 changed files with 241 additions and 4 deletions.
2 changes: 1 addition & 1 deletion create_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def plot_result_from_declaration(dataset, result_declaration):

ResultPlotter.countplot_for_result(
dataset,
differentiate=result_declaration["hue"],
differentiate=result_declaration["differentiate"],
title=result_declaration["title"],
save_name=result_declaration["save_name"],
plot_args=result_declaration.get("plot_args", {}),
Expand Down
6 changes: 3 additions & 3 deletions get_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, dir):
while True:
current_episode = data[data["episode"] == i]

if len(current_episode) <= 0:
if len(current_episode) <= 5:
break

episode_data[i] = self.analyze_episode(current_episode, i)
Expand All @@ -87,8 +87,6 @@ def __init__(self, dir):
data = pd.DataFrame(episode_data).transpose().set_index("episode")
data.to_csv(os.path.join(dir, "metrics.csv"))

pass

def analyze_episode(self, episode, index):
positions, velocities = [], []

Expand All @@ -115,6 +113,8 @@ def analyze_episode(self, episode, index):
start_position = self.get_mean_position(episode, "start")
goal_position = self.get_mean_position(episode, "goal")

print("PATH LENGTH", path_length, path_length_per_step)

return {
"curvature": Metrics.round_values(curvature),
"normalized_curvature": Metrics.round_values(normalized_curvature),
Expand Down
237 changes: 237 additions & 0 deletions plot_declarations/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
# Wether you want to show or save the plots
show_plots: false
# Name of the directory in ./path
save_location: eval_iros_2023

# List of all datasets that should be compared
# Name of the directory in ./data
datasets: ["test"]

# Wether you want to plot the result counts
results:
# Should plot?
plot: true
# Title of the plot
title: Results
differentiate: local_planner
# Name of the file the plot should be saved ot
save_name: results
# Additional Plot arguments
plot_args: {} # Optional

# Plot values that are collected in every time step.
# Thus, being arrays for each episode.
# Possible values are:
# - curvature
# - normalized_curvature
# - roughness
# - path_length_values
# - acceleration
# - jerk
# - velocity

# It is possible to plot
# - A line plot to show the course in a single episode
# You can list multiple value to create multiple plots
single_episode_line:
# Name of the coloumn you want to plot
- data_key: curvature # Required
# Number of values that should be skipped to reduce datapoints
step_size: 2 # Optional -> Defaults to 5
# Coloumn for differentiation
differentiate: local_planner # Optional -> Defaults to namespace
# Index of the episode -> If none all episodes are plotted
episode: 1 # Optional -> Defaults to none
title: Curvature
save_name: episode_curvature
plot_args: { xlabel: Time in seconds } # Optional
- data_key: roughness # Required
# Number of values that should be skipped to reduce datapoints
step_size: 2 # Optional -> Defaults to 5
# Coloumn for differentiation
differentiate: local_planner # Optional -> Defaults to namespace
# Index of the episode -> If none all episodes are plotted
episode: 1 # Optional -> Defaults to none
title: Roughness
save_name: episode_roughness
plot_args: { xlabel: Time in seconds } # Optional
- data_key: path_length_values # Required
# Number of values that should be skipped to reduce datapoints
step_size: 2 # Optional -> Defaults to 5
# Coloumn for differentiation
differentiate: local_planner # Optional -> Defaults to namespace
# Index of the episode -> If none all episodes are plotted
episode: 1 # Optional -> Defaults to none
title: Path Length
save_name: episode_path_length_values
plot_args: { xlabel: Time in seconds } # Optional
- data_key: acceleration # Required
# Number of values that should be skipped to reduce datapoints
step_size: 2 # Optional -> Defaults to 5
# Coloumn for differentiation
differentiate: local_planner # Optional -> Defaults to namespace
# Index of the episode -> If none all episodes are plotted
episode: 1 # Optional -> Defaults to none
title: Acceleration
save_name: episode_acceleration
plot_args: { xlabel: Time in seconds } # Optional
- data_key: jerk # Required
# Number of values that should be skipped to reduce datapoints
step_size: 2 # Optional -> Defaults to 5
# Coloumn for differentiation
differentiate: local_planner # Optional -> Defaults to namespace
# Index of the episode -> If none all episodes are plotted
episode: 1 # Optional -> Defaults to none
title: Jerk
save_name: episode_jerk
plot_args: { xlabel: Time in seconds } # Optional
- data_key: velocity # Required
# Number of values that should be skipped to reduce datapoints
step_size: 2 # Optional -> Defaults to 5
# Coloumn for differentiation
differentiate: local_planner # Optional -> Defaults to namespace
# Index of the episode -> If none all episodes are plotted
episode: 1 # Optional -> Defaults to none
title: Velocity
save_name: episode_velocity
plot_args: { xlabel: Time in seconds } # Optional

# - A Distributional plot for a single episode
# You can list multiple value to create multiple plots

single_episode_distribution:
- data_key: curvature
episode: 1
plot_key: "box"
title: Curvature
save_name: dist_episode_curvature
differentiate: local_planner
plot_args: {} # Optional
- data_key: roughness
episode: 1
plot_key: "box"
title: Roughness
save_name: dist_episode_roughness
differentiate: local_planner
plot_args: {} # Optional
- data_key: path_length_values
episode: 1
plot_key: "box"
title: Path Length
save_name: dist_episode_path_length_values
differentiate: local_planner
plot_args: {} # Optional
- data_key: acceleration
episode: 1
plot_key: "box"
title: Acceleration
save_name: dist_episode_acceleration
differentiate: local_planner
plot_args: {} # Optional
- data_key: jerk
episode: 1
plot_key: "box"
title: Jerk
save_name: dist_episode_jerk
differentiate: local_planner
plot_args: {} # Optional
- data_key: velocity
episode: 1
plot_key: "box"
title: Velocity
save_name: dist_episode_velocity
differentiate: local_planner
plot_args: {} # Optional

# - A line plot showing aggregated values for all episodes.
# Like a line plot for the max value of each episode
# aggregated_distribution:
# - data_key: string
# # Function that should be used for aggregation. We offer: max, min, mean
# aggregate: "max" | "min" | "mean" | "sum"
# # Name of the dist plot you want to use. Can be strip, swarm, box, boxen, violin
# plot_key: "swarm" | "violin" | "box" | "boxen" | "strip" # Optional -> Defaults to "swarm"
# title: string
# save_name: string
# plot_args: {} # Optional
# # - A distributional plot for aggregated values for all episodes.
# aggregated_line:
# - data_key: string
# # Function that should be used for aggregation. We offer: max, min, mean
# aggregate: "max" | "min" | "mean" | "sum"
# title: string
# save_name: string
# plot_args: {} # Optional

# ## Plot values that are collected for each episode.
# # Single values for each episode
# # Possible values are:
# # - time_diff
# # - angle_over_length
# # - path_length

# # It is possible to plot
# # - A categorical plot over all episodes to show the values in a line or bar plot
all_episodes_categorical:
- data_key: time_diff
plot_key: "bar"
title: time_diff
save_name: cat_time_diff
differentiate: local_planner
plot_args: {} # Optional
- data_key: angle_over_length
plot_key: "bar"
title: Angle Over Length
save_name: cat_angle_over_length
differentiate: local_planner
plot_args: {} # Optional
- data_key: path_length
plot_key: "bar"
title: Path Length
save_name: cat_path_length
differentiate: local_planner
plot_args: {} # Optional
# - Plot a distribution over all episodes
all_episodes_distribution:
- data_key: time_diff
plot_key: "box"
title: Time
save_name: cat_agg_time_diff
differentiate: local_planner
plot_args: {} # Optional
- data_key: angle_over_length
plot_key: "box"
title: Angle Over Length
save_name: cat_agg_angle_over_length
differentiate: local_planner
plot_args: {} # Optional
- data_key: path_length
plot_key: "box"
title: Path Length
save_name: cat_agg_path_length
differentiate: local_planner
plot_args: {} # Optional

# ## Plot the path the robots took

# # Plot all paths of all episodes for each robot
episode_plots_for_namespaces:
# list of desired results that should be plotted
desired_results: GOAL_REACHED
# Wether or not to add the obstacles from the scenario file to the plot
should_add_obstacles: False # Optional -> Defaults to False
# Wether or not to mark where collisions happened
should_add_collisions: False # Optional -> Defaults to False
differentiate: local_planner
title: Path
save_name: path
# # Plot the best path of each robot
# # Only select the paths that reached the goal and take the path that took the least amount of time
# create_best_plots:
# # Wether or not to add the obstacles from the scenario file to the plot
# should_add_obstacles: False # Optional -> Defaults to False
# # Wether or not to mark where collisions happened
# should_add_collisions: False # Optional -> Defaults to False
# title: Path
# save_name: path
# # ```

0 comments on commit 041bacc

Please sign in to comment.