summaryrefslogtreecommitdiffhomepage
path: root/digital/mimot
diff options
context:
space:
mode:
authorNicolas Schodet2012-03-28 19:34:17 +0200
committerNicolas Schodet2012-03-28 19:35:45 +0200
commit52de9864646b18b364fea06561bfe283f835f217 (patch)
tree22d8cb7f8ffcf0401209152badb4f13f64c198c5 /digital/mimot
parent9ef4e173c5f6b6f4822d6b03befe3af9cdc9dc51 (diff)
digital/asserv, digital/mimot: use human readable parameters
Diffstat (limited to 'digital/mimot')
-rw-r--r--digital/mimot/tools/mimot/init.py28
-rw-r--r--digital/mimot/tools/mimot/mimot.py45
2 files changed, 40 insertions, 33 deletions
diff --git a/digital/mimot/tools/mimot/init.py b/digital/mimot/tools/mimot/init.py
index 87e00642..5dbe1a87 100644
--- a/digital/mimot/tools/mimot/init.py
+++ b/digital/mimot/tools/mimot/init.py
@@ -1,21 +1,21 @@
"""Default parameters for asserv."""
target_marcel = dict (
- a0kp = 4,
- a0a = 16, a0sm = 0x60, a0ss = 0x10,
- a0be = 256, a0bs = 0x18, a0bc = 5,
- a1kp = 4,
- a1a = 16, a1sm = 0x60, a1ss = 0x10,
- a1be = 256, a1bs = 0x18, a1bc = 5,
- E = 0x3ff, D = 0x1ff,
+ a0_kp = 4,
+ a0_acc = 16, a0_speed_max = 0x60, a0_speed_slow = 0x10,
+ a0_error_limit = 256, a0_bd_speed_limit = 0x18, a0_bd_counter_limit = 5,
+ a1_kp = 4,
+ a1_acc = 16, a1_speed_max = 0x60, a1_speed_slow = 0x10,
+ a1_error_limit = 256, a1_bd_speed_limit = 0x18, a1_bd_counter_limit = 5,
+ e_sat = 0x3ff, d_sat = 0x1ff,
)
target_robospierre = dict (
- a0kp = 8, a0kd = 1,
- a0a = 2, a0sm = 0x60, a0ss = 0x10,
- a0be = 32, a0bs = 0x08, a0bc = 125,
- a1kp = 4,
- a1a = 0.5, a1sm = 0x30, a1ss = 0x08,
- a1be = 64, a1bs = 0x08, a1bc = 5,
- E = 0x3ff, D = 0x1ff,
+ a0_kp = 8, a0_kd = 1,
+ a0_acc = 2, a0_speed_max = 0x60, a0_speed_slow = 0x10,
+ a0_error_limit = 32, a0_bd_speed_limit = 0x08, a0_bd_counter_limit = 125,
+ a1_kp = 4,
+ a1_acc = 0.5, a1_speed_max = 0x30, a1_speed_slow = 0x08,
+ a1_error_limit = 64, a1_bd_speed_limit = 0x08, a1_bd_counter_limit = 5,
+ e_sat = 0x3ff, d_sat = 0x1ff,
)
target = {
'marcel': target_marcel,
diff --git a/digital/mimot/tools/mimot/mimot.py b/digital/mimot/tools/mimot/mimot.py
index 013a85ff..98101eb8 100644
--- a/digital/mimot/tools/mimot/mimot.py
+++ b/digital/mimot/tools/mimot/mimot.py
@@ -71,14 +71,15 @@ class Proto:
self.proto.register (s, f, make_handle (s))
self.stats_enabled = None
self.param = dict (
- a0kp = 0, a0ki = 0, a0kd = 0,
- a0a = 1, a0sm = 0, a0ss = 0,
- a0be = 2048, a0bs = 0x10, a0bc = 20,
- a1kp = 0, a1ki = 0, a1kd = 0,
- a1a = 1, a1sm = 0, a1ss = 0,
- a1be = 2048, a1bs = 0x10, a1bc = 20,
- E = 1023, I = 1023, D = 1023,
- w = 0x00,
+ a0_kp = 0, a0_ki = 0, a0_kd = 0,
+ a0_acc = 1, a0_speed_max = 0, a0_speed_slow = 0,
+ a0_bd_error_limit = 2048, a0_bd_speed_limit = 0x10, a0_bd_counter_limit = 20,
+ a0_reverse = False,
+ a1_kp = 0, a1_ki = 0, a1_kd = 0,
+ a1_acc = 1, a1_speed_max = 0, a1_speed_slow = 0,
+ a1_bd_error_limit = 2048, a1_bd_speed_limit = 0x10, a1_bd_counter_limit = 20,
+ a1_reverse = False,
+ e_sat = 1023, i_sat = 1023, d_sat = 1023,
)
self.param.update (param)
self.send_param ()
@@ -169,17 +170,23 @@ class Proto:
return int (round (x * (1 << 8)))
for m in ('a0', 'a1'):
index = self._index [m]
- self.proto.send ('p', 'cBH', 'p', index, f88 (p[m + 'kp']))
- self.proto.send ('p', 'cBH', 'i', index, f88 (p[m + 'ki']))
- self.proto.send ('p', 'cBH', 'd', index, f88 (p[m + 'kd']))
- self.proto.send ('p', 'cBH', 'a', index, f88 (p[m + 'a']))
- self.proto.send ('p', 'cBBB', 's', index, p[m + 'sm'], p[m + 'ss'])
- self.proto.send ('p', 'cBHHB', 'b', index, p[m + 'be'],
- p[m + 'bs'], p[m + 'bc'])
- self.proto.send ('p', 'cH', 'E', p['E'])
- self.proto.send ('p', 'cH', 'I', p['I'])
- self.proto.send ('p', 'cH', 'D', p['D'])
- self.proto.send ('p', 'cB', 'w', p['w'])
+ self.proto.send ('p', 'cBH', 'p', index, f88 (p[m + '_kp']))
+ self.proto.send ('p', 'cBH', 'i', index, f88 (p[m + '_ki']))
+ self.proto.send ('p', 'cBH', 'd', index, f88 (p[m + '_kd']))
+ self.proto.send ('p', 'cBH', 'a', index, f88 (p[m + '_acc']))
+ self.proto.send ('p', 'cBBB', 's', index, p[m + '_speed_max'],
+ p[m + '_speed_slow'])
+ self.proto.send ('p', 'cBHHB', 'b', index,
+ p[m + '_bd_error_limit'], p[m + '_bd_speed_limit'],
+ p[m + '_bd_counter_limit'])
+ self.proto.send ('p', 'cH', 'E', p['e_sat'])
+ self.proto.send ('p', 'cH', 'I', p['i_sat'])
+ self.proto.send ('p', 'cH', 'D', p['d_sat'])
+ reverse = 0
+ for i, m in enumerate (('a0', 'a1')):
+ if p[m + '_reverse']:
+ reverse |= 1 << i
+ self.proto.send ('p', 'cB', 'w', reverse)
def write_eeprom (self):
"""Request an EEPROM write."""