Skip to content
Merged
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
d86df50
我的选题
mengdeqi12 Sep 16, 2025
76fa610
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 16, 2025
4810d2d
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 19, 2025
3184469
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 21, 2025
d847f22
添加我的环境配置
mengdeqi12 Sep 22, 2025
cb82bc4
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 22, 2025
7bf132b
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 22, 2025
46ecebc
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 23, 2025
610f122
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 23, 2025
0d5ed18
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 24, 2025
64291c7
移除.idea文件并更新.gitignore
mengdeqi12 Sep 24, 2025
7fc6526
彻底删除 .idea 目录
mengdeqi12 Sep 24, 2025
587029b
彻底移除 .idea 文件并更新 .gitignore
mengdeqi12 Sep 24, 2025
2404222
彻底移除 .idea 并修正 .gitignore 位置
mengdeqi12 Sep 24, 2025
dce2420
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 24, 2025
33e5d4b
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 25, 2025
ff2758f
机器人行走的基底模型
mengdeqi12 Sep 25, 2025
eddd4de
Merge branch 'main' of https://github.com/mengdeqi12/nn
mengdeqi12 Sep 25, 2025
491f2d1
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 26, 2025
308886a
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 27, 2025
c607e1c
feat: 优化 humanoid_motion_control 模块路径处理,解决模型加载失败问题
mengdeqi12 Sep 28, 2025
17c41ab
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 28, 2025
d689c29
feat: 优化 humanoid_motion_control 模块路径处理,解决模型加载失败问题
mengdeqi12 Sep 28, 2025
73ce4c9
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 29, 2025
a4a3ef0
feat: 优化 humanoid_motion_control 模块路径处理,解决模型加载失败问题
mengdeqi12 Sep 29, 2025
fb35491
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Sep 29, 2025
c7ed4a1
Merge branch 'main' of https://github.com/mengdeqi12/nn
mengdeqi12 Sep 29, 2025
65a2e06
feat: 优化 humanoid_motion_control 模块路径处理,解决模型加载失败问题;改了代码我的项目的参数
mengdeqi12 Sep 29, 2025
19299f5
chore: 从仓库中删除 .venv 并忽略
mengdeqi12 Sep 29, 2025
0312bb8
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Oct 2, 2025
8ac7ca0
chore: 从仓库移除 tatus 文件并添加到 .gitignore
mengdeqi12 Oct 4, 2025
1da2194
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Oct 12, 2025
037a142
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Oct 13, 2025
6593f90
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Oct 13, 2025
56b0b9a
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Oct 14, 2025
7b83d1f
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Oct 14, 2025
8f12c9b
在模型文件中添加腿部模型,更新运行脚本
mengdeqi12 Oct 14, 2025
6824f42
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Oct 15, 2025
ad97f14
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Oct 20, 2025
0ff1f2c
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Oct 20, 2025
c20f8cc
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Oct 20, 2025
319d3ab
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Oct 23, 2025
e5251c7
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Oct 25, 2025
fc99023
增加模型文件内容
mengdeqi12 Oct 25, 2025
461a961
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Oct 28, 2025
affa266
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Nov 3, 2025
299d247
纠正了初始姿态失衡 和 关节限位 / 惯性参数不匹配的问题
mengdeqi12 Nov 3, 2025
2940fa3
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Nov 3, 2025
c82c80c
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Nov 10, 2025
de55c15
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Nov 17, 2025
4967733
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Nov 18, 2025
b41e691
优化模型
mengdeqi12 Nov 18, 2025
ecd7d05
优化模型
mengdeqi12 Nov 18, 2025
045475f
添加 .gitignore 文件
mengdeqi12 Nov 18, 2025
129142f
优化模型文件,并更新.gitignore
mengdeqi12 Nov 18, 2025
3c4365e
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Nov 18, 2025
132d0c5
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Nov 24, 2025
a503d33
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 2, 2025
d50e4e8
增加了障碍模型
mengdeqi12 Dec 4, 2025
d5ae6bd
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 4, 2025
824fce6
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 8, 2025
ade3208
采用mujoco开源模型优化原有模型
mengdeqi12 Dec 8, 2025
5bdaab9
新增忽略Python缓存文件规则
mengdeqi12 Dec 8, 2025
8d4501e
采用mujoco开源模型优化原有模型
mengdeqi12 Dec 8, 2025
0376896
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 8, 2025
6644c82
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 10, 2025
0b8a0a5
简化障碍模型,优化机器人避障机制
mengdeqi12 Dec 10, 2025
e2c33ea
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 11, 2025
ed4c9f2
增加了障碍模型
mengdeqi12 Dec 11, 2025
df216d9
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 12, 2025
42935b9
为wall2添加slide关节,使其可沿 Y 轴(左右)或 X 轴(前后)动态移动,保留wall1为固定障碍作为基础避障目标
mengdeqi12 Dec 12, 2025
ec2e2be
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 13, 2025
fb4c979
增加固定点目标导航模块
mengdeqi12 Dec 13, 2025
9189840
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 14, 2025
49027d4
复杂动态环境中完成目标导航
mengdeqi12 Dec 14, 2025
84f13e7
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 15, 2025
7723d52
在动态避障中实现了多个固定目标点的导航
mengdeqi12 Dec 15, 2025
6e3e02a
停止跟踪MUJOCO_LOG.TXT日志文件,加入.gitignore忽略
mengdeqi12 Dec 15, 2025
8f2b671
在动态避障中实现了多个固定目标点的导航
mengdeqi12 Dec 15, 2025
4a5adbf
在动态避障中实现了多个固定目标点的导航
mengdeqi12 Dec 15, 2025
86ab201
删除远程仓库中的MUJOCO_LOG.TXT日志文件
mengdeqi12 Dec 16, 2025
1d9694c
删除了MUJOCO_LOG.TXT文件
mengdeqi12 Dec 16, 2025
ae70f1f
ooo
mengdeqi12 Dec 16, 2025
06ef7e6
恢复main.py的总启动文件,删除了日志文件
mengdeqi12 Dec 16, 2025
2baf40b
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 16, 2025
9c6ec5c
解决中文乱码问题
mengdeqi12 Dec 16, 2025
e290398
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 16, 2025
21e812d
Merge branch 'main' of https://github.com/mengdeqi12/nn
mengdeqi12 Dec 16, 2025
89dbafd
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 17, 2025
3e3f4a0
全局配置 Git 强制使用 UTF-8 编码,统一文件编码为UTF-8,适配远程解析
mengdeqi12 Dec 17, 2025
de77843
采用纯英文注释,避免编码器的不同造成的乱码现象
mengdeqi12 Dec 17, 2025
e18ad44
将main文件的注释改为英文,避免编码器的不同导致的中文乱码
mengdeqi12 Dec 17, 2025
055f1d6
覆盖上次提交(修复乱码),增加动态目标巡航的功能
mengdeqi12 Dec 18, 2025
041ce35
尝试解决冲突
mengdeqi12 Dec 18, 2025
2cf4c3d
尝试解决冲突
mengdeqi12 Dec 18, 2025
98586c8
尝试解决冲突
mengdeqi12 Dec 18, 2025
c7e531f
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 19, 2025
b91e04b
修改模型文件
mengdeqi12 Dec 19, 2025
924d7b1
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 19, 2025
41ab8ea
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 19, 2025
c33ca2b
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 19, 2025
2debcd2
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 19, 2025
c77cfca
优化机器人容易倒地的问题
mengdeqi12 Dec 19, 2025
3f634e4
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 21, 2025
5e698f7
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 21, 2025
99a20ab
实现基于距离优先的多目标决策
mengdeqi12 Dec 21, 2025
ece0924
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 22, 2025
acdacf9
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 22, 2025
bfdefe7
优化机器人在可视化界面一闪而过的问题
mengdeqi12 Dec 22, 2025
35e3438
Merge branch 'OpenHUTB:main' into main
mengdeqi12 Dec 22, 2025
0d92252
初始状态中机器人的世界坐标被错误设置,导致模型在空间中位置异常,解决改异常
mengdeqi12 Dec 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 52 additions & 46 deletions src/embodied_robot/robot_walk/move_straight.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
DeepMind Humanoid Robot Simulation
Dynamic Obstacle Avoidance + Distance-Priority Multi-Target Tracking
Stable Version: Fixed robot disappearing issue in MuJoCo viewer
Final Stable Version: Completely fixed robot disappearing issue in MuJoCo viewer
GitHub compatible (UTF-8, no log files generated)
"""

Expand Down Expand Up @@ -44,9 +44,12 @@ def __init__(self, model_path):
# -------------------------- Patrol Target Configuration --------------------------
self.patrol_points = [
{"name": "patrol_target_1", "pos": np.array([0.0, 0.0]), "label": "Start Point", "update_interval": 10.0},
{"name": "patrol_target_2", "pos": np.array([2.0, -1.0]), "label": "Patrol Point 1 (SW)", "update_interval": 12.0},
{"name": "patrol_target_3", "pos": np.array([4.0, 1.0]), "label": "Patrol Point 2 (NE)", "update_interval": 14.0},
{"name": "patrol_target_4", "pos": np.array([6.0, -0.5]), "label": "Patrol Point 3 (NW)", "update_interval": 11.0},
{"name": "patrol_target_2", "pos": np.array([2.0, -1.0]), "label": "Patrol Point 1 (SW)",
"update_interval": 12.0},
{"name": "patrol_target_3", "pos": np.array([4.0, 1.0]), "label": "Patrol Point 2 (NE)",
"update_interval": 14.0},
{"name": "patrol_target_4", "pos": np.array([6.0, -0.5]), "label": "Patrol Point 3 (NW)",
"update_interval": 11.0},
{"name": "patrol_target_5", "pos": np.array([8.0, 0.0]), "label": "Final Point", "update_interval": 13.0}
]
self.current_target_idx = 0 # Current tracked target index
Expand Down Expand Up @@ -104,7 +107,7 @@ def __init__(self, model_path):
# -------------------------- Initialize Components --------------------------
self._init_component_ids()
self._init_obstacle_history()
self._set_initial_pose()
self._set_initial_pose() # Fixed initial position here

def _init_component_ids(self):
"""Initialize all MuJoCo component IDs (joints, motors, bodies)"""
Expand Down Expand Up @@ -217,14 +220,23 @@ def _init_obstacle_history(self):
self.wall_pos_history[wall_name] = deque(maxlen=10)

def _set_initial_pose(self):
"""Set stable initial standing pose and lock position to prevent disappearing"""
# Reset entire simulation data first (core fix for initial drift)
"""强制固定机器人初始位置到视野中心,彻底解决消失问题(核心最终修复)"""
# 1. 重置仿真数据(清空所有异常状态)
mujoco.mj_resetData(self.model, self.data)

# Reset all control commands
# 2. 重置所有控制指令
self.data.ctrl[:] = 0.0

# Initial joint positions (stable standing)
# 3. 强制设置机器人根关节初始世界坐标(不依赖关节ID,直接操作qpos前6位)
# qpos前3位:x/y/z 位置(固定在视野中心);后3位:roll/pitch/yaw 姿态(无倾斜旋转)
self.data.qpos[0] = 0.0 # x坐标:视野中心
self.data.qpos[1] = 0.0 # y坐标:视野中心
self.data.qpos[2] = 0.8 # z坐标:站立高度,确保在地面上方
self.data.qpos[3] = 0.0 # roll:无左右倾斜
self.data.qpos[4] = 0.0 # pitch:无前后倾斜
self.data.qpos[5] = 0.0 # yaw:无旋转

# 4. 强制设置机器人关节初始位置(稳定站立姿态,避免倾倒)
joint_positions = {
"abdomen_x": 0.0,
"abdomen_y": 0.0,
Expand All @@ -248,25 +260,14 @@ def _set_initial_pose(self):
"shoulder2_left": 0.0,
"elbow_left": -0.1
}

# Apply initial joint positions
for joint_name, target_pos in joint_positions.items():
joint_id = mujoco.mj_name2id(self.model, mujoco.mjtObj.mjOBJ_JOINT, joint_name)
if joint_id != -1:
self.data.qpos[joint_id] = target_pos

# Lock torso initial position to prevent drift (core fix for disappearing)
if self.torso_id != -1:
# Get torso joint ID to set initial world position
body_joint_id = mujoco.mj_name2id(self.model, mujoco.mjtObj.mjOBJ_JOINT, "torso_joint")
if body_joint_id == -1:
body_joint_id = mujoco.mj_name2id(self.model, mujoco.mjtObj.mjOBJ_JOINT, "waist_lower_joint")
if body_joint_id != -1:
# Set torso initial position (x=0, y=0, z=0.8) to keep it in view
self.data.qpos[body_joint_id * 7: body_joint_id * 7 + 3] = [0.0, 0.0, 0.8]
# Also reset torso velocity to zero
self.data.qvel[:3] = 0.0 # Linear velocity (x/y/z)
self.data.qvel[3:6] = 0.0 # Angular velocity (roll/pitch/yaw)
# 关节ID对应的qpos索引:根关节占前6位,关节从第7位开始(索引6)
self.data.qpos[joint_id + 6] = target_pos

# 5. 强制设置机器人初始速度为0(无移动、无旋转,彻底杜绝初始漂移)
self.data.qvel[:] = 0.0

def _clip_control_command(self, cmd):
"""Clip control command to max amplitude to prevent joint over-drive (core fix)"""
Expand All @@ -276,9 +277,9 @@ def _select_closest_target(self, elapsed_time):
"""Core decision function: select the closest target based on Euclidean distance"""
# Skip target selection if conditions are not met
if (elapsed_time < self.stabilization_phase or
self.avoid_obstacle or
self.return_to_path or
(elapsed_time - self.last_target_switch_time < self.target_switch_cooldown)):
self.avoid_obstacle or
self.return_to_path or
(elapsed_time - self.last_target_switch_time < self.target_switch_cooldown)):
return self.current_target_idx

# Get robot torso position (XY plane)
Expand Down Expand Up @@ -309,7 +310,8 @@ def _select_closest_target(self, elapsed_time):
prev_label = self.patrol_points[self.current_target_idx]["label"]
self.current_target_idx = closest_idx
# Print switch info (console only, no log file)
print(f"\n🔀 Target switched (distance priority): {prev_label} → {closest_label} (distance: {closest_dist:.2f}m)")
print(
f"\n🔀 Target switched (distance priority): {prev_label} → {closest_label} (distance: {closest_dist:.2f}m)")

return self.current_target_idx

Expand Down Expand Up @@ -340,15 +342,14 @@ def _update_dynamic_targets(self, elapsed_time):
new_x = random.uniform(self.target_movement_range["x"][0], self.target_movement_range["x"][1])
new_y = random.uniform(self.target_movement_range["y"][0], self.target_movement_range["y"][1])

# Control target movement (smooth and slow)
# Control target movement (smooth and slow) with command clipping
if (self.patrol_motor_ids[idx]["x"] != -1 and
self.patrol_motor_ids[idx]["y"] != -1 and
self.patrol_joint_ids[idx]["x"] != -1 and
self.patrol_joint_ids[idx]["y"] != -1):
current_x = self.data.qpos[self.patrol_joint_ids[idx]["x"]]
current_y = self.data.qpos[self.patrol_joint_ids[idx]["y"]]

# Clip control commands for targets to prevent sudden movement
x_cmd = (new_x - current_x) * self.target_move_speed * 0.5
y_cmd = (new_y - current_y) * self.target_move_speed * 0.5
self.data.ctrl[self.patrol_motor_ids[idx]["x"]] = self._clip_control_command(x_cmd)
Expand Down Expand Up @@ -389,8 +390,10 @@ def _control_dynamic_obstacles(self, elapsed_time):
self.wall3_params["y_switch"] = random.uniform(2.0, 4.0)
self.wall3_last_switch["y"] = elapsed_time

wall3_x_target = self.wall3_params["x_base"] + self.wall3_params["x_dir"] * self.wall3_params["x_speed"] * (elapsed_time % 8)
wall3_y_target = self.wall3_params["y_base"] + self.wall3_params["y_dir"] * self.wall3_params["y_speed"] * (elapsed_time % 6)
wall3_x_target = self.wall3_params["x_base"] + self.wall3_params["x_dir"] * self.wall3_params["x_speed"] * (
elapsed_time % 8)
wall3_y_target = self.wall3_params["y_base"] + self.wall3_params["y_dir"] * self.wall3_params["y_speed"] * (
elapsed_time % 6)
wall3_x_target = np.clip(wall3_x_target, 3.5, 4.5)
wall3_y_target = np.clip(wall3_y_target, -1.0, 1.0)

Expand Down Expand Up @@ -473,10 +476,12 @@ def _detect_obstacles(self, elapsed_time):
self.turn_direction = -1 if cross_product > 0 else 1
self.turn_dir_label = "Left" if self.turn_direction == -1 else "Right"

print(f"\n⚠️ Obstacle detected: {closest_wall['name']} (distance: {closest_wall['predicted_dist']:.2f}m) - Turning {self.turn_dir_label}")
print(
f"\n⚠️ Obstacle detected: {closest_wall['name']} (distance: {closest_wall['predicted_dist']:.2f}m) - Turning {self.turn_dir_label}")

# Complete obstacle avoidance phase
if self.avoid_obstacle and (elapsed_time - self.obstacle_avoidance_start) > self.obstacle_avoidance_duration:
if self.avoid_obstacle and (
elapsed_time - self.obstacle_avoidance_start) > self.obstacle_avoidance_duration:
self.avoid_obstacle = False
self.return_to_path = True
self.return_to_path_start = elapsed_time
Expand All @@ -485,7 +490,8 @@ def _detect_obstacles(self, elapsed_time):
# Complete return to path phase
if self.return_to_path and (elapsed_time - self.return_to_path_start) > self.return_to_path_duration:
self.return_to_path = False
print(f"✅ Back to patrol path - tracking target: {self.patrol_points[self.current_target_idx]['label']}")
print(
f"✅ Back to patrol path - tracking target: {self.patrol_points[self.current_target_idx]['label']}")

def _get_joint_id(self, joint_name):
"""Get actuator ID for a given joint name"""
Expand Down Expand Up @@ -612,7 +618,6 @@ def _control_robot_gait(self, elapsed_time):
if (distance_to_target < self.target_reached_threshold and
not self.patrol_completed and
elapsed_time - self.last_target_switch_time > self.target_switch_cooldown):

print(f"\n✅ Reached target: {current_target['label']} (x={torso_pos[0]:.2f}, y={torso_pos[1]:.2f})")
self.last_target_switch_time = elapsed_time
print(f"🔍 Scanning for closest next target...")
Expand All @@ -626,7 +631,7 @@ def _control_robot_gait(self, elapsed_time):
target_yaw = np.arctan2(target_vector[1], target_vector[0])
yaw_error = target_yaw - robot_yaw
yaw_error = np.arctan2(np.sin(yaw_error), np.cos(yaw_error)) # Normalize to [-pi, pi]
yaw_error = np.clip(yaw_error, -np.pi/4, np.pi/4) # Limit max yaw error to 45 degrees (core fix)
yaw_error = np.clip(yaw_error, -np.pi / 4, np.pi / 4) # Limit max yaw error to 45 degrees (core fix)

# Step 4: Reset control commands
self.data.ctrl[:self.model.nu] = 0.0
Expand Down Expand Up @@ -819,21 +824,21 @@ def _print_status(self, elapsed_time):
)

def run_simulation(self):
"""Main simulation loop with camera tracking (fixes disappearing robot in viewer)"""
"""Main simulation loop with optimized camera tracking (彻底解决机器人消失问题)"""
print("🤖 DeepMind Humanoid Simulation Started (Distance-Priority Target Tracking)")
print("📌 Features: Enhanced Balance + Dynamic Obstacle Avoidance + Closest Target Selection")
print("🔍 Press Ctrl+C to stop simulation\n")

with viewer.launch_passive(self.model, self.data) as viewer_instance:
self.sim_start_time = time.time()

# Lock camera to track robot torso (core fix for disappearing view)
# 优化相机参数:增大距离+调整视角,确保机器人始终在视野内
if self.torso_id != -1:
viewer_instance.cam.trackbodyid = self.torso_id
viewer_instance.cam.distance = 5.0 # Camera distance from robot (keep in view)
viewer_instance.cam.elevation = -10 # Camera elevation (slight top-down view)
viewer_instance.cam.azimuth = 45 # Camera azimuth (fixed angle)
viewer_instance.cam.fixedcamid = -1 # Use tracking camera, not fixed camera
viewer_instance.cam.distance = 10.0 # 增大相机距离,避免模型超出视野
viewer_instance.cam.elevation = -20 # 增大俯视角,清晰看到机器人
viewer_instance.cam.azimuth = 90 # 正前方视角,符合直观观察
viewer_instance.cam.fixedcamid = -1 # 使用跟踪相机,不使用固定相机

try:
while viewer_instance.is_running():
Expand All @@ -850,8 +855,8 @@ def run_simulation(self):
mujoco.mj_step(self.model, self.data)
viewer_instance.sync()

# Increased sleep time to fix rendering sync (core fix for disappearing)
time.sleep(0.01) # Stable sleep time, no more fast simulation
# 稳定休眠时间,解决渲染不同步
time.sleep(0.01)

except KeyboardInterrupt:
print("\n\n🛑 Simulation interrupted by user")
Expand Down Expand Up @@ -893,5 +898,6 @@ def run_simulation(self):
except Exception as e:
print(f"\n❌ Failed to start simulation: {e}")
import traceback

traceback.print_exc()
sys.exit(1)
Loading