def __init__(self, name, serial_no):
     self.name = name
     self.serial_no = serial_no
     self.shutdown_token = Event()
     self.logger = Logger(verbose=False)
     self.device = None
     odrive.find_all("usb", self.serial_no,
                     lambda device: self.did_discover_device(device),
                     self.shutdown_token, self.shutdown_token, self.logger)
def main(app_shutdown_token):
    """
    !! Main program !!
    Looks for odrive, then calibrates, then sets gains, then tests motors


    WARNING: Saving more than twice per boot will cause a reversion of all changes
    """
    bare_bones_calibration(app_shutdown_token, reset=True)
    #bare_bones_calibration(app_shutdown_token, reset=False)

import odrive
from fibre import Logger, Event
from odrive.utils import OperationAbortedException
from fibre.protocol import ChannelBrokenException

app_shutdown_token = Event()
try:
    main(app_shutdown_token)
    # init_odrive(odrv0)
except OperationAbortedException:
    logger.info("Operation aborted.")
finally:
    app_shutdown_token.set()

# encoder calibration
# set use_index ot true
# request encoder_index_search
# pre_calibrated to True
# then change startup to encoder_index_search true
Example #3
0
#!/usr/bin/python3
import sys
from fibre import Logger, Event
import odrive

sys.stderr.write("ODrive test (using odrive lib version " +
                 odrive.__version__ + ")\n")

app_shutdown_token = Event()

my_odrive = odrive.find_any(path="usb:003:030",
                            serial_number=None,
                            search_cancellation_token=app_shutdown_token,
                            channel_termination_token=app_shutdown_token)
#print(my_odrive._remote_attributes.items())
print("serial: {}".format(my_odrive.serial_number))
print("encoders pos: {} {}".format(my_odrive.axis0.encoder.pos_estimate,
                                   my_odrive.axis1.encoder.pos_estimate))
print("encoders vel: {} {}".format(my_odrive.axis0.encoder.vel_estimate,
                                   my_odrive.axis1.encoder.vel_estimate))