示例#1
0
def doSetMotor(motor, value, max):
    try:
        value = int(value * 100 * max)
        if motor == "left":
            DMCC.setMotor(0, 1, value)
        elif motor == "right":
            DMCC.setMotor(0, 2, value)
    except:
        print "Error setting " + motor + " motor, trying again"
示例#2
0
def motor_ex():
    DMCC.setPIDConstants(0, 2, 1, -3000, -32768, 0)

    while 1:
        try:
            bbio.digitalWrite(tp, bbio.HIGH)
            DMCC.setTargetVel(0, 2, 150)
            bbio.digitalWrite(tp, bbio.LOW)

        except KeyboardInterrupt:
            DMCC.setTargetVel(0, 2, 0)
            exit()
# Motor3 Parameters
Kp3 = Kp
Ki3 = 0
Kd3 = Kd
error3 = 0
errorPrev3 = 0
errorInt3 = 0.0
errorDer3 = 0.0

DT = 0.01 # Initial step size
controlInput1 = 0
controlInput2 = 0
controlInput3 = 0

# Initial encoder readings
initPos1 = -DMCC.getQEI(0,1)*360/564
initPos2 = -DMCC.getQEI(0,2)*360/564
initPos3 = -DMCC.getQEI(1,1)*360/564

t=0 #init time
terminate=0
while True:
	DesTheta = IK(t) #Desired Theta

	while True:
		time_initial = time.time() # Record the starting time
		#--------------------		
		#	Control of Q1
		#--------------------
		pos1 = -DMCC.getQEI(0,1)*360/564 - initPos1	#Read encoder
		error1 = DesTheta[0] - pos1					#Generate the error
示例#4
0
import DMCC
import time

print "Cape 0; Motor 1"
DMCC.setMotor(0, 1, 5000)
time.sleep(2)
DMCC.setMotor(0, 1, 0)

print "Cape 0; Motor 2"
DMCC.setMotor(0, 2, 5000)
time.sleep(2)
DMCC.setMotor(0, 2, 0)

print "Cape 1; Motor 1"
DMCC.setMotor(1, 1, 5000)
time.sleep(2)
DMCC.setMotor(1, 1, 0)

print "Cape 1; Motor 2"
DMCC.setMotor(1, 2, 5000)
time.sleep(2)
DMCC.setMotor(1, 2, 0)