-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
51 lines (42 loc) · 1.13 KB
/
main.js
File metadata and controls
51 lines (42 loc) · 1.13 KB
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
const { OutSim, OutSimPack2 } = require('node-insim');
const outSim = new OutSim({ timeout: 10000 });
console.log('Connecting...');
outSim.connect({
Host: '127.0.0.1',
Port: 30000,
OutSimOpts: 0x1ff, // This value needs to match the "OutSim Opts" value in cfg.txt
});
outSim.on('connect', () => {
console.log('Connected');
});
outSim.on('disconnect', () => {
console.log('Disconnected');
});
outSim.on('timeout', () => {
console.log('Timed out');
process.exit(1);
});
outSim.on('packet', (data) => {
if (!(data instanceof OutSimPack2)) {
return;
}
console.clear();
console.log(
`Velocity: ${data.OSMain.Vel[0]} ${data.OSMain.Vel[1]} ${data.OSMain.Vel[2]}`,
);
console.log(
`Airspeed: ${Math.sqrt(
Math.pow(data.OSMain.Vel[0], 2) +
Math.pow(data.OSMain.Vel[1], 2) +
Math.pow(data.OSMain.Vel[2], 2),
)} m/s`,
);
console.log(
`Position: ${data.OSMain.Pos[0]} ${data.OSMain.Pos[1]} ${data.OSMain.Pos[2]}`,
);
console.log(`Gear: ${data.Gear}`);
console.log(`Rpm: ${(30 * data.EngineAngVel) / Math.PI}`);
});
process.on('uncaughtException', (error) => {
console.log(error);
});