From b43deee742989e256d9a974abd5ee3b72bd05ef9 Mon Sep 17 00:00:00 2001 From: Carlo Cena Date: Fri, 17 Dec 2021 20:13:33 +0100 Subject: [PATCH] Corrected wrong log, equal pos and vel --- shared/Log Analysis.ipynb | 4 +--- .../ros_packages/px4_ros_extended/src_py/test_ddpg_agent.py | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/shared/Log Analysis.ipynb b/shared/Log Analysis.ipynb index de0b6ca..387a790 100644 --- a/shared/Log Analysis.ipynb +++ b/shared/Log Analysis.ipynb @@ -177,8 +177,6 @@ " with open(folder_path + \"/\" + file, \"rb\") as file_pkl:\n", " data = pickle.load(file_pkl)\n", " if len(data[1]) == 2 and np.abs(data[0]['z'][-1]) < 0.15: # Threshold height, otherwise not landed (vz not trained)\n", - " file_list.append(file)\n", - " elif len(data[1]) == 3 and np.abs(data[0]['z'][-1]) < 0.50: # Threshold height, otherwise not landed (vz trained)\n", " file_list.append(file)" ] }, @@ -266,7 +264,7 @@ "outputs": [], "source": [ "ax = velocities.plot(title=\"Velocity/Time\", figsize=(10, 4));\n", - "plt.ylim(-1, 1);\n", + "plt.ylim(-2, 2);\n", "plt.xlim(0, len(velocities)+1);\n", "plt.grid();\n", "ax.set_xlabel(\"Time (s)\");\n", diff --git a/shared/ros_packages/px4_ros_extended/src_py/test_ddpg_agent.py b/shared/ros_packages/px4_ros_extended/src_py/test_ddpg_agent.py index d6fb409..b68cd17 100644 --- a/shared/ros_packages/px4_ros_extended/src_py/test_ddpg_agent.py +++ b/shared/ros_packages/px4_ros_extended/src_py/test_ddpg_agent.py @@ -78,12 +78,12 @@ def run(self): with torch.no_grad(): action = self.ddpg.get_exploitation_action(normalized_input) - log_velocities['vx'].append(inputs[0]*self.info_dict['max_vel_xy']) - log_velocities['vy'].append(inputs[1]*self.info_dict['max_vel_xy']) + log_velocities['vx'].append(inputs[3]*self.info_dict['max_vel_xy']) + log_velocities['vy'].append(inputs[4]*self.info_dict['max_vel_xy']) log_velocities_ref['vx'].append(action[0]*self.info_dict['max_vel_xy']) log_velocities_ref['vy'].append(action[1]*self.info_dict['max_vel_xy']) if self.act_shape == 3: # Predicting also vz - log_velocities['vz'].append(inputs[2]*self.info_dict['max_vel_z']) + log_velocities['vz'].append(inputs[5]*self.info_dict['max_vel_z']) log_velocities_ref['vz'].append(action[2]*self.info_dict['max_vel_z']) inputs, reward, done = self.env.act(action, self.normalize_input)