Update sim/unitree_sdk2py_bridge.py
Browse files- sim/unitree_sdk2py_bridge.py +0 -21
sim/unitree_sdk2py_bridge.py
CHANGED
|
@@ -120,27 +120,6 @@ class UnitreeSdk2Bridge:
|
|
| 120 |
|
| 121 |
self.reset()
|
| 122 |
|
| 123 |
-
# Initialize motors with default KP/KD from config to make robot stiff at startup
|
| 124 |
-
self._initialize_motor_defaults()
|
| 125 |
-
|
| 126 |
-
def _initialize_motor_defaults(self):
|
| 127 |
-
"""Initialize motor commands with default KP/KD and joint positions"""
|
| 128 |
-
if "MOTOR_KP" in self.config and "MOTOR_KD" in self.config:
|
| 129 |
-
motor_kp = self.config["MOTOR_KP"]
|
| 130 |
-
motor_kd = self.config["MOTOR_KD"]
|
| 131 |
-
default_dof_angles = self.config.get("DEFAULT_DOF_ANGLES", [0.0] * self.num_body_motor)
|
| 132 |
-
|
| 133 |
-
for i in range(min(self.num_body_motor, len(motor_kp))):
|
| 134 |
-
self.low_cmd.motor_cmd[i].kp = motor_kp[i]
|
| 135 |
-
self.low_cmd.motor_cmd[i].kd = motor_kd[i]
|
| 136 |
-
self.low_cmd.motor_cmd[i].q = default_dof_angles[i] if i < len(default_dof_angles) else 0.0
|
| 137 |
-
self.low_cmd.motor_cmd[i].dq = 0.0
|
| 138 |
-
self.low_cmd.motor_cmd[i].tau = 0.0
|
| 139 |
-
|
| 140 |
-
print(f"✓ Initialized {self.num_body_motor} motors with default KP/KD gains")
|
| 141 |
-
else:
|
| 142 |
-
print("⚠ Warning: MOTOR_KP/MOTOR_KD not found in config, robot will be limp at startup")
|
| 143 |
-
|
| 144 |
def reset(self):
|
| 145 |
with self.low_cmd_lock:
|
| 146 |
self.low_cmd_received = False
|
|
|
|
| 120 |
|
| 121 |
self.reset()
|
| 122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
def reset(self):
|
| 124 |
with self.low_cmd_lock:
|
| 125 |
self.low_cmd_received = False
|