moteus 0.3.68__py3-none-any.whl → 0.3.69__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
@@ -305,6 +305,10 @@ def _round_nearest_4v(input_V):
305
305
  return round(input_V / 4) * 4
306
306
 
307
307
 
308
+ def _average(x):
309
+ return sum(x) / len(x)
310
+
311
+
308
312
  def expand_targets(targets):
309
313
  result = set()
310
314
 
@@ -1239,6 +1243,16 @@ class Stream:
1239
1243
  desired_encoder_bw_hz = min(
1240
1244
  desired_encoder_bw_hz, 2e-2 / inductance)
1241
1245
 
1246
+ # Also, limit the bandwidth for halls based on the number
1247
+ # of poles and the estimated calibration speed.
1248
+ if hall_output:
1249
+ max_pole_bandwidth_hz = (
1250
+ 0.5 * self.args.cal_motor_poles *
1251
+ self.args.cal_motor_speed)
1252
+ desired_encoder_bw_hz = min(
1253
+ desired_encoder_bw_hz, max_pole_bandwidth_hz)
1254
+
1255
+
1242
1256
  # And our bandwidth with the filter can be no larger than
1243
1257
  # 1/30th the control rate.
1244
1258
  encoder_bw_hz = min(control_rate_hz / 30, desired_encoder_bw_hz)
@@ -1308,32 +1322,42 @@ class Stream:
1308
1322
 
1309
1323
  start_time = time.time()
1310
1324
 
1325
+ SAMPLE_PERIOD_S = 0.02
1326
+ AVERAGE_PERIOD_S = 0.10
1327
+
1328
+ AVERAGE_COUNT = int(AVERAGE_PERIOD_S / SAMPLE_PERIOD_S)
1329
+
1311
1330
  def sign(x):
1312
1331
  return 1 if x >= 0 else -1
1313
1332
 
1314
- old_change = None
1315
- old_vel = None
1333
+ velocity_samples = []
1334
+
1316
1335
  while True:
1317
1336
  data = await self.read_servo_stats()
1318
- velocity = data.velocity
1337
+ velocity_samples.append(data.velocity)
1338
+
1339
+ if len(velocity_samples) > (3 * AVERAGE_COUNT):
1340
+ del velocity_samples[0]
1341
+
1342
+ recent_average = _average(velocity_samples[-AVERAGE_COUNT:])
1319
1343
 
1320
- # As a fallback, timeout after 1s of waiting.
1344
+ # As a fallback, timeout after a fixed amount of waiting.
1321
1345
  if (time.time() - start_time) > 2.0:
1322
- return velocity
1346
+ return recent_average
1323
1347
 
1324
- if abs(velocity) < 0.2:
1325
- return velocity
1348
+ if (len(velocity_samples) >= AVERAGE_COUNT and
1349
+ abs(recent_average) < 0.2):
1350
+ return recent_average
1326
1351
 
1327
- if old_vel is not None:
1328
- change = velocity - old_vel
1329
- if old_change is not None:
1330
- if sign(old_change) != sign(change):
1331
- return velocity
1332
- old_change = change
1352
+ if len(velocity_samples) == 3 * AVERAGE_COUNT:
1353
+ average_1 = _average(velocity_samples[:AVERAGE_COUNT])
1354
+ average_2 = _average(velocity_samples[AVERAGE_COUNT:2*AVERAGE_COUNT])
1355
+ average_3 = recent_average
1333
1356
 
1334
- old_vel = velocity
1357
+ if sign(average_3 - average_2) != sign(average_2 - average_1):
1358
+ return recent_average
1335
1359
 
1336
- await asyncio.sleep(0.1)
1360
+ await asyncio.sleep(SAMPLE_PERIOD_S)
1337
1361
 
1338
1362
  return velocity
1339
1363
 
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.68"
15
+ VERSION="0.3.69"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: moteus
3
- Version: 0.3.68
3
+ Version: 0.3.69
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=vRIfldaqz1eHtWo3993SvatATtu73TZbejL0hzQe8YE,1646
7
7
  moteus/fdcanusb.py,sha256=7PrQiCTROY96gdT2zSZYU1bOCriw-I7H6NspaZpiEx4,7431
8
8
  moteus/moteus.py,sha256=2x5i-4BpTwS3Uo9FWyWesR--acIO8TJb0wCQHbuKuxQ,48131
9
- moteus/moteus_tool.py,sha256=PbQjd4t4gtLHs7vRrjMpajOoKVezAefDBuKR5CAvHiw,69211
9
+ moteus/moteus_tool.py,sha256=ccrvAVdxRZEnheALvAgbR7mDrlU90Ses3kj1kfEsVfI,70167
10
10
  moteus/multiplex.py,sha256=LF6MuelzYHqqsCJuCB9YeEyUA03eBaTYRwAVotX3qm8,10120
11
11
  moteus/posix_aioserial.py,sha256=2oDrw8TBEwuEQjY41g9rHeuFeffcPHqMwNS3nf5NVq8,3137
12
12
  moteus/pythoncan.py,sha256=ofotOrDuaFhTLvaokaO3EJK6quVc75Bq-ue70lDMtXI,4071
@@ -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=8rx1YUinZCom0pzbiJ3IcLDXrj5FEja3M79tr75nJJM,627
17
+ moteus/version.py,sha256=FEYQhXwueAJ_XxxIiWQCnSdWVFCa2egsxksGzbElp7g,627
18
18
  moteus/win32_aioserial.py,sha256=culdl-vYxBKD5n2s5LkIMGyUaHyCcEc8BL5-DWEaxX8,2025
19
- moteus-0.3.68.dist-info/METADATA,sha256=1fNB-NxqLjIjL2hgDA2FD0aq3BLZnJrE7LgknXIMRfo,3372
20
- moteus-0.3.68.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
21
- moteus-0.3.68.dist-info/entry_points.txt,sha256=accRcwir_K8wCf7i3qHb5R6CPh5SiSgd5a1A92ibb9E,56
22
- moteus-0.3.68.dist-info/top_level.txt,sha256=aZzmI_yecTaDrdSp29pTJuowaSQ9dlIZheQpshGg4YQ,7
23
- moteus-0.3.68.dist-info/RECORD,,
19
+ moteus-0.3.69.dist-info/METADATA,sha256=TRwp5Wf0k3CPaiHBxmpm-URMuJ2lL5wlTWErGm6eXjg,3372
20
+ moteus-0.3.69.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
21
+ moteus-0.3.69.dist-info/entry_points.txt,sha256=accRcwir_K8wCf7i3qHb5R6CPh5SiSgd5a1A92ibb9E,56
22
+ moteus-0.3.69.dist-info/top_level.txt,sha256=aZzmI_yecTaDrdSp29pTJuowaSQ9dlIZheQpshGg4YQ,7
23
+ moteus-0.3.69.dist-info/RECORD,,