Skip to content

Commit b963164

Browse files
committed
fixing reflex z height in case of vision
1 parent 6ef32bf commit b963164

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

quadruped_pympc/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@
200200

201201
# This is used to activate or deactivate the reflexes upon contact detection
202202
'reflex_trigger_mode': 'tracking', # 'tracking', 'geom_contact', False
203-
'reflex_height_enhancement': True,
204-
'velocity_modulator': False,
203+
'reflex_height_enhancement': False,
204+
'velocity_modulator': True,
205205

206206
# velocity mode: human will give you the possibility to use the keyboard, the other are
207207
# forward only random linear-velocity, random will give you random linear-velocity and yaw-velocity

quadruped_pympc/helpers/early_stance_detector.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import numpy as np
2-
from quadruped_pympc import config as cfg
32
from gym_quadruped.utils.quadruped_utils import LegsAttr
43

5-
6-
4+
from quadruped_pympc import config as cfg
75

86
class EarlyStanceDetector:
97
def __init__(self, feet_geom_id : LegsAttr = None,
@@ -31,7 +29,7 @@ def __init__(self, feet_geom_id : LegsAttr = None,
3129
self.absolute_min_distance_error_threshold = 0.1
3230

3331
self.gait_cycles_after_step_height_enanchement = -1
34-
self.use_height_enhancement = cfg.simulation_params['reflex_trigger_mode']
32+
self.use_height_enhancement = cfg.simulation_params['reflex_height_enhancement']
3533
self.max_gait_cycles_height_enhancement = 6
3634

3735

quadruped_pympc/helpers/swing_generators/scipy_swing_trajectory_generator.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import numpy as np
33
from scipy.interpolate import CubicSpline
44

5+
from quadruped_pympc import config as cfg
56

67
class SwingTrajectoryGenerator:
78
def __init__(self, step_height: float, swing_period: float) -> None:
@@ -14,6 +15,11 @@ def __init__(self, step_height: float, swing_period: float) -> None:
1415
self.stepHeight = step_height
1516
self.step_height_enhancement = False
1617

18+
if(cfg.simulation_params['visual_foothold_adaptation'] == 'blind'):
19+
self.z_height_enhancement = True
20+
else:
21+
self.z_height_enhancement = False
22+
1723
def createCurve(self, x0, xf, early_stance_hitmoment = -1):
1824

1925
scaling_factor = 1.5
@@ -29,7 +35,10 @@ def createCurve(self, x0, xf, early_stance_hitmoment = -1):
2935

3036
x = np.array([x0[0], p1[0], p2[0], p3[0], xf[0]])
3137
y = np.array([x0[1], p1[1], p2[1], p3[1], xf[1]])
32-
z = np.array([x0[2], p1[2], p2[2], p3[2], xf[2] + reflex_maximum_height / (scaling_factor+0.5)])
38+
if(self.z_height_enhancement):
39+
z = np.array([x0[2], p1[2], p2[2], p3[2], xf[2] + reflex_maximum_height / (scaling_factor+0.5)])
40+
else:
41+
z = np.array([x0[2], p1[2], p2[2], p3[2], xf[2]])
3342

3443
updated_swing_period = self.swing_period - early_stance_hitmoment
3544
t = np.array([early_stance_hitmoment, early_stance_hitmoment+updated_swing_period/4, early_stance_hitmoment+updated_swing_period/2, early_stance_hitmoment+updated_swing_period*3/4, self.swing_period])

quadruped_pympc/helpers/velocity_modulator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ def modulate_velocities(self, ref_base_lin_vel, ref_base_ang_vel, feet_pos, hip_
2929
np.square(feet_pos.RR[0] - hip_pos.RR[0]) + np.square(feet_pos.RR[1] - hip_pos.RR[1])
3030
)
3131

32+
if(ref_base_lin_vel[0] < 0.01 and ref_base_lin_vel[1] < 0.01):
33+
# If the robot is not moving, we don't need to modulate the velocities
34+
return ref_base_lin_vel, ref_base_ang_vel
35+
3236
if (
3337
distance_FL_to_hip_xy > self.max_distance
3438
or distance_FR_to_hip_xy > self.max_distance

simulation/simulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def run_simulation(
4646
simulation_dt = qpympc_cfg.simulation_params["dt"]
4747

4848
# Save all observables available.
49-
state_obs_names = list(QuadrupedEnv.ALL_OBS) # + list(IMU.ALL_OBS)
49+
state_obs_names = [] #list(QuadrupedEnv.ALL_OBS) # + list(IMU.ALL_OBS)
5050

5151
# Create the quadruped robot environment -----------------------------------------------------------
5252
env = QuadrupedEnv(

0 commit comments

Comments
 (0)