-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.coffee
44 lines (39 loc) · 1.04 KB
/
index.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class Mecanum
constructor: (options = {cw: 'cw', ccw: 'ccw', stop: 'stop'}) ->
@CW = options.cw
@CCW = options.ccw
@stop = options.stop
move: (dir, callback) =>
@values = []
switch dir
when 'forward'
@values = [@CW, @CW, @CW, @CW]
when 'backward'
@values = [@CCW, @CCW, @CCW, @CCW]
when 'left'
@values = [@CW, @CCW, @CCW, @CW]
when 'right'
@values = [@CCW, @CW, @CW, @CCW]
when 'nw'
@values = [@stop, @CW, @CW, @stop]
when 'ne'
@values = [@CW, @stop, @stop, @CW]
when 'sw'
@values = [@CCW, @stop, @stop, @CCW]
when 'se'
@values = [@stop, @CCW, @CCW, @stop]
when 'cw'
@values = [@CW, @CW, @CCW, @CCW]
when 'ccw'
@values = [@CCW, @CCW, @CW, @CW]
when 'stop'
@values = [@stop, @stop, @stop, @stop]
@values = {
LF: @values[0]
LB: @values[1]
RF: @values[2]
RB: @values[3]
}
callback @values if callback?
return @values
module.exports = Mecanum