mix control fix bug

This commit is contained in:
2025-06-09 10:58:28 +08:00
parent cf8df17d3a
commit 55f284b306
5 changed files with 585 additions and 13 deletions

View File

@@ -189,8 +189,8 @@ class EndPoseController:
# print(f"死区处理后 - 右摇杆: {right_y}, 左摇杆: {left_y}")
# 计算各轴速度
self.pose_speeds[0] = current_linear_step if hat_up else (-current_linear_step if hat_down else 0.0) # X
self.pose_speeds[1] = current_linear_step if hat_left else (-current_linear_step if hat_right else 0.0) # Y
self.pose_speeds[1] = current_linear_step if hat_up else (-current_linear_step if hat_down else 0.0) # Y
self.pose_speeds[0] = -current_linear_step if hat_left else (current_linear_step if hat_right else 0.0) # X
# 设置Z速度右摇杆Y轴控制
z_mapping = self._apply_nonlinear_mapping(right_y)
@@ -284,19 +284,20 @@ class EndPoseController:
if __name__ == "__main__":
# 初始化睿尔曼机械臂
arm = RoboticArm(rm_thread_mode_e.RM_TRIPLE_MODE_E)
init_joint = [-90, 90, 90, 90, -90, -90, 90]
init_pose = [-0.030, 0.255, 0.161, 3.142, 0, -1.57]
# 创建机械臂连接
handle = arm.rm_create_robot_arm("192.168.3.18", 8080)
print(f"机械臂连接ID: {handle.id}")
# 使能机械臂
enable_fun(arm=arm)
# init joint
init_joint = [-90, 90, 90, -90, -90, 90]
arm.rm_movej(init_joint, 50, 0, 0, 1)
init_pose = arm.rm_get_current_arm_state()[1]['pose']
teleop = EndPoseController(init_joint, init_pose)
try:
while True:
# 获取当前控制命令
@@ -314,7 +315,7 @@ if __name__ == "__main__":
# 使用笛卡尔空间直线运动控制末端位姿
# 参数: 目标位姿, 速度比例(20%), 交融半径(0), 连接标志(0), 阻塞模式(0-非阻塞)
result = arm.rm_movej_p(target_pose, 50, 0, 0, 1)
result = arm.rm_movej_p(target_pose, 50, 0, 0, 0)
if result != 0:
print(f"运动控制错误,错误码: {result}")