Skip to content
This repository was archived by the owner on Jun 6, 2019. It is now read-only.

Commit da33504

Browse files
committed
Initializing project
0 parents  commit da33504

File tree

393 files changed

+46521
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

393 files changed

+46521
-0
lines changed

.eslintrc.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"extends": "google",
3+
"parserOptions": {
4+
"ecmaVersion": 6
5+
},
6+
"plugins": [
7+
"header"
8+
],
9+
"rules": {
10+
"header/header": [2, "config/header.js"],
11+
"max-len": ["error",
12+
// Following Google Javascript 100 char line limit
13+
100,
14+
// Use 2-space as tab width
15+
2,
16+
{ "ignoreUrls": true }
17+
],
18+
// Prefer to use single quotes
19+
"quotes": ["error", "single"],
20+
// Disable JSDoc
21+
"require-jsdoc": ["error", {
22+
"require": {
23+
"FunctionDeclaration": false,
24+
"MethodDefinition": false,
25+
"ClassDeclaration": false
26+
}
27+
}]
28+
}
29+
}

.gitignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
*~
2+
.DS_Store
3+
.*.sw?
4+
*.gypcmd
5+
*.mk
6+
*.pyc
7+
*.tar.gz
8+
*.log
9+
build
10+
cscope.*
11+
gen
12+
node_modules
13+
npm-debug.log
14+
src/common/tests/data
15+
tags
16+
tools/.boto_config.json
17+
tools/.no_password.expect
18+
tools/.docker

.jshintrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"esversion": 6,
3+
"node": true
4+
}

