@@ -49,23 +49,22 @@ def apply(self, poses, goal):
49
49
all_poses = poses .view (self .K * self .T , self .NPOS )
50
50
51
51
# use terminal distance (K, tensor)
52
- dists = poses [:, self .T - 1 , :2 ].sub (goal [:2 ]).norm (p = 2 , dim = 1 ).mul (self .dist_w )
53
52
cost2go = self .value_fn .get_value (poses [:, self .T - 1 , :]).mul (self .cost2go_w )
54
53
55
54
# get all collisions (K, T, tensor)
56
- collisions = self .world_rep .check_collision_in_map (
57
- all_poses ). view (self .K , self . T )
55
+ collisions = self .world_rep .check_collision_in_map (all_poses ). view ( self . K , self . T )
56
+ collision_cost = collisions . sum ( dim = 1 ). mul (self .bounds_cost )
58
57
59
- obstacle_distances = self .world_rep .distances (
60
- all_poses ).view (self .K , self .T )
58
+ obstacle_distances = self .world_rep .distances (all_poses ).view (self .K , self .T )
61
59
62
- collision_cost = collisions .sum (dim = 1 ).mul (self .bounds_cost )
63
- obstacle_dist_cost = obstacle_distances [:].sum (dim = 1 ).mul (self .obs_dist_w )
60
+ obs_dist_cost = obstacle_distances [:].sum (dim = 1 ).mul (self .obs_dist_w )
64
61
65
62
# reward smoothness by taking the integral over the rate of change in poses,
66
63
# with time-based discounting factor
67
64
smoothness = ((poses [:, 1 :, 2 ] - poses [:, :self .T - 1 , 2 ])).abs ().mul (self .discount ).sum (dim = 1 )
68
- result = dists .add (cost2go ).add (collision_cost ).add (obstacle_dist_cost ).add (smoothness )
65
+
66
+ # result = dists.add(cost2go).add(collision_cost).add(obstacle_dist_cost).add(smoothness)
67
+ result = cost2go .add (collision_cost ).add (obs_dist_cost ).add (smoothness )
69
68
70
69
if self .viz_rollouts :
71
70
import librhc .rosviz as rosviz
@@ -81,10 +80,9 @@ def print_n(c, ns, cmap='coolwarm'):
81
80
", Avg: " + str (torch .mean (c )))
82
81
83
82
print_n (result , ns = "final_result" )
84
- print_n (dists , ns = "dists" )
85
83
print_n (cost2go , ns = "cost2go" )
86
84
print_n (collision_cost , ns = "collision_cost" )
87
- print_n (obstacle_dist_cost , ns = "obstacle_dist_cost" )
85
+ print_n (obs_dist_cost , ns = "obstacle_dist_cost" )
88
86
print_n (smoothness , ns = "smoothness" )
89
87
90
88
return result
0 commit comments