You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.6 KiB
Python

3 years ago
from pathlib import Path, PurePath
import click
import yaml
# OPTIONS
config_option = click.option(
'-c',
'--config',
default=PurePath(Path(__file__).parent, Path('odrive.yaml')),
type=Path,
help='A config file for the odrive. Defaults to odrive.yaml.'
)
@click.group()
def cli():
pass
@cli.command('configure')
@config_option
def configure(**options):
"""Configures an Odrive with a provided .yaml file of config values."""
config_file = options['config']
if not config_file.is_file():
raise FileNotFoundError(f'No config file {config_file} found.')
print(options['config'])
class RoboWheelConfig:
"""
Class for configuring an Odrive axis.
"""
# Motor KV
KV_RATING = 10.0
# min/max phase inductance of motor
MIN_PHASE_INDUCTANCE = 0.0 # ?
MAX_PHASE_INDUCTANCE = 0.001 # ?
# Min/Max phase resistance of motor
MIN_PHASE_RESISTANCE = 0.0 # ?
MAX_PHASE_RESISTANCE = 2.5 # ? I think my motor is 1.7 ohm...
ENCODER_PULSE_PER_REV = 3200.0
ENCODER_COUNT_PER_REV = ENCODER_PULSE_PER_REV * 4
# Number of magnets in the motor divided by 2
POLE_PAIR_COUNT = 27.0
# See https://docs.odriverobotics.com/hoverboard
RESISTANCE_CALIB_MAX_VOLTAGE = 4.0 # HB motors are larger with more resistance so he doubled the 2.0 default
REQUESTED_CURRENT_RANGE = 25.0 # lower values are more sensitive default was 60
CURRENT_CONTROL_BANDWIDTH = 100.0 # Motors are also high inductance so the bandwidth to 100 from the default 1000
TORQUE_CONSTANT = 8.27 / KV_RATING
if __name__ == "__main__":
cli()