def main(): rospy.init_node("arm_controller") cfg_server = Server(armConfig, lambda config, level: config) #start two arm control for the robot right_arm = ArmControl(cfg_server, "right") left_arm = ArmControl(cfg_server, "left") _loop_rate = rospy.Rate(100) while not rospy.is_shutdown(): #do other important stuff here #look up whether there is any change in poses, etc... #currently, we just update the torques right_arm._update_torque() left_arm._update_torque() #if we have extra time, sleep _loop_rate.sleep()
''' from xarm.wrapper import XArmAPI from BodyGameRuntime import BodyGameRuntime from ArmControl import ArmControl from SerialCommunication import SerialCommunication if __name__ == '__main__': arm_left = XArmAPI('192.168.1.209') arm_right = XArmAPI('192.168.1.151') # 连接控制器 arm_left.motion_enable(enable=True) arm_right.motion_enable(enable=True) # 使能 arm_left.set_mode(0) arm_right.set_mode(0) # 运动模式:位置控制模式 arm_left.set_state(state=0) arm_right.set_state(state=0) # 运动状态:进入运动状态 s = SerialCommunication() game = BodyGameRuntime() arm = ArmControl(arm_left, arm_right) while True: a = s.ser() if a == '88': arm.initial() game.run(arm) arm.initial()