Skip to content

Commit

Permalink
always set calibration current before calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
yconst committed May 3, 2024
1 parent 54d0023 commit 84d7af9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
3 changes: 0 additions & 3 deletions studio/Python/tests/test_amt22.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def test_a_position_control_before_after_save_and_load_config(self):
self.configure_sensors(self.tm.sensors.setup.external_spi.type.AMT22)
self.select_sensors(self.tm.sensors.select.position_sensor.connection.ONBOARD, self.tm.sensors.select.position_sensor.connection.EXTERNAL_SPI)

self.tm.motor.I_cal = 1.0

self.try_calibrate()

self.tm.controller.position.p_gain = 9
Expand Down Expand Up @@ -118,7 +116,6 @@ def test_b_position_control_following_sensor_change(self):
# Initially configure with external SPI sensor
self.configure_sensors(self.tm.sensors.setup.external_spi.type.AMT22)
self.select_sensors(self.tm.sensors.select.position_sensor.connection.ONBOARD, self.tm.sensors.select.position_sensor.connection.EXTERNAL_SPI)
self.tm.motor.I_cal = 1.0
self.try_calibrate()

# Set initial controller gains
Expand Down
5 changes: 0 additions & 5 deletions studio/Python/tests/test_as5047.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def test_a_position_control_before_after_save_and_load_config(self):
self.configure_sensors(self.tm.sensors.setup.external_spi.type.AS5047)
self.select_sensors(self.tm.sensors.select.position_sensor.connection.ONBOARD, self.tm.sensors.select.position_sensor.connection.EXTERNAL_SPI)

self.tm.motor.I_cal = 0.8

self.try_calibrate()

self.tm.controller.position.p_gain = 9
Expand Down Expand Up @@ -117,7 +115,6 @@ def test_b_position_control_following_sensor_change(self):
# Initially configure with external SPI sensor
self.configure_sensors(self.tm.sensors.setup.external_spi.type.AS5047)
self.select_sensors(self.tm.sensors.select.position_sensor.connection.ONBOARD, self.tm.sensors.select.position_sensor.connection.EXTERNAL_SPI)
self.tm.motor.I_cal = 0.8
self.try_calibrate()

# Set initial controller gains
Expand Down Expand Up @@ -179,8 +176,6 @@ def test_c_position_control_change_baud_rates(self):
self.configure_sensors(self.tm.sensors.setup.external_spi.type.AS5047)
self.select_sensors(self.tm.sensors.select.position_sensor.connection.ONBOARD, self.tm.sensors.select.position_sensor.connection.EXTERNAL_SPI)

self.tm.motor.I_cal = 0.8

self.try_calibrate()

self.tm.controller.position.p_gain = 9
Expand Down
4 changes: 0 additions & 4 deletions studio/Python/tests/test_base_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ def test_position_control(self):
"""
hw_rev = self.tm.hw_revision
self.check_state(0)
if hw_rev > 20:
self.tm.motor.I_cal = 0.8
else:
self.tm.motor.I_cal = 5
self.tm.controller.current.Iq_limit = 5
self.try_calibrate()
self.tm.controller.position_mode()
Expand Down
1 change: 0 additions & 1 deletion studio/Python/tests/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ def test_j_gimbal_mode(self):
# Ensure we're idle
self.check_state(0)
self.tm.motor.type = 1 # gimbal
self.tm.motor.I_cal = 5.0
self.tm.motor.R = 0.2
self.tm.motor.L = 20 * 1e-5
self.try_calibrate()
Expand Down
14 changes: 13 additions & 1 deletion studio/Python/tests/tm_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,20 @@ def reset_and_wait(cls, timeout=0.5):
cls.tm.reset()
time.sleep(timeout)

def try_calibrate(self, force=False, precheck_callback=None, *args, **kwargs):
def try_calibrate(self, I_cal=None, force=False, precheck_callback=None,*args, **kwargs):
if True == force or not self.tm.calibrated:
hw_rev = self.tm.hw_revision
self.check_state(0)
if I_cal and I_cal > 0:
self.tm.motor.I_cal = I_cal
elif hw_rev > 20:
self.tm.motor.I_cal = 0.8
else:
self.tm.motor.I_cal = 5

if hw_rev > 20:
self.tm.controller.velocity.P_gain = 2e-05

self.tm.controller.calibrate()
self.wait_for_calibration(*args, **kwargs)
if precheck_callback:
Expand Down

0 comments on commit 84d7af9

Please sign in to comment.