node-mavlink 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -226,6 +226,16 @@ The default values for some parameters are as follows:
226
226
 
227
227
  This is a very handy utility function that asynchronously pauses for a given time (ms).
228
228
 
229
+ ## Running sim_vehicle.py
230
+
231
+ The easiest way to start playing around with this package is to use `sim_vehicle.py`. You can use the default parameters forthe MavEsp8266 if you'll make the simulator compatible with it:
232
+
233
+ ```
234
+ $ Tools/autotest/sim_vehicle.py -v ArduCopter -f quad --console --map --out udpin:127.0.0.1:14555
235
+ ```
236
+
237
+ That last parameter (`--out udpin:127.0.0.1:14555`) opens up for incoming messages in port 14555, which is the default send port for MavEsp8266 and its default firmware.
238
+
229
239
  ## Closing thoughts
230
240
 
231
241
  The original generated sources lack one very important aspect of a reusable library: documentation. Also, most of the time the names are more C-like than JavaScript-like.
@@ -9,13 +9,19 @@ const REGISTRY: MavLinkPacketRegistry = {
9
9
  ...ardupilotmega.REGISTRY,
10
10
  }
11
11
 
12
+ // This is how you could build a registry of all commands from different packages
13
+ const COMMANDS: common.MavLinkCommandRegistry = {
14
+ ...common.COMMANDS,
15
+ ...ardupilotmega.COMMANDS,
16
+ }
17
+
12
18
  async function main() {
13
19
  const port = new MavEsp8266()
14
20
 
15
21
  // start the communication
16
22
  // After this line we have received at least one heartbeat message so we
17
23
  // know what is the remote IP address to send the messages to
18
- const { ip, sendPort, receivePort } = await port.start()
24
+ const { ip, sendPort, receivePort } = await port.start(14551)
19
25
  console.log(`Connected to: ${ip}, send port: ${sendPort}, receive port ${receivePort}`)
20
26
 
21
27
  // log incomming messages
@@ -33,21 +39,18 @@ async function main() {
33
39
 
34
40
  // You're now ready to send messages to the controller using the socket
35
41
  // let's request the list of parameters
42
+ const cmdSetMode = new common.DoSetModeCommand()
43
+ cmdSetMode.mode = 1
44
+ cmdSetMode.customMode = ardupilotmega.CopterMode.DRIFT
36
45
 
37
- const cmdParamList = new common.ParamRequestList()
38
- cmdParamList.targetSystem = 1
39
- cmdParamList.targetComponent = 1
40
-
41
- // The send method is another utility method, very handy to have it provided
42
- // by the library. It takes care of the sequence number and data serialization.
43
- await port.send(cmdParamList)
46
+ await port.send(cmdSetMode)
44
47
 
45
- // Here's another example of sending commands
46
- const cmdSetRelay = new common.DoSetRelayCommand()
47
- cmdSetRelay.instance = 0
48
- cmdSetRelay.setting = 1
48
+ // Give the system time to process any incoming acknowledges
49
+ const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))
50
+ await sleep(1000)
49
51
 
50
- await port.send(cmdSetRelay)
52
+ // Close communication
53
+ port.close()
51
54
  }
52
55
 
53
56
  main()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mavlink",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "author": "Matthias Hryniszak <padcom@gmail.com>",
5
5
  "license": "LGPL",
6
6
  "description": "MavLink definitions and parsing library",
@@ -22,7 +22,7 @@
22
22
  "main": "dist/index.js",
23
23
  "types": "dist/index.d.ts",
24
24
  "dependencies": {
25
- "mavlink-mappings": "^1.0.13-20230115"
25
+ "mavlink-mappings": "^1.0.13-20230115-3"
26
26
  },
27
27
  "scripts": {
28
28
  "clean": "rm -rf dist lib/*.js",