rc.ResetEncoderCnts(0x81) # start all motors rc.M2Forward(r1_address,speed) rc.M1Forward(r2_address,speed) rc.M1Forward(r3_address,speed) time.sleep(seconds) # stop all motors rc.M2Forward(r1_address,0) rc.M1Forward(r2_address,0) rc.M1Forward(r3_address,0) r1_ticks_per_second = rc.readM2encoder(r1_address)[0]/seconds r2_ticks_per_second = rc.readM1encoder(r2_address)[0]/seconds r3_ticks_per_second = rc.readM1encoder(r3_address)[0]/seconds print speed, r1_ticks_per_second, r2_ticks_per_second, r3_ticks_per_second # speed ticks/second (r1, r2, r3) # 5 6565 7316 7206 # 10 14103 15410 15189 # 15 21744 23391 23160 # 20 29412 31361 31187 # 25 37284 38919 39325 # 30 45164 46916 47410 # 35 53177 55065 55714 # 40 61693 63290 64199 # 45 70002 71671 72669 # 50 78266 80219 81127
print starting # stop all motors rc.M2Forward(r1_address,0) rc.M1Forward(r2_address,0) rc.M1Forward(r3_address,0) rc.ResetEncoderCnts(0x80) rc.ResetEncoderCnts(0x81) # start all motors rc.M2Forward(r1_address,speed) rc.M1Forward(r2_address,speed) rc.M1Forward(r3_address,speed) while rc.readM1encoder(r2_address)[0] <= stop_ticks: continue # stop all motors rc.M2Forward(r1_address,0) rc.M1Forward(r2_address,0) rc.M1Forward(r3_address,0) rc.ResetEncoderCnts(0x80) rc.ResetEncoderCnts(0x81) print rc.readM1encoder(0x81)[0] - circle_ticks * num_circles # speed splipage # 15 179, 187, 129 11 # 50 648, 616, 524 11.92 # 100 1067, 955, 885 9.69
import roboclaw as rc import serial #rc.M1Forward(0x80,0) # rc.M1Forward(0x81,0) # rc.M2Forward(0x80,0) # rc.M1Forward(0x80,0) while 1: print rc.readM1encoder(0x81) # rc.M2Forward(0x80, 10) #Get version string # rc.sendcommand(128,21) # rcv = port.read(32) # print repr(rcv) # # rc.sendcommand(129,90) # rcv = port.read(1) # print repr(rcv)