tinymovr 2.2.2a1__tar.gz → 2.2.3a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/PKG-INFO +1 -1
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/dfu.py +3 -2
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr.egg-info/PKG-INFO +1 -1
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr.egg-info/SOURCES.txt +0 -4
- tinymovr-2.2.2a1/tests/test_amt22.py +0 -159
- tinymovr-2.2.2a1/tests/test_as5047.py +0 -210
- tinymovr-2.2.2a1/tests/test_board_config.py +0 -167
- tinymovr-2.2.2a1/tests/test_hall.py +0 -105
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/MANIFEST.in +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/README.md +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/pyproject.toml +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/setup.cfg +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/setup.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tests/test_board.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tests/test_dfu.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tests/test_homing.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tests/test_rates.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tests/test_simulation.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tests/test_traj_planner.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tests/test_watchdog.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/__init__.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/bus_manager.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/bus_router.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/channel.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/cli.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/codec/__init__.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/codec/codec.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/config/__init__.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/config/config.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/constants.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/device_discovery.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/gui/__init__.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/gui/gui.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/gui/helpers.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/gui/widgets.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/gui/window.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/gui/worker.py +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/resources/icons/app_icon.png +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/resources/icons/call.png +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/resources/icons/call@2x.png +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/resources/icons/call_dark.png +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/resources/icons/call_dark@2x.png +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/resources/icons/empty.png +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/resources/icons/empty@2x.png +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/resources/icons/empty_dark.png +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/resources/icons/empty_dark@2x.png +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/specs/dfu_1_0_x.yaml +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/specs/dfu_1_1_x.yaml +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/specs/tinymovr_1_3_x.yaml +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/specs/tinymovr_1_4_x.yaml +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/specs/tinymovr_1_5_x.yaml +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/specs/tinymovr_1_6_x.yaml +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/specs/tinymovr_2_0_x.yaml +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr/specs/tinymovr_2_1_x.yaml +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr.egg-info/dependency_links.txt +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr.egg-info/entry_points.txt +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr.egg-info/requires.txt +0 -0
- {tinymovr-2.2.2a1 → tinymovr-2.2.3a1}/tinymovr.egg-info/top_level.txt +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Usage:
|
|
3
|
-
dfu.py --node_id=ID [--bin=PATH | --recovery] [--no-reset] [--bus=<bus>] [--chan=<chan>] [--bitrate=<bitrate>]
|
|
3
|
+
dfu.py --node_id=ID [--bin=PATH | --recovery] [--no-reset] [--force] [--bus=<bus>] [--chan=<chan>] [--bitrate=<bitrate>]
|
|
4
4
|
|
|
5
5
|
Options:
|
|
6
6
|
--node_id=ID The CAN Node ID of the device in DFU mode.
|
|
7
7
|
--bin=PATH The path of the .bin file to upload.
|
|
8
8
|
--recovery Perform recovery procedure for inaccessible DFU bootloader.
|
|
9
9
|
--no-reset Do not perform a reset following successful flashing.
|
|
10
|
+
--force Force flashing even if device memory matches the .bin file.
|
|
10
11
|
--bus=<bus> One or more interfaces to use, first available is used [default: canine,slcan_disco].
|
|
11
12
|
--chan=<chan> The bus device "channel".
|
|
12
13
|
--bitrate=<bitrate> CAN bitrate [default: 1000000].
|
|
@@ -181,7 +182,7 @@ def spawn():
|
|
|
181
182
|
|
|
182
183
|
# If an existing .bin file is specified, upload it to the device
|
|
183
184
|
elif bin_path:
|
|
184
|
-
if compare_bin_w_device(device, bin_path):
|
|
185
|
+
if (not arguments["--force"]) and compare_bin_w_device(device, bin_path):
|
|
185
186
|
print("\nDevice memory matches the .bin file. Skipping flashing.")
|
|
186
187
|
else:
|
|
187
188
|
upload_bin(device, bin_path)
|
|
@@ -2,12 +2,8 @@ MANIFEST.in
|
|
|
2
2
|
README.md
|
|
3
3
|
pyproject.toml
|
|
4
4
|
setup.py
|
|
5
|
-
tests/test_amt22.py
|
|
6
|
-
tests/test_as5047.py
|
|
7
5
|
tests/test_board.py
|
|
8
|
-
tests/test_board_config.py
|
|
9
6
|
tests/test_dfu.py
|
|
10
|
-
tests/test_hall.py
|
|
11
7
|
tests/test_homing.py
|
|
12
8
|
tests/test_rates.py
|
|
13
9
|
tests/test_simulation.py
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Tinymovr Board Config Tests
|
|
3
|
-
Copyright Ioannis Chatzikonstantinou 2020-2023
|
|
4
|
-
|
|
5
|
-
Tests saving and loading Tinymovr configuration to/from NVRAM.
|
|
6
|
-
|
|
7
|
-
This program is free software: you can redistribute it and/or modify it under
|
|
8
|
-
the terms of the GNU General Public License as published by the Free Software
|
|
9
|
-
Foundation, either version 3 of the License, or (at your option) any later
|
|
10
|
-
version.
|
|
11
|
-
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12
|
-
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13
|
-
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
14
|
-
You should have received a copy of the GNU General Public License along with
|
|
15
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
import random
|
|
19
|
-
import time
|
|
20
|
-
|
|
21
|
-
from avlos.unit_field import get_registry
|
|
22
|
-
|
|
23
|
-
import unittest
|
|
24
|
-
import pytest
|
|
25
|
-
from tests import TMTestCase
|
|
26
|
-
|
|
27
|
-
ureg = get_registry()
|
|
28
|
-
A = ureg.ampere
|
|
29
|
-
tick = ureg.ticks
|
|
30
|
-
s = ureg.second
|
|
31
|
-
tsleep = 0.80
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class TestAMT22(TMTestCase):
|
|
35
|
-
|
|
36
|
-
@pytest.mark.sensor_amt22
|
|
37
|
-
def test_a_position_control_before_after_save_and_load_config(self):
|
|
38
|
-
"""
|
|
39
|
-
Test position control after saving and loading config.
|
|
40
|
-
WARNING: This will perform one NVRAM write and two erase cycles.
|
|
41
|
-
"""
|
|
42
|
-
self.check_state(0)
|
|
43
|
-
self.tm.erase_config()
|
|
44
|
-
time.sleep(0.2)
|
|
45
|
-
|
|
46
|
-
self.configure_sensors(self.tm.sensors.setup.external_spi.type.AMT22)
|
|
47
|
-
self.select_sensors(self.tm.sensors.select.position_sensor.connection.ONBOARD, self.tm.sensors.select.position_sensor.connection.EXTERNAL_SPI)
|
|
48
|
-
|
|
49
|
-
self.try_calibrate()
|
|
50
|
-
|
|
51
|
-
self.tm.controller.position.p_gain = 9
|
|
52
|
-
self.tm.controller.velocity.p_gain = 3e-5
|
|
53
|
-
self.tm.controller.velocity.i_gain = 0
|
|
54
|
-
self.tm.controller.velocity.limit = 200000
|
|
55
|
-
|
|
56
|
-
self.tm.controller.position_mode()
|
|
57
|
-
self.check_state(2)
|
|
58
|
-
|
|
59
|
-
for _ in range(10):
|
|
60
|
-
new_pos = random.uniform(-1000, 1000)
|
|
61
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
62
|
-
time.sleep(tsleep)
|
|
63
|
-
self.assertAlmostEqual(
|
|
64
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
65
|
-
self.tm.controller.position.setpoint,
|
|
66
|
-
delta=200 * tick,
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
self.tm.controller.idle()
|
|
70
|
-
|
|
71
|
-
time.sleep(0.1)
|
|
72
|
-
|
|
73
|
-
self.tm.save_config()
|
|
74
|
-
|
|
75
|
-
time.sleep(0.2)
|
|
76
|
-
|
|
77
|
-
self.reset_and_wait()
|
|
78
|
-
|
|
79
|
-
self.tm.controller.position_mode()
|
|
80
|
-
self.check_state(2)
|
|
81
|
-
|
|
82
|
-
for _ in range(10):
|
|
83
|
-
new_pos = random.uniform(-1000, 1000)
|
|
84
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
85
|
-
time.sleep(tsleep)
|
|
86
|
-
self.assertAlmostEqual(
|
|
87
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
88
|
-
self.tm.controller.position.setpoint,
|
|
89
|
-
delta=200 * tick,
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
self.tm.erase_config()
|
|
93
|
-
time.sleep(0.2)
|
|
94
|
-
|
|
95
|
-
@pytest.mark.sensor_amt22
|
|
96
|
-
def test_b_position_control_following_sensor_change(self):
|
|
97
|
-
"""
|
|
98
|
-
Test position control before and after changing sensor connection and type.
|
|
99
|
-
This test will alter the sensor configuration from an external SPI connection
|
|
100
|
-
to an onboard connection, and verify if the position control maintains accuracy.
|
|
101
|
-
"""
|
|
102
|
-
self.check_state(0)
|
|
103
|
-
self.tm.erase_config()
|
|
104
|
-
time.sleep(0.2)
|
|
105
|
-
|
|
106
|
-
# Initially configure with external SPI sensor
|
|
107
|
-
self.configure_sensors(self.tm.sensors.setup.external_spi.type.AMT22)
|
|
108
|
-
self.select_sensors(self.tm.sensors.select.position_sensor.connection.ONBOARD, self.tm.sensors.select.position_sensor.connection.EXTERNAL_SPI)
|
|
109
|
-
self.try_calibrate()
|
|
110
|
-
|
|
111
|
-
# Set initial controller gains
|
|
112
|
-
self.tm.controller.position.p_gain = 9
|
|
113
|
-
self.tm.controller.velocity.p_gain = 3e-5
|
|
114
|
-
self.tm.controller.velocity.i_gain = 0
|
|
115
|
-
self.tm.controller.velocity.limit = 200000
|
|
116
|
-
|
|
117
|
-
# Start with external SPI sensor
|
|
118
|
-
self.tm.controller.position_mode()
|
|
119
|
-
self.check_state(2)
|
|
120
|
-
|
|
121
|
-
for _ in range(5):
|
|
122
|
-
new_pos = random.uniform(-1000, 1000)
|
|
123
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
124
|
-
time.sleep(tsleep)
|
|
125
|
-
self.assertAlmostEqual(
|
|
126
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
127
|
-
self.tm.controller.position.setpoint,
|
|
128
|
-
delta=200 * tick,
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
self.tm.controller.idle()
|
|
132
|
-
time.sleep(0.1)
|
|
133
|
-
|
|
134
|
-
# Change to onboard sensor
|
|
135
|
-
self.select_sensors(self.tm.sensors.select.position_sensor.connection.ONBOARD, self.tm.sensors.select.position_sensor.connection.ONBOARD)
|
|
136
|
-
|
|
137
|
-
# Re-calibrate with new sensor setup
|
|
138
|
-
self.try_calibrate()
|
|
139
|
-
time.sleep(0.1)
|
|
140
|
-
|
|
141
|
-
self.tm.controller.position_mode()
|
|
142
|
-
self.check_state(2)
|
|
143
|
-
|
|
144
|
-
for _ in range(5):
|
|
145
|
-
new_pos = random.uniform(-10000, 10000)
|
|
146
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
147
|
-
time.sleep(tsleep)
|
|
148
|
-
self.assertAlmostEqual(
|
|
149
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
150
|
-
self.tm.controller.position.setpoint,
|
|
151
|
-
delta=2000 * tick,
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
self.tm.erase_config()
|
|
155
|
-
time.sleep(0.2)
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if __name__ == "__main__":
|
|
159
|
-
unittest.main()
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Tinymovr Board Config Tests
|
|
3
|
-
Copyright Ioannis Chatzikonstantinou 2020-2023
|
|
4
|
-
|
|
5
|
-
Tests saving and loading Tinymovr configuration to/from NVRAM.
|
|
6
|
-
|
|
7
|
-
This program is free software: you can redistribute it and/or modify it under
|
|
8
|
-
the terms of the GNU General Public License as published by the Free Software
|
|
9
|
-
Foundation, either version 3 of the License, or (at your option) any later
|
|
10
|
-
version.
|
|
11
|
-
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12
|
-
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13
|
-
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
14
|
-
You should have received a copy of the GNU General Public License along with
|
|
15
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
import random
|
|
19
|
-
import time
|
|
20
|
-
|
|
21
|
-
from avlos.unit_field import get_registry
|
|
22
|
-
|
|
23
|
-
import unittest
|
|
24
|
-
import pytest
|
|
25
|
-
from tests import TMTestCase
|
|
26
|
-
|
|
27
|
-
ureg = get_registry()
|
|
28
|
-
A = ureg.ampere
|
|
29
|
-
tick = ureg.ticks
|
|
30
|
-
s = ureg.second
|
|
31
|
-
tsleep = 0.50
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class TestAS5047(TMTestCase):
|
|
35
|
-
|
|
36
|
-
@pytest.mark.sensor_as5047
|
|
37
|
-
def test_a_position_control_before_after_save_and_load_config(self):
|
|
38
|
-
"""
|
|
39
|
-
Test position control after saving and loading config.
|
|
40
|
-
WARNING: This will perform one NVRAM write and two erase cycles.
|
|
41
|
-
"""
|
|
42
|
-
self.check_state(0)
|
|
43
|
-
self.tm.erase_config()
|
|
44
|
-
time.sleep(0.2)
|
|
45
|
-
|
|
46
|
-
self.configure_sensors(self.tm.sensors.setup.external_spi.type.AS5047)
|
|
47
|
-
self.select_sensors(self.tm.sensors.select.position_sensor.connection.ONBOARD, self.tm.sensors.select.position_sensor.connection.EXTERNAL_SPI)
|
|
48
|
-
|
|
49
|
-
self.try_calibrate()
|
|
50
|
-
|
|
51
|
-
self.tm.controller.position.p_gain = 9
|
|
52
|
-
self.tm.controller.velocity.p_gain = 2e-5
|
|
53
|
-
self.tm.controller.velocity.i_gain = 0
|
|
54
|
-
|
|
55
|
-
self.tm.controller.position_mode()
|
|
56
|
-
self.check_state(2)
|
|
57
|
-
|
|
58
|
-
for _ in range(10):
|
|
59
|
-
new_pos = random.uniform(-20000, 20000)
|
|
60
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
61
|
-
time.sleep(tsleep)
|
|
62
|
-
self.assertAlmostEqual(
|
|
63
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
64
|
-
self.tm.controller.position.setpoint,
|
|
65
|
-
delta=2000 * tick,
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
self.tm.controller.idle()
|
|
69
|
-
|
|
70
|
-
time.sleep(0.1)
|
|
71
|
-
|
|
72
|
-
self.tm.save_config()
|
|
73
|
-
|
|
74
|
-
time.sleep(0.2)
|
|
75
|
-
|
|
76
|
-
self.reset_and_wait()
|
|
77
|
-
|
|
78
|
-
self.tm.controller.position_mode()
|
|
79
|
-
self.check_state(2)
|
|
80
|
-
|
|
81
|
-
for _ in range(10):
|
|
82
|
-
new_pos = random.uniform(-20000, 20000)
|
|
83
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
84
|
-
time.sleep(tsleep)
|
|
85
|
-
self.assertAlmostEqual(
|
|
86
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
87
|
-
self.tm.controller.position.setpoint,
|
|
88
|
-
delta=2000 * tick,
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
self.tm.erase_config()
|
|
92
|
-
time.sleep(0.2)
|
|
93
|
-
|
|
94
|
-
@pytest.mark.sensor_as5047
|
|
95
|
-
def test_b_position_control_following_sensor_change(self):
|
|
96
|
-
"""
|
|
97
|
-
Test position control before and after changing sensor connection and type.
|
|
98
|
-
This test will alter the sensor configuration from an external SPI connection
|
|
99
|
-
to an onboard connection, and verify if the position control maintains accuracy.
|
|
100
|
-
"""
|
|
101
|
-
self.check_state(0)
|
|
102
|
-
self.tm.erase_config()
|
|
103
|
-
time.sleep(0.2)
|
|
104
|
-
|
|
105
|
-
# Initially configure with external SPI sensor
|
|
106
|
-
self.configure_sensors(self.tm.sensors.setup.external_spi.type.AS5047)
|
|
107
|
-
self.select_sensors(self.tm.sensors.select.position_sensor.connection.ONBOARD, self.tm.sensors.select.position_sensor.connection.EXTERNAL_SPI)
|
|
108
|
-
self.try_calibrate()
|
|
109
|
-
|
|
110
|
-
# Set initial controller gains
|
|
111
|
-
self.tm.controller.position.p_gain = 9
|
|
112
|
-
self.tm.controller.velocity.p_gain = 3e-5
|
|
113
|
-
self.tm.controller.velocity.i_gain = 0
|
|
114
|
-
self.tm.controller.velocity.limit = 200000
|
|
115
|
-
|
|
116
|
-
# Start with external SPI sensor
|
|
117
|
-
self.tm.controller.position_mode()
|
|
118
|
-
self.check_state(2)
|
|
119
|
-
|
|
120
|
-
for _ in range(5):
|
|
121
|
-
new_pos = random.uniform(-20000, 20000)
|
|
122
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
123
|
-
time.sleep(tsleep)
|
|
124
|
-
self.assertAlmostEqual(
|
|
125
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
126
|
-
self.tm.controller.position.setpoint,
|
|
127
|
-
delta=2000 * tick,
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
self.tm.controller.idle()
|
|
131
|
-
time.sleep(0.1)
|
|
132
|
-
|
|
133
|
-
# Change to onboard sensor
|
|
134
|
-
self.select_sensors(self.tm.sensors.select.position_sensor.connection.ONBOARD, self.tm.sensors.select.position_sensor.connection.ONBOARD)
|
|
135
|
-
|
|
136
|
-
# Re-calibrate with new sensor setup
|
|
137
|
-
self.try_calibrate()
|
|
138
|
-
time.sleep(0.1)
|
|
139
|
-
|
|
140
|
-
self.tm.controller.position_mode()
|
|
141
|
-
self.check_state(2)
|
|
142
|
-
|
|
143
|
-
for _ in range(5):
|
|
144
|
-
new_pos = random.uniform(-20000, 20000)
|
|
145
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
146
|
-
time.sleep(tsleep)
|
|
147
|
-
self.assertAlmostEqual(
|
|
148
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
149
|
-
self.tm.controller.position.setpoint,
|
|
150
|
-
delta=2000 * tick,
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
self.tm.erase_config()
|
|
154
|
-
time.sleep(0.2)
|
|
155
|
-
|
|
156
|
-
@pytest.mark.sensor_as5047
|
|
157
|
-
def test_c_position_control_change_baud_rates(self):
|
|
158
|
-
"""
|
|
159
|
-
Test position control with external sensor and
|
|
160
|
-
different baud rates.
|
|
161
|
-
"""
|
|
162
|
-
self.check_state(0)
|
|
163
|
-
self.tm.erase_config()
|
|
164
|
-
time.sleep(0.2)
|
|
165
|
-
|
|
166
|
-
self.configure_sensors(self.tm.sensors.setup.external_spi.type.AS5047)
|
|
167
|
-
self.select_sensors(self.tm.sensors.select.position_sensor.connection.ONBOARD, self.tm.sensors.select.position_sensor.connection.EXTERNAL_SPI)
|
|
168
|
-
|
|
169
|
-
self.try_calibrate()
|
|
170
|
-
|
|
171
|
-
self.tm.controller.position.p_gain = 9
|
|
172
|
-
self.tm.controller.velocity.p_gain = 2e-5
|
|
173
|
-
self.tm.controller.velocity.i_gain = 0
|
|
174
|
-
|
|
175
|
-
self.tm.controller.position_mode()
|
|
176
|
-
self.check_state(2)
|
|
177
|
-
|
|
178
|
-
for _ in range(10):
|
|
179
|
-
new_pos = random.uniform(-20000, 20000)
|
|
180
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
181
|
-
time.sleep(tsleep)
|
|
182
|
-
self.assertAlmostEqual(
|
|
183
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
184
|
-
self.tm.controller.position.setpoint,
|
|
185
|
-
delta=2000 * tick,
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
self.tm.controller.idle()
|
|
189
|
-
|
|
190
|
-
self.tm.sensors.setup.external_spi.rate = "1_5Mbps"
|
|
191
|
-
time.sleep(0.1)
|
|
192
|
-
|
|
193
|
-
self.tm.controller.position_mode()
|
|
194
|
-
self.check_state(2)
|
|
195
|
-
|
|
196
|
-
for _ in range(10):
|
|
197
|
-
new_pos = random.uniform(-20000, 20000)
|
|
198
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
199
|
-
time.sleep(tsleep)
|
|
200
|
-
self.assertAlmostEqual(
|
|
201
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
202
|
-
self.tm.controller.position.setpoint,
|
|
203
|
-
delta=2000 * tick,
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
self.tm.controller.idle()
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if __name__ == "__main__":
|
|
210
|
-
unittest.main()
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Tinymovr Board Config Tests
|
|
3
|
-
Copyright Ioannis Chatzikonstantinou 2020-2023
|
|
4
|
-
|
|
5
|
-
Tests saving and loading Tinymovr configuration to/from NVRAM.
|
|
6
|
-
|
|
7
|
-
This program is free software: you can redistribute it and/or modify it under
|
|
8
|
-
the terms of the GNU General Public License as published by the Free Software
|
|
9
|
-
Foundation, either version 3 of the License, or (at your option) any later
|
|
10
|
-
version.
|
|
11
|
-
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12
|
-
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13
|
-
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
14
|
-
You should have received a copy of the GNU General Public License along with
|
|
15
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
import random
|
|
19
|
-
import time
|
|
20
|
-
|
|
21
|
-
from avlos.unit_field import get_registry
|
|
22
|
-
|
|
23
|
-
import unittest
|
|
24
|
-
from tests import TMTestCase
|
|
25
|
-
|
|
26
|
-
ureg = get_registry()
|
|
27
|
-
A = ureg.ampere
|
|
28
|
-
tick = ureg.ticks
|
|
29
|
-
s = ureg.second
|
|
30
|
-
tsleep = 0.20
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class TestBoardConfig(TMTestCase):
|
|
34
|
-
def test_a_state_errors(self):
|
|
35
|
-
"""
|
|
36
|
-
Test state transitions
|
|
37
|
-
WARNING: This may perform one NVRAM erase cycle.
|
|
38
|
-
"""
|
|
39
|
-
if self.tm.motor.calibrated:
|
|
40
|
-
self.tm.erase_config()
|
|
41
|
-
time.sleep(0.2)
|
|
42
|
-
|
|
43
|
-
self.reset_and_wait()
|
|
44
|
-
self.check_state(0)
|
|
45
|
-
self.assertEqual(self.tm.motor.calibrated, False)
|
|
46
|
-
self.tm.controller.position_mode()
|
|
47
|
-
self.check_state(0)
|
|
48
|
-
self.reset_and_wait()
|
|
49
|
-
self.check_state(0)
|
|
50
|
-
self.assertEqual(self.tm.motor.calibrated, False)
|
|
51
|
-
self.try_calibrate()
|
|
52
|
-
self.assertEqual(self.tm.motor.calibrated, True)
|
|
53
|
-
self.check_state(0)
|
|
54
|
-
time.sleep(0.2)
|
|
55
|
-
self.tm.controller.position_mode()
|
|
56
|
-
self.check_state(2)
|
|
57
|
-
time.sleep(0.2)
|
|
58
|
-
self.tm.controller.calibrate()
|
|
59
|
-
self.check_state(0)
|
|
60
|
-
|
|
61
|
-
self.reset_and_wait()
|
|
62
|
-
|
|
63
|
-
def test_b_save_load_config(self):
|
|
64
|
-
"""
|
|
65
|
-
Test erasing, saving and loading of config.
|
|
66
|
-
WARNING: This will perform one NVRAM write and two erase cycles.
|
|
67
|
-
"""
|
|
68
|
-
self.check_state(0)
|
|
69
|
-
self.tm.erase_config()
|
|
70
|
-
time.sleep(0.2)
|
|
71
|
-
self.assertEqual(self.tm.motor.calibrated, False)
|
|
72
|
-
self.try_calibrate()
|
|
73
|
-
self.assertEqual(self.tm.motor.calibrated, True)
|
|
74
|
-
R = self.tm.motor.R
|
|
75
|
-
L = self.tm.motor.L
|
|
76
|
-
pole_pairs = self.tm.motor.pole_pairs
|
|
77
|
-
self.tm.save_config()
|
|
78
|
-
time.sleep(0.2)
|
|
79
|
-
self.reset_and_wait()
|
|
80
|
-
self.assertEqual(self.tm.motor.calibrated, True)
|
|
81
|
-
self.assertAlmostEqual(R, self.tm.motor.R)
|
|
82
|
-
self.assertAlmostEqual(L, self.tm.motor.L)
|
|
83
|
-
self.assertAlmostEqual(pole_pairs, self.tm.motor.pole_pairs)
|
|
84
|
-
self.tm.erase_config()
|
|
85
|
-
time.sleep(0.2)
|
|
86
|
-
|
|
87
|
-
def test_c_parameter_persistence(self):
|
|
88
|
-
"""
|
|
89
|
-
Test persisting parameters across config saves.
|
|
90
|
-
WARNING: This will perform one NVRAM write and two erase cycles.
|
|
91
|
-
"""
|
|
92
|
-
self.check_state(0)
|
|
93
|
-
self.tm.erase_config()
|
|
94
|
-
time.sleep(0.2)
|
|
95
|
-
|
|
96
|
-
self.tm.controller.position.p_gain = 30
|
|
97
|
-
self.tm.controller.velocity.p_gain = 3e-5
|
|
98
|
-
self.tm.controller.velocity.i_gain = 2e-2
|
|
99
|
-
self.tm.controller.velocity.deadband = 100
|
|
100
|
-
self.tm.controller.velocity.limit = 120000
|
|
101
|
-
self.tm.controller.current.Iq_limit = 18
|
|
102
|
-
self.tm.save_config()
|
|
103
|
-
|
|
104
|
-
time.sleep(0.2)
|
|
105
|
-
self.reset_and_wait()
|
|
106
|
-
self.assertAlmostEqual(self.tm.controller.position.p_gain, 30) # * 1 / s
|
|
107
|
-
self.assertAlmostEqual(self.tm.controller.velocity.p_gain, 3e-5) # * A * s / tick
|
|
108
|
-
self.assertAlmostEqual(self.tm.controller.velocity.i_gain, 2e-2) # * A * s / tick
|
|
109
|
-
self.assertAlmostEqual(self.tm.controller.velocity.deadband, 100 * tick)
|
|
110
|
-
self.assertAlmostEqual(self.tm.controller.velocity.limit, 120000 * tick / s)
|
|
111
|
-
self.assertAlmostEqual(self.tm.controller.current.Iq_limit, 18 * A)
|
|
112
|
-
self.tm.erase_config()
|
|
113
|
-
time.sleep(0.2)
|
|
114
|
-
|
|
115
|
-
def test_d_position_control_w_loaded_config(self):
|
|
116
|
-
"""
|
|
117
|
-
Test position control after saving and loading config.
|
|
118
|
-
WARNING: This will perform one NVRAM write and two erase cycles.
|
|
119
|
-
"""
|
|
120
|
-
self.check_state(0)
|
|
121
|
-
self.tm.erase_config()
|
|
122
|
-
time.sleep(0.2)
|
|
123
|
-
|
|
124
|
-
self.try_calibrate()
|
|
125
|
-
|
|
126
|
-
self.tm.controller.position_mode()
|
|
127
|
-
self.check_state(2)
|
|
128
|
-
|
|
129
|
-
for _ in range(15):
|
|
130
|
-
new_pos = random.uniform(-24000, 24000)
|
|
131
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
132
|
-
time.sleep(tsleep)
|
|
133
|
-
self.assertAlmostEqual(
|
|
134
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
135
|
-
self.tm.controller.position.setpoint,
|
|
136
|
-
delta=2000 * tick,
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
self.tm.controller.idle()
|
|
140
|
-
|
|
141
|
-
time.sleep(0.1)
|
|
142
|
-
|
|
143
|
-
self.tm.save_config()
|
|
144
|
-
|
|
145
|
-
time.sleep(0.2)
|
|
146
|
-
|
|
147
|
-
self.reset_and_wait()
|
|
148
|
-
|
|
149
|
-
self.tm.controller.position_mode()
|
|
150
|
-
self.check_state(2)
|
|
151
|
-
|
|
152
|
-
for _ in range(15):
|
|
153
|
-
new_pos = random.uniform(-24000, 24000)
|
|
154
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
155
|
-
time.sleep(tsleep)
|
|
156
|
-
self.assertAlmostEqual(
|
|
157
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
158
|
-
self.tm.controller.position.setpoint,
|
|
159
|
-
delta=2000 * tick,
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
self.tm.erase_config()
|
|
163
|
-
time.sleep(0.2)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if __name__ == "__main__":
|
|
167
|
-
unittest.main()
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Tinymovr Board Config Tests
|
|
3
|
-
Copyright Ioannis Chatzikonstantinou 2020-2023
|
|
4
|
-
|
|
5
|
-
Tests saving and loading Tinymovr configuration to/from NVRAM.
|
|
6
|
-
|
|
7
|
-
This program is free software: you can redistribute it and/or modify it under
|
|
8
|
-
the terms of the GNU General Public License as published by the Free Software
|
|
9
|
-
Foundation, either version 3 of the License, or (at your option) any later
|
|
10
|
-
version.
|
|
11
|
-
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12
|
-
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13
|
-
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
14
|
-
You should have received a copy of the GNU General Public License along with
|
|
15
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
import random
|
|
19
|
-
import time
|
|
20
|
-
|
|
21
|
-
from avlos.unit_field import get_registry
|
|
22
|
-
|
|
23
|
-
import unittest
|
|
24
|
-
import pytest
|
|
25
|
-
from tests import TMTestCase
|
|
26
|
-
|
|
27
|
-
ureg = get_registry()
|
|
28
|
-
A = ureg.ampere
|
|
29
|
-
tick = ureg.ticks
|
|
30
|
-
s = ureg.second
|
|
31
|
-
tsleep = 1.00
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def set_pole_pairs(tm):
|
|
35
|
-
tm.motor.pole_pairs = 15
|
|
36
|
-
|
|
37
|
-
class TestHall(TMTestCase):
|
|
38
|
-
|
|
39
|
-
@pytest.mark.sensor_hall
|
|
40
|
-
def test_a_position_control_w_loaded_config(self):
|
|
41
|
-
"""
|
|
42
|
-
Test position control after saving and loading config.
|
|
43
|
-
WARNING: This will perform one NVRAM write and two erase cycles.
|
|
44
|
-
"""
|
|
45
|
-
self.check_state(0)
|
|
46
|
-
self.tm.erase_config()
|
|
47
|
-
time.sleep(0.2)
|
|
48
|
-
|
|
49
|
-
self.tm.sensors.select.position_sensor.connection = self.tm.sensors.select.position_sensor.connection.HALL
|
|
50
|
-
self.tm.sensors.select.commutation_sensor.connection = self.tm.sensors.select.commutation_sensor.connection.HALL
|
|
51
|
-
# Commutation sensor remains internal
|
|
52
|
-
|
|
53
|
-
self.tm.sensors.select.position_sensor.bandwidth = 50;
|
|
54
|
-
self.tm.sensors.select.commutation_sensor.bandwidth = 80;
|
|
55
|
-
time.sleep(0.2)
|
|
56
|
-
|
|
57
|
-
self.try_calibrate(precheck_callback=set_pole_pairs)
|
|
58
|
-
|
|
59
|
-
self.tm.controller.position.p_gain = 15
|
|
60
|
-
self.tm.controller.velocity.limit = 400000
|
|
61
|
-
self.tm.controller.velocity.p_gain = 1e-5
|
|
62
|
-
self.tm.controller.velocity.i_gain = 0
|
|
63
|
-
|
|
64
|
-
self.tm.controller.position_mode()
|
|
65
|
-
self.check_state(2)
|
|
66
|
-
|
|
67
|
-
for _ in range(5):
|
|
68
|
-
new_pos = random.uniform(-200000, 200000)
|
|
69
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
70
|
-
time.sleep(tsleep)
|
|
71
|
-
self.assertAlmostEqual(
|
|
72
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
73
|
-
self.tm.controller.position.setpoint,
|
|
74
|
-
delta=30000 * tick,
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
self.tm.controller.idle()
|
|
78
|
-
|
|
79
|
-
time.sleep(0.1)
|
|
80
|
-
|
|
81
|
-
self.tm.save_config()
|
|
82
|
-
|
|
83
|
-
time.sleep(0.2)
|
|
84
|
-
|
|
85
|
-
self.reset_and_wait()
|
|
86
|
-
|
|
87
|
-
self.tm.controller.position_mode()
|
|
88
|
-
self.check_state(2)
|
|
89
|
-
|
|
90
|
-
for _ in range(10):
|
|
91
|
-
new_pos = random.uniform(-200000, 200000)
|
|
92
|
-
self.tm.controller.position.setpoint = new_pos * tick
|
|
93
|
-
time.sleep(tsleep)
|
|
94
|
-
self.assertAlmostEqual(
|
|
95
|
-
self.tm.sensors.user_frame.position_estimate,
|
|
96
|
-
self.tm.controller.position.setpoint,
|
|
97
|
-
delta=30000 * tick,
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
self.tm.erase_config()
|
|
101
|
-
time.sleep(0.2)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if __name__ == "__main__":
|
|
105
|
-
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|