mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-08-18 01:18:52 +08:00
[UNTESTED] start implementing sensorless test
This commit is contained in:
@@ -18,7 +18,7 @@ struct ControllerConfig_t {
|
||||
Motor_control_mode_t control_mode = CTRL_MODE_POSITION_CONTROL; //see: Motor_control_mode_t
|
||||
float pos_gain = 20.0f; // [(counts/s) / counts]
|
||||
float vel_gain = 5.0f / 10000.0f; // [A/(counts/s)]
|
||||
// float vel_gain = 15.0f / 200.0f, // [A/(rad/s)] <sensorless example>
|
||||
// float vel_gain = 5.0f / 200.0f, // [A/(rad/s)] <sensorless example>
|
||||
float vel_integrator_gain = 10.0f / 10000.0f; // [A/(counts/s * s)]
|
||||
float vel_limit = 20000.0f; // [counts/s]
|
||||
};
|
||||
|
||||
@@ -164,6 +164,9 @@ def get_max_rpm(axis_ctx: AxisTestContext):
|
||||
rated_rpm = min(base_speed_rpm, axis_ctx.yaml['encoder-max-rpm'])
|
||||
return rated_rpm
|
||||
|
||||
def get_sensorless_vel(axis_ctx: AxisTestContext, vel):
|
||||
return vel * 2 * math.pi / axis_ctx.yaml['encoder-cpr'] * axis_ctx.yaml['motor-pole-pairs']
|
||||
|
||||
class ODriveTest(ABC):
|
||||
"""
|
||||
Tests inheriting from this class get full ownership of the ODrive
|
||||
@@ -748,3 +751,17 @@ class TestAsciiProtocol(ODriveTest):
|
||||
odrv_ctx.handle.axis1.controller.set_pos_setpoint(0, 0, 0)
|
||||
request_state(odrv_ctx.axes[0], AXIS_STATE_IDLE)
|
||||
request_state(odrv_ctx.axes[1], AXIS_STATE_IDLE)
|
||||
|
||||
|
||||
class TestSensorlessControl(AxisTest):
|
||||
def run_test(self, axis_ctx: AxisTestContext, logger):
|
||||
odrv0.axis0.controller.config.vel_gain = 5 / get_sensorless_vel(axis_ctx, 10000)
|
||||
odrv0.axis0.controller.config.vel_integrator_gain = 10 / get_sensorless_vel(axis_ctx, 10000)
|
||||
target_vel = get_sensorless_vel(axis_ctx, 20000)
|
||||
axis_ctx.handle.controller.set_vel_setpoint(target_vel, 0)
|
||||
request_state(axis_ctx, AXIS_STATE_SENSORLESS_CONTROL)
|
||||
# wait for spinup
|
||||
time.sleep(2)
|
||||
test_assert_eq(odrv0.axis0.encoder.pll_vel, target_vel, range=2000)
|
||||
|
||||
request_state(axis_ctx, AXIS_STATE_IDLE)
|
||||
|
||||
@@ -88,6 +88,10 @@ else:
|
||||
all_tests.append(TestEncoderOffsetCalibration(pass_if_ready=True))
|
||||
|
||||
all_tests.append(TestAsciiProtocol())
|
||||
all_tests.append(TestSensorlessControl())
|
||||
|
||||
#all_tests.append(TestStepDirInput())
|
||||
#all_tests.append(TestPWMInput())
|
||||
|
||||
if test_rig_yaml['type'] == 'parallel':
|
||||
#all_tests.append(TestHighVelocity())
|
||||
|
||||
Reference in New Issue
Block a user