diff --git a/Simulator/src/config/config.yaml b/Simulator/src/config/config.yaml index 113297e..cfacd8f 100644 --- a/Simulator/src/config/config.yaml +++ b/Simulator/src/config/config.yaml @@ -20,7 +20,7 @@ expand_y_times: 0 # y方向复制次数(cuda版不使用) occupy_threshold: 0 # 大于多少个点才认为占据(cpu版不使用) # 2.2 随机地图 -seed: 2 +seed: 3 x_length: 60 # 真正随机范围(XY更大范围处为其镜像) y_length: 60 z_length: 15 diff --git a/YOPO/config/traj_opt.yaml b/YOPO/config/traj_opt.yaml index 4728396..bec4cf8 100644 --- a/YOPO/config/traj_opt.yaml +++ b/YOPO/config/traj_opt.yaml @@ -1,6 +1,7 @@ -# IMPORTANT PARAM: actual velocity in training / test +# IMPORTANT PARAM: actual velocity in training / testing velocity: 6.0 -# used to align the vel/acc, if vel*n then acc*n*n +# used to align the vel/acc, ensure consistency between testing and training. +# during testing, if vel*n then acc*n*n, please refer to ../policy/primitive.py vel_align: 6.0 acc_align: 6.0 diff --git a/YOPO/loss/guidance_loss.py b/YOPO/loss/guidance_loss.py index 3c9e3c8..5b8ab04 100644 --- a/YOPO/loss/guidance_loss.py +++ b/YOPO/loss/guidance_loss.py @@ -19,9 +19,9 @@ class GuidanceLoss(nn.Module): Df: fixed parameters: (batch_size, 3, 3) → [px, vx, ax; py, vy, ay; pz, vz, az] goal: (batch_size, 3) Returns: - similarity: (batch_size) → guidance loss + guidance_loss: (batch_size) → guidance loss - GuidanceLoss: Projection length of the trajectory onto the goal direction: higher cosine similarity and longer trajectory are preferred + GuidanceLoss: distance_loss (better near the goal) or similarity_loss (better during flight) or terminal_aware_similarity_loss (balanced) """ cur_pos = Df[:, :, 0] end_pos = Dp[:, :, 0] @@ -79,7 +79,7 @@ class GuidanceLoss(nn.Module): traj_dir_proj = similarity.unsqueeze(1) * goal_dir_norm # [B, 3] perp_component = (traj_dir - traj_dir_proj).norm(dim=1) # [B] - perp_weight = 2 * (self.goal_length - goal_length) / self.goal_length # [B] - perp_weight[perp_weight.abs() < 1e-4] = 0.0 # eliminate tiny numerical errors for stability - similarity_loss = th.abs(goal_length - similarity) + perp_weight * perp_component + perp_weight = ((self.goal_length - goal_length) / self.goal_length).clamp(min=0.0, max=0.6) # [B] + perp_weight[perp_weight < 1e-4] = 0.0 # eliminate tiny numerical errors for stability + similarity_loss = (1 - perp_weight) * th.abs(goal_length - similarity) + perp_weight * perp_component return similarity_loss \ No newline at end of file diff --git a/YOPO/saved/YOPO_1/epoch50.pth b/YOPO/saved/YOPO_1/epoch50.pth old mode 100644 new mode 100755 index aaca561..54e988c Binary files a/YOPO/saved/YOPO_1/epoch50.pth and b/YOPO/saved/YOPO_1/epoch50.pth differ