moteus 0.3.54__py3-none-any.whl → 0.3.56__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
@@ -754,9 +754,13 @@ class Stream:
754
754
  if await self.is_config_supported("motor.unwrapped_position_scale"):
755
755
  unwrapped_position_scale = \
756
756
  await self.read_config_double("motor.unwrapped_position_scale")
757
+ motor_output_sign = 1.0
757
758
  elif await self.is_config_supported("motor_position.rotor_to_output_ratio"):
758
759
  unwrapped_position_scale = \
759
760
  await self.read_config_double("motor_position.rotor_to_output_ratio")
761
+ motor_output_sign = \
762
+ await self.read_config_double("motor_position.output.sign")
763
+
760
764
 
761
765
  if await self.is_config_supported("servo.pwm_rate_hz"):
762
766
  pwm_rate_hz = await self.read_config_double("servo.pwm_rate_hz")
@@ -820,7 +824,7 @@ class Stream:
820
824
  await self.check_for_fault()
821
825
 
822
826
  v_per_hz = await self.calibrate_kv_rating(
823
- input_V, unwrapped_position_scale)
827
+ input_V, unwrapped_position_scale, motor_output_sign)
824
828
  await self.check_for_fault()
825
829
 
826
830
  # Rezero the servo since we just spun it a lot.
@@ -852,7 +856,8 @@ class Stream:
852
856
  # We measure voltage to the center, not peak-to-peak, thus
853
857
  # the extra 0.5.
854
858
  'kv' : (0.5 * 60.0 / v_per_hz),
855
- 'unwrapped_position_scale' : unwrapped_position_scale
859
+ 'unwrapped_position_scale' : unwrapped_position_scale,
860
+ 'motor_position_output_sign' : motor_output_sign,
856
861
  }
857
862
 
858
863
  log_filename = f"moteus-cal-{device_info['serial_number']}-{now.strftime('%Y%m%dT%H%M%S.%f')}.log"
@@ -1306,40 +1311,54 @@ class Stream:
1306
1311
  print()
1307
1312
  return maybe_result
1308
1313
 
1309
- async def calibrate_kv_rating(self, input_V, unwrapped_position_scale):
1310
- print("Calculating Kv rating")
1314
+ async def calibrate_kv_rating(self, input_V, unwrapped_position_scale,
1315
+ motor_output_sign):
1316
+ if self.args.cal_force_kv is None:
1317
+ print("Calculating Kv rating")
1318
+
1319
+ await self.ensure_valid_theta(self.encoder_cal_voltage)
1311
1320
 
1312
- await self.ensure_valid_theta(self.encoder_cal_voltage)
1321
+ original_position_min = await self.read_config_double("servopos.position_min")
1322
+ original_position_max = await self.read_config_double("servopos.position_max")
1313
1323
 
1314
- original_position_min = await self.read_config_double("servopos.position_min")
1315
- original_position_max = await self.read_config_double("servopos.position_max")
1324
+ await self.command("conf set servopos.position_min NaN")
1325
+ await self.command("conf set servopos.position_max NaN")
1326
+ await self.command("d index 0")
1316
1327
 
1317
- await self.command("conf set servopos.position_min NaN")
1318
- await self.command("conf set servopos.position_max NaN")
1319
- await self.command("d index 0")
1328
+ kv_cal_voltage = await self.find_kv_cal_voltage(input_V, unwrapped_position_scale)
1329
+ await self.stop_and_idle()
1320
1330
 
1321
- kv_cal_voltage = await self.find_kv_cal_voltage(input_V, unwrapped_position_scale)
1322
- await self.stop_and_idle()
1331
+ voltages = [x * kv_cal_voltage for x in [
1332
+ 0.0, 0.25, 0.5, 0.75, 1.0 ]]
1333
+ speed_hzs = [ await self.find_speed_and_print(voltage, sleep_time=2)
1334
+ for voltage in voltages]
1323
1335
 
1324
- voltages = [x * kv_cal_voltage for x in [
1325
- 0.0, 0.25, 0.5, 0.75, 1.0 ]]
1326
- speed_hzs = [ await self.find_speed_and_print(voltage, sleep_time=2)
1327
- for voltage in voltages]
1336
+ await self.stop_and_idle()
1328
1337
 
1329
- await self.stop_and_idle()
1338
+ await asyncio.sleep(0.5)
1330
1339
 
1331
- await asyncio.sleep(0.5)
1340
+ geared_v_per_hz = 1.0 / _calculate_slope(voltages, speed_hzs)
1332
1341
 
1333
- geared_v_per_hz = 1.0 / _calculate_slope(voltages, speed_hzs)
1342
+ v_per_hz = (geared_v_per_hz *
1343
+ unwrapped_position_scale *
1344
+ motor_output_sign)
1345
+ print(f"v_per_hz (pre-gearbox)={v_per_hz}")
1334
1346
 
1335
- v_per_hz = geared_v_per_hz * unwrapped_position_scale
1336
- print(f"v_per_hz (pre-gearbox)={v_per_hz}")
1347
+ await self.command(f"conf set servopos.position_min {original_position_min}")
1348
+ await self.command(f"conf set servopos.position_max {original_position_max}")
1349
+
1350
+ if v_per_hz < 0.0:
1351
+ raise RuntimeError(
1352
+ f"v_per_hz measured as negative ({v_per_hz}), something wrong")
1353
+ else:
1354
+ v_per_hz = (0.5 * 60 / self.args.cal_force_kv)
1355
+ print(f"Using forced Kv: {self.args.cal_force_kv} v_per_hz={v_per_hz}")
1337
1356
 
