# node-natnet

> Addon for the NatNet SDK.

Latest version **0.0.6** (published 2017-07-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-natnet
pnpm add node-natnet
yarn add node-natnet
bun add node-natnet
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2017-07-03 |
| First published | 2017-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Gellert Hegyi |
| Maintainers | gerhardberger |

## Links

- npm: https://www.npmjs.com/package/node-natnet
- Repository: https://github.com/gerhardberger/node-natnet
- Issues: https://github.com/gerhardberger/node-natnet/issues
- npm.io page: https://npm.io/package/node-natnet

## Dependencies (4)

- [nan](https://npm.io/package/nan.md) ^2.6.2
- [fs-extra](https://npm.io/package/fs-extra.md) ^3.0.1
- [native-huron](https://npm.io/package/native-huron.md) ^0.1.2
- [node-gyp-build](https://npm.io/package/node-gyp-build.md) ^3.2.0

## Recent versions

- 0.0.6 (latest) — 2017-07-03
- 0.0.5 — 2017-07-01
- 0.0.4 — 2017-07-01
- 0.0.3 — 2017-06-30
- 0.0.2 — 2017-06-29
- 0.0.1 — 2017-06-29

## README

# node-natnet

A client for the Optitrack NatNet client in Node.js. The implementation uses the official NatNetSDK. Using this module it is possible the gather frame data from the *Motive* software by enabling *Data Streaming* in it.

<blockquote>
  This module only supports Windows operating systems!
</blockquote>

## Usage

``` js
const { NatNetClient } = require('node-natnet')

const client = new NatNetClient()

client.initialize({
  local: '127.0.0.1',
  server: '127.0.0.1'
})

client.on('frame', data => {
  console.log('Received frame data: ', data)
})
```

## Install

Install from NPM:

```
$ npm install node-natnet
```

Install from the Git repository:
```
$ git clone https://github.com/gerhardberger/node-natnet.git
$ cd node-natnet
$ npm install
```
Then in your code import it with its path: `require('path/to/folder')`.

### Compiling manually

The module comes with prebuilt binaries for various Node.js versions, but if your's not supported, you can compile it manually, by running `npm run compile` inside the `node-natnet` folder after `npm install`.

## API Reference

### Methods

#### `const client = new NatNetClient(type)`

Creates a new `NatNetClient` instance. `type` is an optional *String* parameter that determines the connection (this can be configured inside *Motive*).

The possible connection types are:
- `'unicast'`, default
- `'multicast'`.

#### `client.initialize(options)`

Initializes and connects to a NatNet server that can be started in *Motive*.

The options object can contain:
- `local`: *String*, the local IP address that the client is running on. **Required.**
- `server`: *String*, the server IP address that the data is streamed to. **Required.**
- `hostCommandPort`: *Number*, the custom command port if there is one. *Optional.*
- `hostDataPort`: *Number*, the custom data port if there is one. *Optional.*

#### `client.uninitialize()`

Disconnects the client application from the server.

### Events

#### `client.on('frame', callback)`

This event is emitted every time there is new frame data received from *Motive*. The rate of this is dependent on the FPS counter in *Motive*.

The callback has one parameter which is an object containing the current frame data:
- `id`: The current frame identifier.
- `markerSets`: A named collection of identified markers and the marker positions `{ x, y, z }`.
- `otherMarkers`: List of point cloud solved 3D positions `{ x, y, z }` for all markers in the frame that are not labeled.
- `labeledMarkers`: Ordered, padded, point cloud solved, model filled (where occluded) labeled marker data.
- `latency`: The latency value of the frame.
- `timestamp`: Timing information for the frame.

### Properties

#### `client.connected`

A *Boolean* value that indicates wether the client is connected to the server.

#### `client.serverDescription`

Fetches the server description through a NatNet command. Returns an *Object*:
- `hostPresent`: *Boolean*
- `hostComputerName`: *String*
- `hostComputerAddress`: *String*
- `hostApp`: *String*
- `appVersion`: *String*
- `natNetVersion`: *String*

#### `client.dataDescriptions`

Fetches the data descriptions through a NatNet command. Returns an *[Object]*:
- `name`: *String*
- `markerNames`: *String*

---
_Source: https://npm.io/package/node-natnet · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
