moteus 0.3.84__py3-none-any.whl → 0.3.86__py3-none-any.whl

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.
moteus/moteus_tool.py CHANGED
@@ -1428,8 +1428,6 @@ class Stream:
1428
1428
  async def calibrate_encoder_mapping_absolute(
1429
1429
  self, encoder_cal_voltage, encoder_cal_current, current_noise,
1430
1430
  unwrapped_position_scale):
1431
- await self.ensure_valid_theta(encoder_cal_voltage)
1432
-
1433
1431
  current_quality_factor = encoder_cal_current / current_noise
1434
1432
  use_current_for_quality = (
1435
1433
  current_quality_factor > CURRENT_QUALITY_MIN or
@@ -1437,23 +1435,30 @@ class Stream:
1437
1435
  use_current_for_firmware_version = self.firmware.version >= 0x010a
1438
1436
 
1439
1437
  use_current_calibration = (
1440
- use_current_for_quality and use_current_for_firmware_version)
1438
+ not self.args.cal_never_encoder_current_mode and (
1439
+ use_current_for_quality and use_current_for_firmware_version))
1441
1440
 
1442
1441
  if use_current_for_firmware_version and not use_current_for_quality:
1443
1442
  print(f"Using voltage mode calibration, current quality factor {current_quality_factor:.1f} < {CURRENT_QUALITY_MIN:.1f}")
1444
1443
 
1445
-
1446
1444
  old_motor_poles = None
1447
1445
 
1448
1446
  if use_current_calibration:
1449
1447
  old_motor_poles = await self.read_config_int("motor.poles")
1450
1448
  await self.command("conf set motor.poles 2")
1449
+
1450
+ # We have to check for a valid there here, because setting
1451
+ # the motor pole count will invalidate it.
1452
+ await self.ensure_valid_theta(encoder_cal_voltage)
1453
+
1451
1454
  await self.command(f"d pos nan 0 nan c{encoder_cal_current} b1")
1452
1455
  await asyncio.sleep(3.0)
1453
1456
 
1454
1457
  await self.write_message(
1455
1458
  (f"d cali i{encoder_cal_current} s{self.args.cal_ll_encoder_speed * unwrapped_position_scale}"))
1456
1459
  else:
1460
+ await self.ensure_valid_theta(encoder_cal_voltage)
1461
+
1457
1462
  await self.command(f"d pwm 0 {encoder_cal_voltage}")
1458
1463
  await asyncio.sleep(3.0)
1459
1464
 
@@ -1717,6 +1722,10 @@ class Stream:
1717
1722
  # current on low resistance / low inductance motors.
1718
1723
  break
1719
1724
  await self.command("d stop")
1725
+
1726
+ # Give a little bit of wait in case we had an error that
1727
+ # the above stop should clear.
1728
+ await asyncio.sleep(0.1)
1720
1729
  except moteus.CommandError as e:
1721
1730
  # It is possible this is an old firmware that does not
1722
1731
  # support inductance measurement.
@@ -1831,7 +1840,7 @@ class Stream:
1831
1840
 
1832
1841
  return kp, ki, w_3db / twopi
1833
1842
 
1834
- async def find_speed(self, voltage, sleep_time=0.5):
1843
+ async def find_speed(self, voltage, unwrapped_position_scale, sleep_time=0.5):
1835
1844
  assert voltage < 20.0
1836
1845
  assert voltage >= 0.0
1837
1846
 
@@ -1864,7 +1873,7 @@ class Stream:
1864
1873
  if len(power_samples) > AVERAGE_COUNT:
1865
1874
  del power_samples[0]
1866
1875
 
1867
- velocity_samples.append(data.velocity)
1876
+ velocity_samples.append(data.velocity / unwrapped_position_scale)
1868
1877
 
1869
1878
  if len(velocity_samples) > (3 * AVERAGE_COUNT):
1870
1879
  del velocity_samples[0]
@@ -1909,8 +1918,8 @@ class Stream:
1909
1918
 
1910
1919
  return velocity
1911
1920
 
1912
- async def find_speed_and_print(self, voltage, **kwargs):
1913
- result = await self.find_speed(voltage, **kwargs)
1921
+ async def find_speed_and_print(self, voltage, unwrapped_position_scale, **kwargs):
1922
+ result = await self.find_speed(voltage, unwrapped_position_scale, **kwargs)
1914
1923
  print(f"{voltage:.3f}V - {result:.3f}Hz")
1915
1924
  return result
1916
1925
 
@@ -1930,7 +1939,7 @@ class Stream:
1930
1939
  if maybe_result > (0.2 * input_V):
1931
1940
  return maybe_result
1932
1941
 
1933
- this_speed = await self.find_speed(maybe_result) / unwrapped_position_scale
1942
+ this_speed = await self.find_speed(maybe_result, unwrapped_position_scale)
1934
1943
 
1935
1944
  if (abs(this_speed) > (0.1 * self.args.cal_motor_speed) and
1936
1945
  first_nonzero_speed_voltage is None):
@@ -1968,7 +1977,8 @@ class Stream:
1968
1977
  voltages = [x * kv_cal_voltage for x in [
1969
1978
  0.0, 0.25, 0.5, 0.75, 1.0 ]]
