Beispiel #1
0
    def find_controllers(self):

        addressList = [0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87]

        controller_dictionary = {}
        speed_factors = {}
        counter = 0
        for i in range(0, 20):
            rc = Roboclaw(self.baseStr + str(i), self.rate)
            if rc.Open() == 0:
                for a in addressList:
                    if rc.GetConfig(a) != (0, 0):
                        controller_dictionary[a] = rc
                        speed_factors[a] = [1, 1, 1]
                        counter += 1
                        break
            if counter == 3:
                break
        return controller_dictionary, speed_factors
from roboclaw import Roboclaw

rc = Roboclaw("/dev/ttyS3", 115200)
rc.Open()
rc.ReadVersion(0x80)

# This is the old API, use the new one below. rc.SetMinVoltageMainBattery(0x80, 110) # 11 Volts
rc.ReadMinMaxMainVoltages(0x80)
rc.SetMainVoltages(0x80, 110, 340)  # Allowed range: 11 V - 34 V
rc.SetM1MaxCurrent(0x80, 500)  # 5 Amps
rc.SetPWMMode(0x80, 0)  # Locked Antiphase
#rc.ReadPWMMode(0x80)
rc.SetM1EncoderMode(0x80, 0)  # No RC/Analog support + Quadrature encoder
#rc.ReadEncoderModes(0x80)

getConfig = rc.GetConfig(0x80)
config = getConfig[1]  # index zero is 1 for success, 0 for failure.
config = config | 0x0003  # Packet serial mode
config = config | 0x8000  # Multi-Unit mode
rc.SetConfig(0x80, config)

rc.SetPinFunctions(0x80, 2, 0, 0)  # S3 = E-Stop, S4 = Disabled, S5 = Disabled

rc.WriteNVM(0x80)

rc.ReadEncM1(0x80)
rc.ResetEncoders(0x80)
rc.ReadEncM1(0x80)

p = 15000
i = 1000