@nodriverai/mavjs
Node.js wrapper for mavlink/MAVSDK C++ library using node-addon-api.
Last updated 2 months ago by nodriverai .
SEE LICENSE IN LICENSE.md · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @nodriverai/mavjs 
SYNC missed versions from official npm registry.

MAVJS

Build Status

Node.js wrapper for mavlink/MAVSDK C++ library using node-addon-api.

MAVJS is a Node.js addon, written in C++, that can be loaded into Node.js using the require() function, and used just as if they were an ordinary Node.js module.

The aim of the project is to provide an interface between JavaScript running in Node.js and MAVSDK C/C++ library.

The library also provides types definition to use Typescript.

documentation: https://nodriver-ai.github.io/MAVJS/

Prerequisites

Before starting to use MAVJS you need to assure you have the following prerequisites:

Cmake needs because we use CMake.js to build the addon

MAVJS requires MAVSDK System-wide Install.

Installation

This is a Node.js module available through the npm registry.

installation is done using the npm install command:

$ npm i @nodriverai/mavjs

Getting started

import { Mavsdk, System, Telemetry, Action } from "@nodriverai/mavjs";

//Create a Mavsdk instance
let mavsdk = new Mavsdk();

//Add connection
const connection_result = mavsdk.add_any_connection("udp://14540");

if (connection_result != Mavsdk.ConnectionResult.SUCCESS) {
    console.log(`Connection failed: ${connection_result.toString()}`);
    process.exit()
}

//Get the first system discovered
let system = mavsdk.system();

//Initialize telemtery and action objects
let telemetry = system.telemetry();
let action = system.action();

//Monitor altitude while the vehicle is in flight
telemetry.position_async((position) => {
    console.log(`Altitude: ${position.relative_altitude_m} m`)
})

// Arm vehicle
let arm_result: Action.Result = action.arm();

if (arm_result != Action.Result.SUCCESS) {
    console.log(`Arming failed: ${arm_result}`)
    process.exit();
}

// Take off
let takeoff_result: Action.Result = action.takeoff();
if (takeoff_result != Action.Result.SUCCESS) {
    console.log(`Takeoff failed: ${takeoff_result}`)
    process.exit();
}

//close all connections
mavsdk.close();

Examples

To view the examples, clone the Express repo and install the dependencies:

$ git clone https://github.com/nodriver-ai/MAVJS.git
$ cd MAVJS
$ npm install

Then run whichever example you want:

$ node examples/takeoff_and_land.js udp:://14540

Project Status

Plugins implementation:

  • [x] Action
  • [x] Info
  • [x] Telemetry
  • [x] Mission
  • [x] MissionItem
  • [ ] Offboard
  • [ ] Geofence
  • [ ] Gimbal
  • [ ] Camera
  • [ ] LogFiles
  • [ ] MavlinkPasstrough
  • [ ] MavlinkFTP
  • [ ] MissionRaw
  • [ ] Mocap
  • [ ] Param
  • [ ] Shell
  • [ ] Tune

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm install
$ npm test

You need also a PX4 SITL running and accessible via UDP in localhost. You can use docker to run a gazebo PX4 SITL simulator.

$ docker run -d -it --net=host jonasvautherin/px4-gazebo-headless:v1.9.2

License

This project is licensed under the permissive BSD 3-clause, see LICENSE.md.

Current Tags

  • 0.1.2                                ...           latest (2 months ago)

5 Versions

  • 0.1.2                                ...           2 months ago
  • 0.1.1                                ...           4 months ago
  • 0.1.0-b                                ...           4 months ago
  • 0.1.0-a                                ...           4 months ago
  • 0.1.0                                ...           4 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (10)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |