#***Before using this example the motor/controller combination must be #***tuned and the settings saved to the Roboclaw using IonMotion. #***The Min and Max Positions must be at least 0 and 50000 import time from roboclaw import Roboclaw #Windows comport name #rc = Roboclaw("COM3",115200) #Linux comport name rc = Roboclaw("/dev/tty_roboclaw", 115200) def displayspeed(): enc1 = rc.ReadEncM1(address) enc2 = rc.ReadEncM2(address) speed1 = rc.ReadSpeedM1(address) speed2 = rc.ReadSpeedM2(address) print("Encoder1:"), if (enc1[0] == 1): print enc1[1], print format(enc1[2], '02x'), else: print "failed", print "Encoder2:", if (enc2[0] == 1): print enc2[1], print format(enc2[2], '02x'), else: print "failed ",
from roboclaw import Roboclaw try: # if on win32 or linux from serial import SerialException, Serial as UART except ImportError: try: # try CircuitPython from board import UART except ImportError: try: # try MicroPythom from roboclaw.usart_serial_ctx import SerialUART as UART # Windows comport name # rc = Roboclaw(UART("COM3", 115200)) # Linux comport name # rc = Roboclaw(UART("/dev/ttyACM0", 115200)) # if CircuitPython or MicroPythom rc = Roboclaw(UART(), address=0x80) def displayspeed(): enc1 = rc.read_encoder_m1() enc2 = rc.read_encoder_m2() speed1 = rc.read_speed_m1() speed2 = rc.read_speed_m2() print("Encoder1:") if enc1[0] == 1: print(enc1[1]) print(format(enc1[2], '02x')) else: print("failed") print("Encoder2:")