Open loikun opened 1 year ago
And below a possible solution to the periodic plots (class Graph()) that were always blank during training. The issue was the redundant ax = plt.subplot(2, 2, i+1) inside the loop that set the subfigures titles. I believe it creates a new subplot that acts as an overlay and hides the initial subplot.
Besides, it seems needed to force the color of the plots for the outcome graph. Otherwise colors in the legend are not consistant along time.
Best.
diff --git a/src/turtlebot3_drl/turtlebot3_drl/common/graph.py b/src/turtlebot3_drl/turtlebot3_drl/common/graph.py
index f1e6db5..748328b 100644
--- a/src/turtlebot3_drl/turtlebot3_drl/common/graph.py
+++ b/src/turtlebot3_drl/turtlebot3_drl/common/graph.py
@@ -13,6 +13,7 @@ class Graph():
self.session_dir = ""
self.bin_size_average_reward = 3
self.legend_labels = ['Unknown', 'Success', 'Collision Wall', 'Collision Dynamic', 'Timeout', 'Tumble']
+ self.legend_colors = ['b', 'g', 'r', 'c', 'm', 'y']
self.outcome_histories = []
@@ -29,7 +30,6 @@ class Graph():
titles = ['outcomes', 'avg critic loss over episode', 'avg actor loss over episode', 'avg reward over 10 episodes']
for i in range(4):
ax = self.ax[int(i/2)][int(i%2!=0)]
- ax = plt.subplot(2, 2, i+1)
ax.set_title(titles[i])
self.legend_set = False
@@ -64,7 +64,7 @@ class Graph():
if len(self.data_outcome_history) > 0:
i = 0
for outcome_history in self.outcome_histories:
- self.ax[0][0].plot(xaxis, outcome_history, label=self.legend_labels[i])
+ self.ax[0][0].plot(xaxis, outcome_history, color=self.legend_colors[i], label=self.legend_labels[i])
i += 1
if not self.legend_set:
self.ax[0][0].legend()
To mention that commit 6f80041 introduces import errors when running the native code. A simple patch that corrects the issue is:
Thanks, a small oversight fixed now with 0a71463
And below a possible solution to the periodic plots (class Graph()) that were always blank during training. The issue was the redundant ax = plt.subplot(2, 2, i+1) inside the loop that set the subfigures titles. I believe it creates a new subplot that acts as an overlay and hides the initial subplot.
Besides, it seems needed to force the color of the plots for the outcome graph. Otherwise colors in the legend are not consistant along time.
Best.
The graph is only updated periodically to save time by not having to redraw the plot after every episode. You should see the first results appear after the first 100 episodes which is the case for me. The line ax = plt.subplot(2, 2, i+1)
does seem to be redundant so I removed it in 80f58de. Thanks!
(Even after 100 episodes, plots were blank with default python package on my computer if ax = plt.subplot(2, 2, i+1); is kept).
Interesting. The plots are also still not as stable as I would want them to be, any suggestions are welcome.
To clear any misunderstanding : the plots are running well on my intel and my arm ubuntu, when the redundant ax = plt.subplot(2, 2, i+1)
has been removed. Also the visualization of the neural network activity is running so far. Good work and thanks again.
Interesting. The plots are also still not as stable as I would want them to be, any suggestions are welcome.
I found it frustrating to encounter a entirely blank plot initially (of course no data, but annoyingly no axes), unresponsive plot windows, and seldomly blank windows after plot updates. This small modification appears to enhance the stability of the plots: improved_graph_stability.patch
Furthermore, I advise against updating the native rosdep from ROS2 Foxy's official installation guide to rosdep2. It's unnecessary and often disrupts systems that are functioning properly with rosdep. I recommend removing the following step from the installation procedure:
Next, install the correct rosdep tool
sudo apt install python3-rosdep2
Best regards
To mention that commit 6f80041 introduces import errors when running the native code. A simple patch that corrects the issue is:
Best regards.