-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsendCmd.m
73 lines (71 loc) · 1.54 KB
/
sendCmd.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function [ ] = sendCmd( s, type, val )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
cmd = [ 0, 1, 3, 1, 0, 0, 0, 1, 0, 0];
cmd = uint8(cmd);
switch type
case 'down'
cmd(4) = 1;
cmd(8) = bitand(val, 255);
fprintf('↓');
case 'up'
cmd(4) = 1;
cmd(8) = bitand(val, 255);
fprintf('↑');
case 'left roll'
cmd(4) = 4;
cmd(5) = 255;
cmd(6) = bitand(val, 255);
cmd(7) = bitshift(val,-8);
fprintf('左旋');
case 'right roll'
cmd(4) = 4;
cmd(5) = 1;
cmd(6) = bitand(val, 255);
cmd(7) = bitshift(val,-8);
fprintf('右旋');
case 'forward'
cmd(4) = 2;
cmd(5) = 1;
cmd(6) = bitand(val, 255);
cmd(7) = bitshift(val,-8);
fprintf('×');
case 'backward'
cmd(4) = 2;
cmd(5) = 255;
cmd(6) = bitand(val, 255);
cmd(7) = bitshift(val,-8);
fprintf('⊙');
case 'left'
cmd(4) = 3;
cmd(5) = 255;
cmd(6) = bitand(val, 255);
cmd(7) = bitshift(val,-8);
fprintf('←');
case 'right'
cmd(4) = 3;
cmd(5) = 1;
cmd(6) = bitand(val, 255);
cmd(7) = bitshift(val,-8);
fprintf('→');
case 'gimbal up'
cmd(4) = 5;
cmd(5) = 2555;
cmd(9) = bitand(val, 255);
cmd(10) = bitshift(val,-8);
fprintf('云台上旋');
case 'gimbal down'
cmd(4) = 5;
cmd(5) = 1;
cmd(9) = bitand(val, 255);
cmd(10) = bitshift(val,-8);
fprintf('云台下旋');
case 'gimbal stop'
cmd(4) = 5;
cmd(5) = 1;
cmd(9) = 0;
cmd(10) = 0;
fprintf('云台停止');
end
org.garrett.javatoolformatlab.SocketUtil.wrightBytes2Stream(cmd,s);
end