mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-08-21 06:23:07 +08:00
fix HWIL tests
This commit is contained in:
@@ -177,7 +177,7 @@ class TestRegenProtection(TestClosedLoopControlBase):
|
||||
max_current = 15.0
|
||||
|
||||
# Accept a bit of noise on Ibus
|
||||
axis_ctx.parent.handle.config.dc_max_negative_current = -0.2
|
||||
axis_ctx.parent.handle.config.dc_max_negative_current = -0.5
|
||||
|
||||
logger.debug(f'Brake control test from {nominal_rps} rounds/s...')
|
||||
|
||||
@@ -227,6 +227,7 @@ class TestVelLimitInTorqueControl(TestClosedLoopControlBase):
|
||||
|
||||
axis_ctx.handle.controller.config.vel_gain /= 10 # reduce the slope to make it easier to see what's going on
|
||||
vel_gain = axis_ctx.handle.controller.config.vel_gain
|
||||
direction = axis_ctx.handle.motor.config.direction
|
||||
logger.debug(f'vel gain is {vel_gain}')
|
||||
|
||||
axis_ctx.handle.controller.config.vel_limit = max_vel
|
||||
@@ -237,7 +238,7 @@ class TestVelLimitInTorqueControl(TestClosedLoopControlBase):
|
||||
|
||||
# Returns the expected limited setpoint for a given velocity and current
|
||||
def get_expected_setpoint(input_setpoint, velocity):
|
||||
return clamp(clamp(input_setpoint / torque_constant, (velocity + max_vel) * -vel_gain / torque_constant, (velocity - max_vel) * -vel_gain / torque_constant), -max_current, max_current)
|
||||
return clamp(clamp(input_setpoint / torque_constant, (velocity + max_vel) * -vel_gain / torque_constant, (velocity - max_vel) * -vel_gain / torque_constant), -max_current, max_current) * direction
|
||||
|
||||
def data_getter():
|
||||
# sample velocity twice to avoid systematic bias
|
||||
|
||||
@@ -105,7 +105,7 @@ class TestUartAscii():
|
||||
ser.write(b'c 0 12.5\n')
|
||||
test_assert_eq(ser.readline(), b'')
|
||||
test_assert_eq(odrive.handle.axis0.controller.input_torque, 12.5, accuracy=0.001)
|
||||
test_assert_eq(odrive.handle.axis0.controller.config.control_mode, CONTROL_MODE_CURRENT_CONTROL)
|
||||
test_assert_eq(odrive.handle.axis0.controller.config.control_mode, CONTROL_MODE_TORQUE_CONTROL)
|
||||
|
||||
odrive.handle.axis0.controller.input_vel = 0
|
||||
odrive.handle.axis0.controller.input_torque = 0
|
||||
@@ -132,7 +132,7 @@ class TestUartAscii():
|
||||
test_assert_eq(ser.readline(), b'')
|
||||
test_assert_eq(odrive.handle.axis0.controller.input_pos, 123.4, accuracy=0.001)
|
||||
test_assert_eq(odrive.handle.axis0.controller.config.vel_limit, 567.8, accuracy=0.001)
|
||||
test_assert_eq(odrive.handle.axis0.motor.config.current_lim, 12.5, accuracy=0.001)
|
||||
test_assert_eq(odrive.handle.axis0.motor.config.torque_lim, 12.5, accuracy=0.001)
|
||||
test_assert_eq(odrive.handle.axis0.controller.config.control_mode, CONTROL_MODE_POSITION_CONTROL)
|
||||
|
||||
ser.write(b'f 0\n')
|
||||
|
||||
Reference in New Issue
Block a user