.travis.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
language: node_js
2+
3+
node_js:
4+
- "4"
5+
6+
sudo: required
7+
8+
services:
9+
# Travis CI does not support Ubuntu 16.04, so we use docker to match RealSense requirement.
10+
- docker
11+
12+
branches:
13+
only:
14+
- master
15+
16+
before_install:
17+
# Run linter
18+
- git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git && export PATH=$PATH:$(pwd)/depot_tools
19+
- cd tools && npm install && cd ..
20+
- python ./tools/node_modules/widl-nan/tools/lint.py
21+
22+
# Pull container
23+
- sudo docker pull ubuntu:16.04
24+
25+
# Install dependencies described as Dockerfile
26+
- sudo mkdir ./tools/.docker
27+
- sudo cat ./tools/Dockerfile.template | sed 's/<your_username>/mrbuild/g' | sed 's/<your_git_name>/Mr. Build/g' | sed 's/<your_git_email>/[email protected]/g' > /tmp/Dockerfile
28+
- sudo cp /tmp/Dockerfile ./tools/.docker/Dockerfile
29+
- sudo cp ./tools/install_realsense_pkgs.sh ./tools/.docker/
30+
- sudo docker build -t realsense ./tools/.docker
31+
32+
script:
33+
- sudo docker run -v $(pwd):/home/mrbuild/node-realsense --rm realsense bash -c "sudo -H -u mrbuild /home/mrbuild/node-realsense/tools/try_build_realsense_js.sh"

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Intel Corporation. All rights reserved.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Intel® RealSense™ technology with JavaScript API for Linux OS
2+
3+
[![Build Status](https://travis-ci.com/otcshare/node-realsense.svg?token=R4frH5duwqgLFqkCuqbn&branch=master)](https://travis-ci.com/otcshare/node-realsense)
4+
5+
[ ![License] [license-image] ] [license]
6+
7+
[license-image]: https://img.shields.io/github/license/mashape/apistatus.svg?style=flat
8+
[license]: LICENSE
9+
10+
This project is offering Node.js modules of [Intel® RealSense™ technology](http://www.intel.com/content/www/us/en/architecture-and-technology/realsense-overview.html) including Person Tracaking, Object Recognization, and SLAM capabilities. The target is [Intel® Joule™](https://software.intel.com/en-us/iot/hardware/joule) and ZR300 camera on top of Ubuntu 16.04 DT.
11+
12+
## Documents
13+
14+
* [Spec](./doc/spec) - Javascript specification document. (TODO)
15+
* [Get Started](./doc/get_started.md) - A guide how to setup environment and run samples.
16+
* [Contribution](./doc/contribution.md) - A guide how to contribute code.
17+
* [BKMs](./doc/bkms.md) - Best known methods.
18+
19+
## License
20+
The MIT License (MIT)
21+
22+
Copyright (c) 2016 Intel Corporation. All rights reserved.
23+
24+
Permission is hereby granted, free of charge, to any person obtaining a copy
25+
of this software and associated documentation files (the "Software"), to deal
26+
in the Software without restriction, including without limitation the rights
27+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28+
copies of the Software, and to permit persons to whom the Software is
29+
furnished to do so, subject to the following conditions:
30+
31+
The above copyright notice and this permission notice shall be included in all
32+
copies or substantial portions of the Software.
33+
34+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40+
SOFTWARE.
41+

config/header.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Copyright (c) 2016 Intel Corporation. All rights reserved.
2+
// Use of this source code is governed by a MIT-style license that can be
3+
// found in the LICENSE file.

doc/bkms.md

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
## BKMs
2+
3+
* Oh my god somebody please help node-gyp build takes too long time it compiles almost all C++ files every time somebody please help me out...
4+
5+
Use the below shell script to build (with extra benefits)
6+
7+
```
8+
# Workaround of node-gyp build issue
9+
target=`ls build/*.mk`
10+
alter=`ls build/*.mk`".new"
11+
sed 's/widl\ FORCE_DO_CMD/widl/' -r $target > $alter
12+
cp -f $alter $target
13+
14+
# Build current add-on
15+
node-gyp build
16+
17+
# Lint tool -- Make your code great again by making lint happy again
18+
if [ $? -eq 0 ]; then
19+
# Save current dir
20+
saved=`pwd`
21+
22+
cd ../../ && python tools/node_modules/widl-nan/tools/lint.py --base=master
23+
24+
# Test: to do, or not to do
25+
if [ $# -gt 0 ] && [ $1 == "test" ]; then
26+
cd $saved && mocha
27+
else
28+
echo "Note: to run test, type '$0 test'"
29+
fi
30+
fi
31+
```
32+
33+
* How to debug node addon
34+
```
35+
node-gyp rebuild --debug
36+
gdb --args `which node` sample.js
37+
// In gdb
38+
gdb> b main
39+
gdb> r
40+
gdb> b [SOME_FUNCTION_NAME/LINE_NUMBER]
41+
gdb> c
42+
gdb> l
43+
gdb> s/n
44+
```
45+
46+
* How to debug mocha
47+
48+
```
49+
>gdb --args `which node` `which mocha`
50+
```
51+
52+
* ZR300 can't work on Ubuntu
53+
* Install udev rules
54+
```
55+
sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/
56+
sudo udevadm control --reload-rules
57+
sudo udevadm trigger
58+
```
59+
* Above steps should be automatically executed if install librealsense via [PPA](https://code.launchpad.net/~halton-huo/+junk/librealsense).
60+
61+
* Can't connect to camera again if previous run crashed.
62+
* Current solution: disconnect and reconnect camera from/to your system.
63+
* Crash occurs when addon is running smoothly, and then can't connect to RealSense camera again in a restart
64+
* The solution: disconnect the camera and then reconnect
65+
66+
Error message of the 1st crash:
67+
```
68+
terminate called after throwing an instance of 'std::runtime_error'
69+
what(): VIDIOC_DQBUF error 19, No such device
70+
Aborted (core dumped)
71+
```
72+
73+
Error message of later failure to connect:
74+
75+
```
76+
terminate called after throwing an instance of 'rs::error'
77+
what(): UVCIOC_CTRL_QUERY:UVC_SET_CUR error 5, Input/output error
78+
Aborted (core dumped)
79+
```
80+
81+
* If you use add-on directly and has forgotten to inherit from `Node.js` `EventEmitter`, you'll hit the following error (or the like)
82+
```
83+
/usr/bin/nodejs[24777]: ../src/node.cc:1345:v8::Local<v8::Value> node::MakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::String>, int, v8::Local<v8::Value>*): Assertion `cb_v->IsFunction()' failed.
84+
1: node::Abort() [node]
85+
2: node::Assert(char const* const (*) [4]) [node]
86+
3: node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, char const*, int, v8::Local<v8::Value>*) [node]
87+
4: FutureMakeCallback::TimerCallback(unsigned long) [/home/yunfei/00_yunfei/github/node-realsense/src/object-recognition/build/Release/realsense_object_recognition.node]
88+
5: WIDLNANTimer::TimerCallbackProc(uv_timer_s*) [/home/yunfei/00_yunfei/github/node-realsense/src/object-recognition/build/Release/realsense_object_recognition.node]
89+
6: 0x13774f5 [node]
90+
7: uv_run [node]
91+
8: node::Start(int, char**) [node]
92+
9: __libc_start_main [/lib/x86_64-linux-gnu/libc.so.6]
93+
10: _start [node]
94+
Aborted (core dumped)
95+
```
96+
Solution: to inherit from `EventEmitter` or to `require` the `Node.js` wrapper module
97+
98+
* `sudo snap login <your_email>` failed
99+
Edit your `http_proxy`, https_proxy` to /etc/environment, then `sudo service snapd restart`

doc/contribution.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Contribution
2+
Go to [Setup Environment](./setup_environment.md) first to ensure all your hardware and software are ready.
3+
4+
## Coding style guideline
5+
We're following [Chromium coding style](https://chromium.googlesource.com/chromium/src/+/master/styleguide/styleguide.md) for different languages: [C++](https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md), [Python](https://google.github.io/styleguide/pyguide.html) and [JavaScript](https://google.github.io/styleguide/javascriptguide.xml).
6+
7+
### Install tools
8+
* [depot_tools](https://www.chromium.org/developers/how-tos/install-depot-tools) need to be installed and added to `PATH` env.
9+
* Re-use [widl-nan](http://github.com/01org/widl-nan) linter tool
10+
```
11+
cd src/tools && npm install
12+
```
13+
14+
### Run tests
15+
* Prepare the playback files by running `./src/common/tests/fetch_tests_data.sh <playback_url>`
16+
17+
### Run linter
18+
Run `python ./tools/node_modules/widl-nan/tools/lint.py` before submitting your code.
19+
20+
## Commit message guideline
21+
We use same [Chromium commit log guideline](https://www.chromium.org/developers/contributing-code) and [Github closing isses via commit messages](https://help.github.com/articles/closing-issues-via-commit-messages/). Use the following form:
22+
23+
```
24+
Summary of change.
25+
26+
Longer description of change addressing as appropriate: why the change is made,
27+
context if it is part of many changes, description of previous behavior and
28+
newly introduced differences, etc.
29+
30+
Long lines should be wrapped to 80 columns for easier log message viewing in
31+
terminals.
32+
33+
Fixes #123456
34+
```
35+
36+
## If you need release a build, follow [How to Release](./howto_release.md)

doc/get_started.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Get Started
2+
Go to [Setup Environment](./setup_environment.md) first to ensure all your hardware and software are ready.
3+
4+
## For non-display usage
5+
* Init project
6+
```
7+
npm init
8+
```
9+
* Install Node.JS modules (Take PT for eg)
10+
```
11+
npm install --save person-tracking
12+
```
13+
Note: Use below steps instead before we officially register on https://www.npmjs.com
14+
```
15+
git clone ssh://[email protected]/otcshare/node-realsense ~/node-realsense
16+
cd ~/node-realsense/src/person-tracking
17+
npm run-script maketarball
18+
cd <your_project_path>
19+
npm install --save ~/node-realsense/src/person-tracking/*.tar.gz
20+
```
21+
22+
### Code time (TODO)
23+
24+
## For display usage (TODO)

doc/howto_release.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# How to release a node-realsense build
2+
Go to [Setup Environment](./setup_environment.md) first to ensure all your hardware and software are ready.
3+
4+
## Preparation
5+
1. Follow [Generating an SSH key](https://help.github.com/articles/generating-an-ssh-key/) and add this SSH key to your github account. If you ever did that, please bypass this step.
6+
2. Get push permission for this repo. (Because we need bump the patch version automatically)
7+
3. Setup the night build archive server, typically HTTP server running on that. Apply an user account with permission to write to the www directory.
8+
4. Add your ssh key (on step 1) to archive server, follow [Adding SSH Keys to authorized_keys](http://askubuntu.com/questions/46424/adding-ssh-keys-to-authorized-keys). This step ensure you can push code and upload to archive server w/o password.
9+
10+
## Customize
11+
1. clone this code via SSH way, `git clone [email protected]:otcshare/node-realsense.git`. Otherwise, unable to automatically push commit.
12+
2. Copy `tools/.boto_config.json.template` to `tools/.boto_config.json` and change the value
13+
```
14+
"archive_server": {
15+
"host": "<your_archive_server>",
16+
"nightly_dir": "", # The directory of nightly build
17+
"official_dir": "", # The directory of official build
18+
"usergroup": "", # group on archive server
19+
"username": "" # username on archive server
20+
},
21+
"build_type": "nightly", # Support nightly or official type
22+
"bump_version": true, # Whether to bump version
23+
"tarball_only": false, # Only make tarball, no install and test
24+
"upload_build": true # Whether to upload build to server
25+
```
26+
3. Copy `tools/.no_password.expect.template` to `tools/.no_password.expect` and change the right value. NOTE, please keep this file carefully because it contains your passpharse to unlock the SSH key (step1).
27+
4. Install required packages `sudo apt-get install expect`
28+
29+
## Run Build
30+
### Nightly
31+
Ensure `build_type` is ***nightly*** in `tools/.boto_config.json` and execute `tools/build_realsense_js.sh`. Some hints:
32+
33+
* Add it to cronjob via `crontab -e`. For example (run every day at 10pm):
34+
```
35+
0 22 * * * cd $HOME/nightly/node-realsense/tools/build_realsense_js.sh
36+
```
37+
* `bump_version` is normally set as ***true*** to automatic bump the patch version.
38+
* `tarball_only` can be set as ***false*** to allow npm install and test run.
39+
* `upload_build` is mostly ***true***.
40+
41+
## Official
42+
Ensure `build_type` is ***official*** in `tools/.boto_config.json` and execute `tools/build_realsense_js.sh <version>`. Some hints:
43+
44+
* `bump_version` is ***true*** will auto make tagging and push commit. If you want to the bump commit review by pull request, set `bump_version` as ***false***, then you need follow normal PR review process.
45+
* `tarball_only` can be set as ***true*** to save time.
46+
* `upload_build` is mostly ***true***.
47+
48+
## Check build
49+
There will be `node_realsense-<date>.log` after each run. The tarball of each module and log file will eventually uploaded to the archive server. And the latest link will always point the latest nightly build.

doc/images/state/Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pngs : object-recognition-state.png person-tracking-state.png slam-state.png
2+
3+
object-recognition-state.png : object-recognition-state.dot
4+
dot object-recognition-state.dot -Tpng -oobject-recognition-state.png
5+
person-tracking-state.png : person-tracking-state.dot
6+
dot person-tracking-state.dot -Tpng -operson-tracking-state.png
7+
slam-state.png : slam-state.dot
8+
dot slam-state.dot -Tpng -oslam-state.png
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
digraph G {
2+
"ready" -> "running" [label="start(), restart()"];
3+
"ready" -> "errored" [label="Oops"];
4+
"ready" -> "ready" [label="reset()"];
5+
6+
"running" -> "running" [label="restart()"];
7+
"running" -> "ready" [label="reset()"];
8+
"running" -> "paused" [label="pause()"];
9+
"running" -> "errored" [label="Oops"];
10+
11+
"paused" -> "ready" [label="reset()"];
12+
"paused" -> "running" [label="resume(), restart()"];
13+
"paused" -> "errored" [label="Oops"];
14+
15+
"errored" -> "ready" [label="reset()"];
16+
"errored" -> "errored" [label="Oops"];
17+
"errored" -> "running" [label="restart()"];
18+
}
50.5 KB
Loading

0 commit comments

Comments
 (0)