From fb7cabef5b54c96deea5f479f9a8c09260a4816b Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Fri, 29 May 2020 10:24:36 +0200 Subject: [PATCH] make all other interfaces children of ODrive --- Firmware/MotorControl/axis.hpp | 2 +- Firmware/MotorControl/controller.hpp | 2 +- Firmware/MotorControl/encoder.hpp | 2 +- Firmware/MotorControl/motor.hpp | 2 +- .../MotorControl/sensorless_estimator.hpp | 2 +- Firmware/odrive-interface.yaml | 28 +++++++++---------- tools/odrive/enums.py | 26 ++++++++--------- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Firmware/MotorControl/axis.hpp b/Firmware/MotorControl/axis.hpp index 598da2a8..480de844 100644 --- a/Firmware/MotorControl/axis.hpp +++ b/Firmware/MotorControl/axis.hpp @@ -5,7 +5,7 @@ #error "This file should not be included directly. Include odrive_main.h instead." #endif -class Axis : public AxisIntf { +class Axis : public ODriveIntf::AxisIntf { public: struct LockinConfig_t { float current = 10.0f; // [A] diff --git a/Firmware/MotorControl/controller.hpp b/Firmware/MotorControl/controller.hpp index 66f2dbb1..be84d159 100644 --- a/Firmware/MotorControl/controller.hpp +++ b/Firmware/MotorControl/controller.hpp @@ -5,7 +5,7 @@ #error "This file should not be included directly. Include odrive_main.h instead." #endif -class Controller : public ControllerIntf { +class Controller : public ODriveIntf::ControllerIntf { public: typedef struct { uint32_t index = 0; diff --git a/Firmware/MotorControl/encoder.hpp b/Firmware/MotorControl/encoder.hpp index 77f40068..cb97a45b 100644 --- a/Firmware/MotorControl/encoder.hpp +++ b/Firmware/MotorControl/encoder.hpp @@ -5,7 +5,7 @@ #error "This file should not be included directly. Include odrive_main.h instead." #endif -class Encoder : public EncoderIntf { +class Encoder : public ODriveIntf::EncoderIntf { public: const uint32_t MODE_FLAG_ABS = 0x100; diff --git a/Firmware/MotorControl/motor.hpp b/Firmware/MotorControl/motor.hpp index a7e87139..6e449111 100644 --- a/Firmware/MotorControl/motor.hpp +++ b/Firmware/MotorControl/motor.hpp @@ -7,7 +7,7 @@ #include "drv8301.h" -class Motor : public MotorIntf { +class Motor : public ODriveIntf::MotorIntf { public: struct Iph_BC_t { float phB; diff --git a/Firmware/MotorControl/sensorless_estimator.hpp b/Firmware/MotorControl/sensorless_estimator.hpp index 99c339be..95992ae0 100644 --- a/Firmware/MotorControl/sensorless_estimator.hpp +++ b/Firmware/MotorControl/sensorless_estimator.hpp @@ -1,7 +1,7 @@ #ifndef __SENSORLESS_ESTIMATOR_HPP #define __SENSORLESS_ESTIMATOR_HPP -class SensorlessEstimator : public SensorlessEstimatorIntf { +class SensorlessEstimator : public ODriveIntf::SensorlessEstimatorIntf { public: struct Config_t { float observer_gain = 1000.0f; // [rad/s] diff --git a/Firmware/odrive-interface.yaml b/Firmware/odrive-interface.yaml index 36309b82..f17aca63 100644 --- a/Firmware/odrive-interface.yaml +++ b/Firmware/odrive-interface.yaml @@ -178,14 +178,14 @@ interfaces: functions: set_baud_rate: {in: {baudRate: uint32}} - Endpoint: + ODrive.Endpoint: c_is_class: False attributes: endpoint: endpoint_ref min: float32 max: float32 - Axis: + ODrive.Axis: c_is_class: True attributes: error: @@ -294,7 +294,7 @@ interfaces: clear_errors: doc: Check the watchdog timer for expiration. Also sets the watchdog error bit if expired. - Axis.LockinConfig: + ODrive.Axis.LockinConfig: c_is_class: False attributes: current: @@ -320,7 +320,7 @@ interfaces: finish_on_enc_idx: bool - Motor: + ODrive.Motor: c_is_class: True attributes: error: @@ -443,7 +443,7 @@ interfaces: acim_autoflux_decay_gain: float32 - Controller: + ODrive.Controller: c_is_class: True attributes: error: @@ -527,7 +527,7 @@ interfaces: start_anticogging_calibration: - Encoder: + ODrive.Encoder: c_is_class: True attributes: error: @@ -580,7 +580,7 @@ interfaces: set_linear_count: {in: {count: int32}} - SensorlessEstimator: + ODrive.SensorlessEstimator: c_is_class: True attributes: error: @@ -600,7 +600,7 @@ interfaces: pm_flux_linkage: float32 - TrapezoidalTrajectory: + ODrive.TrapezoidalTrajectory: c_is_class: True attributes: config: @@ -611,7 +611,7 @@ interfaces: decel_limit: float32 - Endstop: + ODrive.Endstop: c_is_class: True attributes: endstop_state: readonly bool @@ -630,7 +630,7 @@ valuetypes: ODrive.Can.Protocol: values: {Simple: } - Axis.AxisState: # TODO: remove redundant "Axis" in name + ODrive.Axis.AxisState: # TODO: remove redundant "Axis" in name values: Undefined: doc: will fall through to idle @@ -656,7 +656,7 @@ valuetypes: Homing: doc: run axis homing function - Encoder.Mode: + ODrive.Encoder.Mode: values: Incremental: Hall: @@ -671,7 +671,7 @@ valuetypes: value: 0x102 doc: not yet implemented - Controller.ControlMode: + ODrive.Controller.ControlMode: values: # Note: these should be sorted from lowest level of control to # highest level of control, to allow "<" style comparisons. @@ -680,7 +680,7 @@ valuetypes: VelocityControl: PositionControl: - Controller.InputMode: + ODrive.Controller.InputMode: values: Inactive: Passthrough: @@ -692,7 +692,7 @@ valuetypes: Mirror: - Motor.MotorType: + ODrive.Motor.MotorType: values: HighCurrent: #LowCurrent: # not implemented diff --git a/tools/odrive/enums.py b/tools/odrive/enums.py index 466f11b6..93a5cfe2 100644 --- a/tools/odrive/enums.py +++ b/tools/odrive/enums.py @@ -4,7 +4,7 @@ # ODrive.Can.Protocol PROTOCOL_SIMPLE = 0 -# Axis.AxisState +# ODrive.Axis.AxisState AXIS_STATE_UNDEFINED = 0 AXIS_STATE_IDLE = 1 AXIS_STATE_STARTUP_SEQUENCE = 2 @@ -18,7 +18,7 @@ AXIS_STATE_LOCKIN_SPIN = 9 AXIS_STATE_ENCODER_DIR_FIND = 10 AXIS_STATE_HOMING = 11 -# Encoder.Mode +# ODrive.Encoder.Mode ENCODER_MODE_INCREMENTAL = 0 ENCODER_MODE_HALL = 1 ENCODER_MODE_SINCOS = 2 @@ -26,13 +26,13 @@ ENCODER_MODE_SPI_ABS_CUI = 256 ENCODER_MODE_SPI_ABS_AMS = 257 ENCODER_MODE_SPI_ABS_AEAT = 258 -# Controller.ControlMode +# ODrive.Controller.ControlMode CONTROL_MODE_VOLTAGE_CONTROL = 0 CONTROL_MODE_CURRENT_CONTROL = 1 CONTROL_MODE_VELOCITY_CONTROL = 2 CONTROL_MODE_POSITION_CONTROL = 3 -# Controller.InputMode +# ODrive.Controller.InputMode INPUT_MODE_INACTIVE = 0 INPUT_MODE_PASSTHROUGH = 1 INPUT_MODE_VEL_RAMP = 2 @@ -42,7 +42,7 @@ INPUT_MODE_TRAP_TRAJ = 5 INPUT_MODE_CURRENT_RAMP = 6 INPUT_MODE_MIRROR = 7 -# Motor.MotorType +# ODrive.Motor.MotorType MOTOR_TYPE_HIGH_CURRENT = 0 MOTOR_TYPE_GIMBAL = 2 MOTOR_TYPE_ACIM = 3 @@ -51,7 +51,7 @@ MOTOR_TYPE_ACIM = 3 CAN_ERROR_NONE = 0x00000000 CAN_ERROR_DUPLICATE_CAN_IDS = 0x00000001 -# Axis.Error +# ODrive.Axis.Error AXIS_ERROR_NONE = 0x00000000 AXIS_ERROR_INVALID_STATE = 0x00000001 AXIS_ERROR_DC_BUS_UNDER_VOLTAGE = 0x00000002 @@ -70,13 +70,13 @@ AXIS_ERROR_MAX_ENDSTOP_PRESSED = 0x00002000 AXIS_ERROR_ESTOP_REQUESTED = 0x00004000 AXIS_ERROR_HOMING_WITHOUT_ENDSTOP = 0x00020000 -# Axis.LockinState +# ODrive.Axis.LockinState LOCKIN_STATE_INACTIVE = 0 LOCKIN_STATE_RAMP = 1 LOCKIN_STATE_ACCELERATE = 2 LOCKIN_STATE_CONST_VEL = 3 -# Motor.Error +# ODrive.Motor.Error MOTOR_ERROR_NONE = 0x00000000 MOTOR_ERROR_PHASE_RESISTANCE_OUT_OF_RANGE = 0x00000001 MOTOR_ERROR_PHASE_INDUCTANCE_OUT_OF_RANGE = 0x00000002 @@ -95,13 +95,13 @@ MOTOR_ERROR_BRAKE_DUTY_CYCLE_NAN = 0x00002000 MOTOR_ERROR_DC_BUS_OVER_REGEN_CURRENT = 0x00004000 MOTOR_ERROR_DC_BUS_OVER_CURRENT = 0x00008000 -# Motor.ArmedState +# ODrive.Motor.ArmedState ARMED_STATE_DISARMED = 0 ARMED_STATE_WAITING_FOR_TIMINGS = 1 ARMED_STATE_WAITING_FOR_UPDATE = 2 ARMED_STATE_ARMED = 3 -# Motor.GateDriver.DrvFault +# ODrive.Motor.GateDriver.DrvFault DRV_FAULT_NO_FAULT = 0x00000000 DRV_FAULT_FET_LOW_C_OVERCURRENT = 0x00000001 DRV_FAULT_FET_HIGH_C_OVERCURRENT = 0x00000002 @@ -115,7 +115,7 @@ DRV_FAULT_P_VDD_UNDERVOLTAGE = 0x00000100 DRV_FAULT_G_VDD_UNDERVOLTAGE = 0x00000200 DRV_FAULT_G_VDD_OVERVOLTAGE = 0x00000400 -# Controller.Error +# ODrive.Controller.Error CONTROLLER_ERROR_NONE = 0x00000000 CONTROLLER_ERROR_OVERSPEED = 0x00000001 CONTROLLER_ERROR_INVALID_INPUT_MODE = 0x00000002 @@ -124,7 +124,7 @@ CONTROLLER_ERROR_INVALID_MIRROR_AXIS = 0x00000008 CONTROLLER_ERROR_INVALID_LOAD_ENCODER = 0x00000010 CONTROLLER_ERROR_INVALID_ESTIMATE = 0x00000020 -# Encoder.Error +# ODrive.Encoder.Error ENCODER_ERROR_NONE = 0x00000000 ENCODER_ERROR_UNSTABLE_GAIN = 0x00000001 ENCODER_ERROR_CPR_POLEPAIRS_MISMATCH = 0x00000002 @@ -136,6 +136,6 @@ ENCODER_ERROR_ABS_SPI_TIMEOUT = 0x00000040 ENCODER_ERROR_ABS_SPI_COM_FAIL = 0x00000080 ENCODER_ERROR_ABS_SPI_NOT_READY = 0x00000100 -# SensorlessEstimator.Error +# ODrive.SensorlessEstimator.Error SENSORLESS_ESTIMATOR_ERROR_NONE = 0x00000000 SENSORLESS_ESTIMATOR_ERROR_UNSTABLE_GAIN = 0x00000001