from roboclaw import Roboclaw from time import sleep roboclaw = Roboclaw("/dev/ttyS0", 38400) roboclaw.Open() # Read encoder motor_1_count = roboclaw.ReadEncM1(0x80) print "Original:" print motor_1_count sleep(2) # Set encoder and then read and print to test operation roboclaw.SetEncM1(0x80, 10000) motor_1_count = roboclaw.ReadEncM1(0x80) print "After setting count:" print motor_1_count sleep(2) # Reset encoders and read and print value to test operation roboclaw.ResetEncoders(0x80) motor_1_count = roboclaw.ReadEncM1(0x80) print "After resetting:" print motor_1_count sleep(2) # Position motor, these values may have to be changed to suit the motor/encoder combination in use
version2 = rc.ReadVersion(address2) version3 = rc.ReadVersion(address3) if version1[0]==False: print "GETVERSION Failed" else: print repr(version1[1]) print repr(version2[1]) print repr(version3[1]) #homeaxis(address1,1) homeaxis(address1,2,2000,25) homeaxis(address2,1,2000,5) homeaxis(address2,2,2000,10) rc.SetEncM1(address3,0) rc.SetEncM2(address3,0) rc.SpeedAccelDeccelPositionM2(address1,2000,10000,10000,24000,100) time.sleep(0.5) rc.SpeedAccelDeccelPositionM1(address2,2000,10000,10000,2500,100) time.sleep(0.5) rc.SpeedAccelDeccelPositionM2(address2,2000,10000,10000,14500,100) time.sleep(0.5) while(1): for i in range(0,20): displayspeed() time.sleep(0.01)