-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaestroOS.m
41 lines (34 loc) · 1.17 KB
/
MaestroOS.m
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
classdef MaestroOS < MaestroInterface
properties (SetAccess = protected, GetAccess = protected)
ServoCount
end
methods (Static)
function unsafeSystem(cmd)
[status, msg] = system(cmd);
assert(status == 0, msg);
end
end
methods (Hidden, Static)
function res = commandBuilder(action, servo, target)
assert(isnumeric(servo), 'Servo must be a numeric');
assert(isnumeric(target), 'Target must be a numeric');
res = sprintf('UscCmd --%s %i,%i', action, servo, target);
end
end
methods
function gobj = MaestroOS()
end
function setTarget(~, servo, target)
cmd = MaestroOS.commandBuilder('servo', servo, target);
MaestroOS.unsafeSystem(cmd);
end
function setAccel(~, servo, target)
cmd = MaestroOS.commandBuilder('accel', servo, target);
MaestroOS.unsafeSystem(cmd);
end
function setSpeed(~, servo, target)
cmd = MaestroOS.commandBuilder('speed', servo, target);
MaestroOS.unsafeSystem(cmd);
end
end
end