git.haldean.org wallbot / e1b5c2b
lots of ideas for the command language Haldean Brown 1 year, 10 months ago
1 changed file(s) with 128 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 Primitives:
1 - boolean
2 - int
3 signed 32-bit integer
4 - Q vectors
5 dimension k (fixed at compile time), represents robot state
6 - R vectors
7 dimension n (fixed at compile time), represents robot position
8 - register
9 static storage whose value influences the behavior of the whole system
10 - signal
11 a triple of high-period, low-period (in milliseconds) and pulse count. A
12 signal with a period of zero and a nonzero pulse count represents an
13 always-on signal. A signal with a period of zero and a zero pulse count
14 represents an always-off signal.
15
16 3v3__ _________________________ ______
17 | | |
18 | | |
19 | | |
20 | | |
21 0__ ___/ \__________________/
22
23 |< high period >|< low period >|
24 |< one pulse >|
25
26 - channel
27 hardware output channel with a buffer, takes signals as input
28 - channelset
29 a set of channels that can be started and joined together
30
31 Registers:
32 %pivl: rvec
33 position of left pivot in real space
34 %pivr: rvec
35 position of right pivot in real space
36 %radl: int
37 difference between left radius at robot-zero and current radius
38 %radr: int
39 difference between right radius at robot-zero and current radius
40 %step: int
41 amount of chain let out in a single step
42 %cal: bool
43 true if the robot is calibrated (i.e., if pivl, pivr, radl and radr are
44 properly initialized)
45 %pen: bool
46 true if the pen is engaged, false otherwise
47 %mle: channel
48 motor left enable channel
49 %mld: channel
50 motor left direction channel
51 %mls: channel
52 motor left step channel
53 %mre: channel
54 motor right enable channel
55 %mrd: channel
56 motor right direction channel
57 %mrs: channel
58 motor right step channel
59
60 WiFi and serial communication are done via "remote registers", which are normal
61 registers that the interpreter keeps updated when remote requests come in, or
62 that cause a request to go out over serial or WiFi when written to. Remote
63 registers include:
64
65 %jogq: qvec
66 user jog requests of the Q position, in microns per second
67 %jogr: rvec
68 user jog requests of the R position, in microns per second
69 %go: bool
70 whether the go button is depressed
71
72 Built-in words:
73
74 true, false
75
76 swap (a b -- b a)
77 drop (a -- )
78 dup (a -- a a)
79
80 assert (a -- )
81 if a is not true, halts the interpreter
82
83 add, sub, div, mul, mod (v0 v1 -- res)
84 arithmetic on integers and vectors, all vector arithmetic is
85 element-wise
86 neg (v -- res)
87 negate a number or vector
88
89 qv (qn, ..., q1, q0 -- q)
90 makes a Q vector
91 rv (rn, ..., r1, r0 -- r)
92 makes an R vector
93 get (vec i -- vec[i])
94 gets an element from a qvec or rvec
95 dot (v0 v1 -- res)
96 dot product of two vectors
97
98 load (register -- value)
99 register load
100 store (value register -- )
101 register store
102
103 push (sig chan -- )
104 push a signal into a channel
105 wait (chan -- )
106 tell the channel to buffer requests until the next flush
107 flush (chan -- )
108 execute all requests on the channel
109
110 attach (channelset channel -- channelset)
111 add a channel to a set
112 begin (channelset -- channelset)
113 puts all associated channels into the wait state
114 commit (channelset -- channelset)
115 flushes all channels simultaneously, blocks until all signals are sent
116
117 Control flow:
118
119 mark ( -- )
120 adds a mark in the instruction flow
121 unmark ( -- )
122 drop the most recent mark
123 jumpif (bool -- )
124 if true, goes to the most recent mark and maintains the mark.
125 otherwise, unmarks and continues
126
127 All measurements done in whole microns to avoid floating point