-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
46 lines (40 loc) · 1.05 KB
/
main.js
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
import { NT4_Client } from "./nt4.js";
var nt = new NT4_Client(
"10.17.21.2",
doNothing,
doNothing,
handleNewData,
doNothing,
onDisconnect,
);
nt.ws_connect();
nt.subscribeAllSamples("/");
function doNothing() {}
function onDisconnect() {}
function handleNewData(topic, timestamp, value) {
let name = topic.name;
if (topic.name == "/components/swerve/pose") {
let [x, y, z] = value;
$("#robot").css({
left: x * 65.590062111 + "px",
bottom: y * 65.590062111 + "px",
rotate: z + "deg",
});
$("#robotpos").html("Robot<br>" + x + "<br>" + y + "<br>" + z);
}
if (topic.name == "/components/swerve/goal") {
let [x, y, z] = value;
$("#target").css({
left: x * 65.590062111 + "px",
bottom: y * 65.590062111 + "px",
rotate: z + "deg",
});
$("#targetpos").html("Target<br>" + x + "<br>" + y + "<br>" + z);
}
if (topic.name == "/components/swerve/heading") {
$("#gyro").html("Gyro<br>" + value);
}
if (topic.name == "/limelight/botpose_orb_wpiblue") {
console.log(value);
}
}