gpue commited on
Commit
902cc59
·
1 Parent(s): 6487de0

Update QuadrupedPyMPCController for enhanced strafe motion dynamics

Browse files

- Increased strafe amplitude and added extra knee lift during strafe for improved movement.
- Refined strafe behavior by differentiating between leading and trailing legs, optimizing hip roll adjustments during both swing and stance phases.
- Enhanced comments for clarity on strafe mechanics and adjustments.

robots/spot/controllers/quadruped_pympc_controller.py CHANGED
@@ -74,8 +74,9 @@ class QuadrupedPyMPCController(BaseController):
74
  # Motion parameters - SIGNIFICANTLY INCREASED
75
  self.swing_height = 0.35 # radians - big knee lift during swing
76
  self.stride_length = 0.5 # radians - big hip pitch for forward/back
77
- self.strafe_amplitude = 0.4 # radians - lateral hip roll amplitude
78
- self.turn_amplitude = 0.25 # radians - turning hip roll amplitude
 
79
 
80
  # Feedback gains for balance
81
  self.kp_roll = 0.5
@@ -228,13 +229,26 @@ class QuadrupedPyMPCController(BaseController):
228
  # Also adjust hip pitch for turning
229
  hy_offset += turn_sign * 0.15 * vyaw * (1 - 2 * swing_progress)
230
 
231
- # STRAFE: Big lateral hip roll during swing
232
  if abs(vy) > 0.01:
233
- sign = 1.0 if is_left else -1.0
234
- # Strong lateral motion through hip roll
235
- hx += sign * self.strafe_amplitude * vy * (1 - 2 * swing_progress)
236
- # Also lift knee more during strafe
237
- kn_offset -= 0.1 * abs(vy) * np.sin(np.pi * swing_progress)
 
 
 
 
 
 
 
 
 
 
 
 
 
238
 
239
  hy += hy_offset
240
  kn += kn_offset
@@ -268,10 +282,23 @@ class QuadrupedPyMPCController(BaseController):
268
  # Push in opposite direction during stance
269
  hx += sign * turn_sign * self.turn_amplitude * vyaw * np.cos(np.pi * stance_progress)
270
 
271
- # STRAFE in stance: push laterally
272
  if abs(vy) > 0.01:
273
- sign = 1.0 if is_left else -1.0
274
- hx += sign * self.strafe_amplitude * vy * np.cos(np.pi * stance_progress)
 
 
 
 
 
 
 
 
 
 
 
 
 
275
 
276
  hy += hy_offset
277
  kn += kn_offset
 
74
  # Motion parameters - SIGNIFICANTLY INCREASED
75
  self.swing_height = 0.35 # radians - big knee lift during swing
76
  self.stride_length = 0.5 # radians - big hip pitch for forward/back
77
+ self.strafe_amplitude = 0.6 # radians - lateral hip roll amplitude (INCREASED)
78
+ self.strafe_knee_extra = 0.2 # extra knee lift during strafe
79
+ self.turn_amplitude = 0.3 # radians - turning hip roll amplitude
80
 
81
  # Feedback gains for balance
82
  self.kp_roll = 0.5
 
229
  # Also adjust hip pitch for turning
230
  hy_offset += turn_sign * 0.15 * vyaw * (1 - 2 * swing_progress)
231
 
232
+ # STRAFE: Aggressive lateral motion during swing
233
  if abs(vy) > 0.01:
234
+ # Determine if this leg should step toward or away from strafe direction
235
+ # When strafing right (vy < 0): right legs lead, left legs follow
236
+ # When strafing left (vy > 0): left legs lead, right legs follow
237
+ strafe_dir = 1.0 if vy > 0 else -1.0
238
+ is_leading_leg = (is_left and vy > 0) or (not is_left and vy < 0)
239
+
240
+ # Leading leg: big outward hip roll to reach
241
+ # Trailing leg: hip roll inward to push
242
+ if is_leading_leg:
243
+ hx += self.strafe_amplitude * abs(vy) * np.sin(np.pi * swing_progress)
244
+ else:
245
+ hx -= self.strafe_amplitude * 0.5 * abs(vy) * np.sin(np.pi * swing_progress)
246
+
247
+ # Extra knee lift for clearance during strafe
248
+ kn_offset -= self.strafe_knee_extra * abs(vy) * np.sin(np.pi * swing_progress)
249
+
250
+ # Slight hip pitch adjustment for diagonal reach
251
+ hy_offset += 0.1 * abs(vy) * (1 - 2 * swing_progress)
252
 
253
  hy += hy_offset
254
  kn += kn_offset
 
282
  # Push in opposite direction during stance
283
  hx += sign * turn_sign * self.turn_amplitude * vyaw * np.cos(np.pi * stance_progress)
284
 
285
+ # STRAFE in stance: push body laterally
286
  if abs(vy) > 0.01:
287
+ # In stance, push in direction of strafe
288
+ is_leading_leg = (is_left and vy > 0) or (not is_left and vy < 0)
289
+
290
+ # Leading leg (already placed outward): pull body toward it
291
+ # Trailing leg: push body away
292
+ if is_leading_leg:
293
+ # Pull - hip roll decreases to bring body over
294
+ hx -= self.strafe_amplitude * 0.7 * abs(vy) * (1 - stance_progress)
295
+ else:
296
+ # Push - hip roll increases to push body away
297
+ hx += self.strafe_amplitude * 0.7 * abs(vy) * stance_progress
298
+
299
+ # Also slight knee bend on trailing side for push
300
+ if not is_leading_leg:
301
+ kn_offset -= 0.1 * abs(vy) * stance_progress
302
 
303
  hy += hy_offset
304
  kn += kn_offset