增加仿真模式控制
This commit is contained in:
@@ -5,52 +5,6 @@ from lerobot.motors import Motor, MotorCalibration, MotorsBus
|
||||
#动作执行成功
|
||||
ACTION_SUCCESS = 0
|
||||
|
||||
class RoboticArmMock:
|
||||
def __init__(self,*args):
|
||||
pass
|
||||
|
||||
def rm_create_robot_arm(self, ip, port):
|
||||
print(f"connnect {ip}:{port}")
|
||||
return {"id":1}
|
||||
|
||||
def rm_movej(self,*args):
|
||||
print(f"rm_movej:{args}")
|
||||
|
||||
def rm_movej_follow(self,*args):
|
||||
print(f"rm_movej_follow:{args}")
|
||||
|
||||
def rm_get_current_arm_state(self):
|
||||
print("get_current_arm_state")
|
||||
return ACTION_SUCCESS, {"pose":[0.0,0.0,0.0,0.0,0.0,0.0],"joint":[0.0,0.0,0.0,0.0,0.0,0.0]}
|
||||
|
||||
def rm_movej_p(self,*args):
|
||||
print(f"rm_movej_p:{args}")
|
||||
|
||||
|
||||
def rm_set_joint_en_state(self,*args):
|
||||
print(f"rm_set_joint_en_state:{args}")
|
||||
|
||||
def rm_set_gripper_route(self,*args):
|
||||
print(f"rm_set_gripper_route:{args}")
|
||||
|
||||
def rm_set_gripper_position(self,*kargs):
|
||||
print(f"rm_set_gripper_position:{kargs}")
|
||||
|
||||
def rm_get_gripper_state(self):
|
||||
print("get_gripper_state")
|
||||
return ACTION_SUCCESS, {"actpos":0.0}
|
||||
|
||||
def rm_set_gripper_release(self,*args):
|
||||
print(f"rm_set_gripper_release:{args}")
|
||||
def rm_set_gripper_pick_on(self,*args):
|
||||
print(f"rm_set_gripper_pick_on:{args}")
|
||||
|
||||
def rm_movev_canfd(self,*args):
|
||||
print(f"rm_movev_canfd:{args}")
|
||||
|
||||
def rm_destory(self):
|
||||
print("destory")
|
||||
|
||||
|
||||
class RealmanMotorsBus(MotorsBus):
|
||||
model_number_table={}
|
||||
@@ -72,10 +26,11 @@ class RealmanMotorsBus(MotorsBus):
|
||||
calibration: dict[str, MotorCalibration] | None = None,
|
||||
):
|
||||
super().__init__(port,motors, calibration)
|
||||
self.rmarm = RoboticArm(rm_thread_mode_e.RM_DUAL_MODE_E)
|
||||
if mock:
|
||||
self.rmarm = RoboticArmMock()
|
||||
self.rmarm.rm_set_arm_run_mode(0)#仿真模式
|
||||
else:
|
||||
self.rmarm = RoboticArm(rm_thread_mode_e.RM_DUAL_MODE_E)
|
||||
self.rmarm.rm_set_arm_run_mode(1)
|
||||
address = port.split(':')
|
||||
self.ip = address[0]
|
||||
self.port = int(address[1])
|
||||
@@ -105,7 +60,6 @@ class RealmanMotorsBus(MotorsBus):
|
||||
'''
|
||||
|
||||
self.handle = self.rmarm.rm_create_robot_arm(self.ip, self.port)
|
||||
self.rmarm.rm_set_arm_run_mode(0)
|
||||
enable_flag = False
|
||||
loop_flag = False
|
||||
# 设置超时时间(秒)
|
||||
|
||||
Reference in New Issue
Block a user