Skip to content

Commit 78ae708

Browse files
committed
allow rotating in place trajectory for warp dphysics sampling
1 parent e7a5bce commit 78ae708

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

launch/dphysics.launch

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<arg name="device" default="cpu" doc="Device to run the warp-based differentiable physics on"/>
1010

1111
<!-- Diff Physics node -->
12-
<node unless="$(arg warp_dphys)" name="diff_physics" pkg="monoforce" type="diff_physics">
12+
<node unless="$(arg warp_dphys)" name="diff_physics" pkg="monoforce" type="diff_physics" output="screen">
1313
<rosparam subst_value="true">
1414
robot: $(arg robot)
1515
robot_clearance: 0.132

nodes/diff_physics_warp

+15-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ class DiffPhysicsWarp:
5050
self.path_lock = RLock()
5151

5252
self.poses0 = self.init_poses()
53-
self.track_vels, self.flipper_angles = self.init_controls(linear_vel, angular_vel_max, allow_backward)
53+
self.track_vels = self.init_controls(linear_vel, angular_vel_max, allow_backward)
54+
self.flipper_angles = self.init_flippers()
5455
height = np.zeros((int(hm_dims[0] / grid_res), int(hm_dims[1] / grid_res)), dtype=np.float32)
5556
self.simulator = self.init_simulator(height)
5657

@@ -99,10 +100,20 @@ class DiffPhysicsWarp:
99100
v_r = vels[i] + r * omegas[i]
100101
v_l = vels[i] - r * omegas[i]
101102
track_vels[i, :, 0], track_vels[i, :, 1] = v_r, v_l
102-
flipper_angles = np.zeros((self.n_sim_trajs, T, 4))
103+
104+
# control input to rotate 180 degrees
105+
track_vels[-1, :, 0] = -linear_vel
106+
track_vels[-1, :, 1] = linear_vel
107+
108+
return track_vels
109+
110+
def init_flippers(self):
111+
"""
112+
Initialize flipper angles.
113+
"""
114+
flipper_angles = np.zeros((self.n_sim_trajs, self.n_sim_steps, 4))
103115
# flipper_angles[0, :, 0] = 0.5
104-
105-
return track_vels, flipper_angles
116+
return flipper_angles
106117

107118
def init_simulator(self, height):
108119
"""

0 commit comments

Comments
 (0)