-
Notifications
You must be signed in to change notification settings - Fork 0
/
VerboseMaestro.m
48 lines (44 loc) · 1.74 KB
/
VerboseMaestro.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
41
42
43
44
45
46
47
48
classdef VerboseMaestro < MaestroInterface
methods (Static)
function res = buildLogSpec(type)
str1 = 'Setting servo %i to:\t';
str2 = ' %i\n';
res = strcat(str1, type, str2);
end
end
methods
function gobj = VerboseMaestro(verbose)
if nargin > 0
assert(islogical(verbose));
gobj.Verbose = verbose;
else
gobj.Verbose = false;
end
end
function setTarget(obj, servo, target)
assert(isnumeric(servo), "servo argument is not a numeric");
assert(isnumeric(target), "target argument is not a numeric");
formatSpec = VerboseMaestro.buildLogSpec('target');
proc = @() fprintf(formatSpec, servo, target);
obj.onVerbose(proc);
end
function setAccel(obj, servo, target)
assert(isnumeric(servo), "servo argument is not a numeric");
assert(isnumeric(target), "target argument is not a numeric");
formatSpec = VerboseMaestro.buildLogSpec('acceleration');
proc = @() fprintf(formatSpec, servo, target);
obj.onVerbose(proc);
end
function setSpeed(obj, servo, target)
assert(isnumeric(servo), "servo argument is not a numeric");
assert(isnumeric(target), "target argument is not a numeric");
formatSpec = VerboseMaestro.buildLogSpec('speed');
proc = @() fprintf(formatSpec, servo, target);
obj.onVerbose(proc);
end
function goHome(obj)
proc = @() disp('Setting all servos to home position');
obj.onVerbose(proc);
end
end
end