1338
1357
  if not self.args.cal_no_update:
1339
1358
  await self.command(f"conf set motor.v_per_hz {v_per_hz}")
1340
1359
 
1341
- await self.command(f"conf set servopos.position_min {original_position_min}")
1342
- await self.command(f"conf set servopos.position_max {original_position_max}")
1360
+ if v_per_hz < 0:
1361
+ raise RuntimeError(f'v_per_hz value ({v_per_hz}) is negative')
1343
1362
 
1344
1363
  return v_per_hz
1345
1364
 
@@ -1623,6 +1642,9 @@ async def async_main():
1623
1642
  parser.add_argument('--cal-motor-poles', metavar='N', type=int,
1624
1643
  default=None,
1625
1644
  help='number of motor poles (2x pole pairs)')
1645
+ parser.add_argument('--cal-force-kv', metavar='Kv', type=float,
1646
+ default=None,
1647
+ help='do not calibrate Kv, but use the specified value')
1626
1648
 
1627
1649
 
1628
1650
  parser.add_argument('--cal-max-remainder', metavar='F',
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.54"
15
+ VERSION="0.3.56"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: moteus
3
- Version: 0.3.54
3
+ Version: 0.3.56
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=YEtDNXX-TlkUSElsGVQoSYbGqcboneNEejZo06v8ZsI,1128
6
6
  moteus/export.py,sha256=dI8QjdqrcI3pi5fKfP25PwLvsIlVJ695x0ta0PVMKx8,1628
7
7
  moteus/fdcanusb.py,sha256=AMwqdvIRz4X9yA4qz8REuyFBfs3OcLcVqbGX28sEx4s,6729
8
8
  moteus/moteus.py,sha256=W-ADEI1uAHF0j5A3s1CINTUYpwjEgO-xPRQS15C9Ewg,43410
9
- moteus/moteus_tool.py,sha256=n7DTaO17qX1Tz4OjbJG8KS7OFTwISd9HvCAPig9MsBM,65158
9
+ moteus/moteus_tool.py,sha256=WPpXvLwD9bJaWZY8LVygzFrmT7diN0HXMVZ_nUSfp9k,66231
10
10
  moteus/multiplex.py,sha256=0Hs63pFZpl1y7ciTcwEeg8F2JDjlhrkb2FcfUbdox-g,9637
11
11
  moteus/posix_aioserial.py,sha256=3JFiY5p4dtC2ztg6N5SOffnNk9lNcjie02yjD3UlJWo,2971
12
12
  moteus/pythoncan.py,sha256=lawewmkd9zQuE-Z1LurmpFD2iSWATei65SZb42um_Vg,3309
@@ -14,10 +14,10 @@ moteus/reader.py,sha256=jGADQTmONSBMQ25I5AqXELLqil2TEha1KjraPdOsf78,11932
14
14
  moteus/regression.py,sha256=wpPlxAZ9nC9kfv0oX1K9W2AZNnBLbY8htAJz60SxIb8,1183
15
15
  moteus/router.py,sha256=k4Tf6hWtHSgzznmdnj4NySe84-y9feYRxGz0yTrJtoc,2043
16
16
  moteus/transport.py,sha256=3asI2A87eQDImLP74LNLtETaShQRiD9RuCjlxNY6AlE,1003
17
- moteus/version.py,sha256=jmm_-XvCr1X4UYMgpel9H6m6QGgp-Q9okhEFMeGSxRs,609
17
+ moteus/version.py,sha256=6IePxRuf-dHbF45uc1W5kTJba8U8rF7AWW44ngo7bEY,609
18
18
  moteus/win32_aioserial.py,sha256=SZsnoBWE0Uwo4ZZF8ALB1WNPRY9NiaCOBz6VfvVcnxA,1841
19
- moteus-0.3.54.dist-info/METADATA,sha256=vgKZ2vzI5vAuCnC_GYt7naPzRGZKHa2q8o5H6M_an6U,3417
20
- moteus-0.3.54.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
21
- moteus-0.3.54.dist-info/entry_points.txt,sha256=indCsEML1fmtWJU1WiV-d7UmmTaAMhyBLEc1iiKnexQ,57
22
- moteus-0.3.54.dist-info/top_level.txt,sha256=aZzmI_yecTaDrdSp29pTJuowaSQ9dlIZheQpshGg4YQ,7
23
- moteus-0.3.54.dist-info/RECORD,,
19
+ moteus-0.3.56.dist-info/METADATA,sha256=rztYCXjyhVOwKH0uVEQf7Xp2zuD6C0kexA4CXIMVUgo,3417
20
+ moteus-0.3.56.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
21
+ moteus-0.3.56.dist-info/entry_points.txt,sha256=indCsEML1fmtWJU1WiV-d7UmmTaAMhyBLEc1iiKnexQ,57
22
+ moteus-0.3.56.dist-info/top_level.txt,sha256=aZzmI_yecTaDrdSp29pTJuowaSQ9dlIZheQpshGg4YQ,7
23
+ moteus-0.3.56.dist-info/RECORD,,