这是给机器人设置的端口,对照用
代码
#
#'作者:溥哥’
##机器人驱动主程序
#请在main中编写您自己的机器人驱动代码
import msvcrt
def main():a="none"while True:key_input = msvcrt.getch()a=key_inputif a==b'w':print(a)robot_drv.set_motors(1,40,2,40,3,40,4,40)robot_drv.sleep(100)robot_drv.stop_all_motor()if a==b's':print(a) robot_drv.set_motors(1,-45,2,-45,3,-45,4,-45)robot_drv.sleep(160)robot_drv.stop_all_motor()if a==b'd':print(a) robot_drv.set_motors(1,25,2,25,3,-25,4,-25)robot_drv.sleep(20)robot_drv.stop_all_motor()if a==b'a':print(a) robot_drv.set_motors(1,-25,2,-25,3,25,4,25)robot_drv.sleep(20)robot_drv.stop_all_motor()if a==b'e':robot_drv.set_motors(1,55,2,55,3,55,4,55)robot_drv.sleep(100)robot_drv.stop_all_motor()if a==b'f':for i in range(20):robot_drv.tanshe(120,5100,121,5100,122,5650,123,5650,124,32767)if a==b'r':for i in range(20):robot_drv.tanshe(124,32767,123,1300,124,1300)# *********************************************
# 以下为初始化代码,请不要修改或者删除
# *********************************************
import sys
import irobotq_robotdriver as robot_drvif __name__ == '__main__':try:ret=robot_drv.init(sys.argv[1],sys.argv[2],int(sys.argv[3]))if(ret == 0):main()robot_drv.over()print("机器人程序运行结束")else:print('初始化错误,错误码:%d' % ret)print('按任意键退出')v=input()except Exception as e:print (e)print('按任意键退出')v=input()
#该代码适用于萝卜圈python编译器1.6.2.2
效果(仅供参考)