- 安装python
- 添加环境变量 PYTHONPATH
-
环境变量的目的是为能在Python中引用到电机控制包
image.png
-
-
启动MegaRobo Studio,在设备管理器中有设备
- 使用例程
# -*- coding=utf-8 -*-
# step1
import mrq.mrq as MRQ
# from mrq import *
# step2
# create the device
myMrq = MRQ.MRQ( "device1" )
# step3
# read the idn
idn = myMrq.IDN
print( idn )
# step4
# control the device
myMrq.IDENTITY_DISTDEVICE = "ON"
# get the value
idDist = myMrq.IDENTITY_DISTDEVICE
print( idDist )
# control the motor
# loop
for i in range( 1, 100 ):
myMrq.roate( 0, 360 )
myMrq.wait_idle( 0 )
myMrq.roate( 0, -360 )
myMrq.wait_idle( 0 )
- 说明
- 'device1' 是设备的名称
- 'rotate' 是旋转的api