1970
1979
  voltage_speed_hzs = list(zip(
1971
- voltages, [ await self.find_speed_and_print(voltage, sleep_time=2)
1980
+ voltages, [ await self.find_speed_and_print(
1981
+ voltage, unwrapped_position_scale, sleep_time=2)
1972
1982
  for voltage in voltages]))
1973
1983
 
1974
1984
  await self.stop_and_idle()
@@ -1986,12 +1996,10 @@ class Stream:
1986
1996
  voltage_speed_hzs = [(v, s) for v, s in voltage_speed_hzs
1987
1997
  if abs(s) > speed_threshold]
1988
1998
 
1989
- geared_v_per_hz = 1.0 / _calculate_slope(
1999
+ v_per_hz = 1.0 / _calculate_slope(
1990
2000
  [x[0] for x in voltage_speed_hzs],
1991
2001
  [x[1] for x in voltage_speed_hzs])
1992
2002
 
1993
- v_per_hz = (geared_v_per_hz *
1994
- unwrapped_position_scale)
1995
2003
  if self.firmware.version <= 0x0106:
1996
2004
  v_per_hz *= motor_output_sign
1997
2005
 
@@ -2338,6 +2346,8 @@ async def async_main():
2338
2346
  help='write raw calibration data')
2339
2347
  parser.add_argument('--cal-force-encoder-current-mode', action='store_true',
2340
2348
  help='always use encoder current mode calibration if supported')
2349
+ parser.add_argument('--cal-never-encoder-current-mode', action='store_true',
2350
+ help='never use current mode calibration')
2341
2351
 
2342
2352
  args = parser.parse_args()
2343
2353
 
moteus/version.py CHANGED
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- VERSION="0.3.84"
15
+ VERSION="0.3.86"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: moteus
3
- Version: 0.3.84
3
+ Version: 0.3.86
4
4
  Summary: moteus brushless controller library and tools
5
5
  Home-page: https://github.com/mjbots/moteus
6
6
  Author: mjbots Robotic Systems
@@ -6,7 +6,7 @@ moteus/command.py,sha256=UkOsbtkso6Oyex8CfbpAKpBNriik519ymxL86EZGkRs,1169
6
6
  moteus/export.py,sha256=XitBUuf4MDRIneXQSUptizIhZi2BdHyFO2Vo_2d2CFI,1742
7
7
  moteus/fdcanusb.py,sha256=7PrQiCTROY96gdT2zSZYU1bOCriw-I7H6NspaZpiEx4,7431
8
8
  moteus/moteus.py,sha256=vImSRBn6VEmoijD6hvrSRVxuv1_xVaEJU3F_3Wi6GiE,52498
9
- moteus/moteus_tool.py,sha256=ocKUSl7qc_O1DOwoj5UFx1Kaw5HkRPEhU_e-tftfmk4,97236
9
+ moteus/moteus_tool.py,sha256=x5jhduF4miGaBkhnOYEFM8ljtSukI89m8NCkMF6UeAw,97848
10
10
  moteus/multiplex.py,sha256=2tdNX5JSh21TOjN6N9LKribLQtVYyyYbXjzwXB64sfA,12119
11
11
  moteus/posix_aioserial.py,sha256=2oDrw8TBEwuEQjY41g9rHeuFeffcPHqMwNS3nf5NVq8,3137
12
12
  moteus/pythoncan.py,sha256=M5Qba3aCzO_GyXcIsLJxjw3NrPgUk4CUnHOQIhQeIb0,4786
@@ -14,10 +14,10 @@ moteus/reader.py,sha256=9i1-h4aGd4syfqtWJcpg70Bl-bmunkGU4FmXmOLyRt8,12121
14
14
  moteus/regression.py,sha256=M5gjDBYJQ64iBXIrvBhMkD8TYhtlnQ85x8U4py0niGA,1196
15
15
  moteus/router.py,sha256=501W5GZ12rFoc1lmcH3S7IYsoc-Q_-FJ4B3i37RzE3Q,2061
16
16
  moteus/transport.py,sha256=WhkW2G9i25lkOlO55eI5_oXmU0PhDmxTeJ75Sg_7nTI,1021
17
- moteus/version.py,sha256=SIOoh1lHjcFFVldtp79E9rmBXUk63cDry1gjgxqOQ14,627
17
+ moteus/version.py,sha256=xB3AWW4PPnSUzd7MMXbwCcYTSWPZDqGWSabi_HYJyBU,627
18
18
  moteus/win32_aioserial.py,sha256=culdl-vYxBKD5n2s5LkIMGyUaHyCcEc8BL5-DWEaxX8,2025
19
- moteus-0.3.84.dist-info/METADATA,sha256=okhSG2P2nrnQPSoq_F4-4t79_4KVrRCOZat5etq3gAg,3441
20
- moteus-0.3.84.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
21
- moteus-0.3.84.dist-info/entry_points.txt,sha256=accRcwir_K8wCf7i3qHb5R6CPh5SiSgd5a1A92ibb9E,56
22
- moteus-0.3.84.dist-info/top_level.txt,sha256=aZzmI_yecTaDrdSp29pTJuowaSQ9dlIZheQpshGg4YQ,7
23
- moteus-0.3.84.dist-info/RECORD,,
19
+ moteus-0.3.86.dist-info/METADATA,sha256=lJ0MCEWlEIzJKtT0ba2izsy-Vn2oAU_PtJj4-SVOniw,3441
20
+ moteus-0.3.86.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
21
+ moteus-0.3.86.dist-info/entry_points.txt,sha256=accRcwir_K8wCf7i3qHb5R6CPh5SiSgd5a1A92ibb9E,56
22
+ moteus-0.3.86.dist-info/top_level.txt,sha256=aZzmI_yecTaDrdSp29pTJuowaSQ9dlIZheQpshGg4YQ,7
23
+ moteus-0.3.86.dist-info/RECORD,,