@openhps/openvslam 0.0.0-stage → 0.1.0
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/LICENSE +190 -0
- package/README.md +115 -2
- package/cc/config.cc +49 -0
- package/cc/config.h +24 -0
- package/cc/frame_publisher.cc +62 -0
- package/cc/frame_publisher.h +27 -0
- package/cc/graph_node.cc +78 -0
- package/cc/graph_node.h +26 -0
- package/cc/keyframe.cc +81 -0
- package/cc/keyframe.h +27 -0
- package/cc/landmark.cc +85 -0
- package/cc/landmark.h +26 -0
- package/cc/map_publisher.cc +119 -0
- package/cc/map_publisher.h +33 -0
- package/cc/openvslam.cc +26 -0
- package/cc/pangolin_viewer/viewer.h +26 -0
- package/cc/socket_publisher/publisher.cc +84 -0
- package/cc/socket_publisher/publisher.h +26 -0
- package/cc/system.cc +190 -0
- package/cc/system.h +47 -0
- package/dist/cjs/data/VSLAMFrame.js +44 -0
- package/dist/cjs/data/VSLAMFrame.js.map +1 -0
- package/dist/cjs/data/VSLAMGraphNode.js +7 -0
- package/dist/cjs/data/VSLAMGraphNode.js.map +1 -0
- package/dist/cjs/data/VSLAMKeyFrame.js +56 -0
- package/dist/cjs/data/VSLAMKeyFrame.js.map +1 -0
- package/dist/cjs/data/VSLAMLandmark.js +53 -0
- package/dist/cjs/data/VSLAMLandmark.js.map +1 -0
- package/dist/cjs/data/VSLAMMap.js +36 -0
- package/dist/cjs/data/VSLAMMap.js.map +1 -0
- package/dist/cjs/data/index.js +8 -0
- package/dist/cjs/data/index.js.map +1 -0
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/nodes/VSLAMConfiguration.js +43 -0
- package/dist/cjs/nodes/VSLAMConfiguration.js.map +1 -0
- package/dist/cjs/nodes/index.js +7 -0
- package/dist/cjs/nodes/index.js.map +1 -0
- package/dist/cjs/nodes/processing/VSLAMProcessingNode.js +124 -0
- package/dist/cjs/nodes/processing/VSLAMProcessingNode.js.map +1 -0
- package/dist/cjs/nodes/processing/index.js +5 -0
- package/dist/cjs/nodes/processing/index.js.map +1 -0
- package/dist/cjs/nodes/sink/VSLAMSocketPublisher.js +68 -0
- package/dist/cjs/nodes/sink/VSLAMSocketPublisher.js.map +1 -0
- package/dist/cjs/nodes/sink/index.js +5 -0
- package/dist/cjs/nodes/sink/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/service/VSLAMService.js +121 -0
- package/dist/cjs/service/VSLAMService.js.map +1 -0
- package/dist/cjs/service/index.js +5 -0
- package/dist/cjs/service/index.js.map +1 -0
- package/dist/cjs/tsconfig.bundle.cjs.tsbuildinfo +1 -0
- package/dist/esm/data/VSLAMFrame.js +41 -0
- package/dist/esm/data/VSLAMFrame.js.map +1 -0
- package/dist/esm/data/VSLAMGraphNode.js +3 -0
- package/dist/esm/data/VSLAMGraphNode.js.map +1 -0
- package/dist/esm/data/VSLAMKeyFrame.js +53 -0
- package/dist/esm/data/VSLAMKeyFrame.js.map +1 -0
- package/dist/esm/data/VSLAMLandmark.js +50 -0
- package/dist/esm/data/VSLAMLandmark.js.map +1 -0
- package/dist/esm/data/VSLAMMap.js +33 -0
- package/dist/esm/data/VSLAMMap.js.map +1 -0
- package/dist/esm/data/index.js +5 -0
- package/dist/esm/data/index.js.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/nodes/VSLAMConfiguration.js +39 -0
- package/dist/esm/nodes/VSLAMConfiguration.js.map +1 -0
- package/dist/esm/nodes/index.js +4 -0
- package/dist/esm/nodes/index.js.map +1 -0
- package/dist/esm/nodes/processing/VSLAMProcessingNode.js +120 -0
- package/dist/esm/nodes/processing/VSLAMProcessingNode.js.map +1 -0
- package/dist/esm/nodes/processing/index.js +2 -0
- package/dist/esm/nodes/processing/index.js.map +1 -0
- package/dist/esm/nodes/sink/VSLAMSocketPublisher.js +64 -0
- package/dist/esm/nodes/sink/VSLAMSocketPublisher.js.map +1 -0
- package/dist/esm/nodes/sink/index.js +2 -0
- package/dist/esm/nodes/sink/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/service/VSLAMService.js +117 -0
- package/dist/esm/service/VSLAMService.js.map +1 -0
- package/dist/esm/service/index.js +2 -0
- package/dist/esm/service/index.js.map +1 -0
- package/dist/esm/tsconfig.bundle.esm.tsbuildinfo +1 -0
- package/dist/esm/tsconfig.bundle.types.tsbuildinfo +1 -0
- package/dist/types/data/VSLAMFrame.d.ts +16 -0
- package/dist/types/data/VSLAMFrame.d.ts.map +1 -0
- package/dist/types/data/VSLAMGraphNode.d.ts +3 -0
- package/dist/types/data/VSLAMGraphNode.d.ts.map +1 -0
- package/dist/types/data/VSLAMKeyFrame.d.ts +28 -0
- package/dist/types/data/VSLAMKeyFrame.d.ts.map +1 -0
- package/dist/types/data/VSLAMLandmark.d.ts +20 -0
- package/dist/types/data/VSLAMLandmark.d.ts.map +1 -0
- package/dist/types/data/VSLAMMap.d.ts +13 -0
- package/dist/types/data/VSLAMMap.d.ts.map +1 -0
- package/dist/types/data/index.d.ts +5 -0
- package/dist/types/data/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/nodes/VSLAMConfiguration.d.ts +36 -0
- package/dist/types/nodes/VSLAMConfiguration.d.ts.map +1 -0
- package/dist/types/nodes/index.d.ts +4 -0
- package/dist/types/nodes/index.d.ts.map +1 -0
- package/dist/types/nodes/processing/VSLAMProcessingNode.d.ts +36 -0
- package/dist/types/nodes/processing/VSLAMProcessingNode.d.ts.map +1 -0
- package/dist/types/nodes/processing/index.d.ts +2 -0
- package/dist/types/nodes/processing/index.d.ts.map +1 -0
- package/dist/types/nodes/sink/VSLAMSocketPublisher.d.ts +17 -0
- package/dist/types/nodes/sink/VSLAMSocketPublisher.d.ts.map +1 -0
- package/dist/types/nodes/sink/index.d.ts +2 -0
- package/dist/types/nodes/sink/index.d.ts.map +1 -0
- package/dist/types/service/VSLAMService.d.ts +57 -0
- package/dist/types/service/VSLAMService.d.ts.map +1 -0
- package/dist/types/service/index.d.ts +2 -0
- package/dist/types/service/index.d.ts.map +1 -0
- package/install/install.js +85 -0
- package/install/parseEnv.js +7 -0
- package/package.json +125 -5
- package/src/data/VSLAMFrame.ts +48 -0
- package/src/data/VSLAMGraphNode.ts +1 -0
- package/src/data/VSLAMKeyFrame.ts +50 -0
- package/src/data/VSLAMLandmark.ts +42 -0
- package/src/data/VSLAMMap.ts +20 -0
- package/src/data/index.ts +4 -0
- package/src/index.ts +4 -0
- package/src/nodes/VSLAMConfiguration.ts +72 -0
- package/src/nodes/index.ts +3 -0
- package/src/nodes/processing/VSLAMProcessingNode.ts +152 -0
- package/src/nodes/processing/index.ts +1 -0
- package/src/nodes/sink/VSLAMSocketPublisher.ts +75 -0
- package/src/nodes/sink/index.ts +1 -0
- package/src/openvslam/index.d.ts +9 -0
- package/src/openvslam/index.js +8 -0
- package/src/openvslam/typings/Config.d.ts +3 -0
- package/src/openvslam/typings/FramePublisher.d.ts +12 -0
- package/src/openvslam/typings/GraphNode.d.ts +5 -0
- package/src/openvslam/typings/KeyFrame.d.ts +24 -0
- package/src/openvslam/typings/Landmark.d.ts +19 -0
- package/src/openvslam/typings/MapPublisher.d.ts +21 -0
- package/src/openvslam/typings/PangolinViewer.d.ts +9 -0
- package/src/openvslam/typings/SocketPublisher.d.ts +9 -0
- package/src/openvslam/typings/System.d.ts +45 -0
- package/src/service/VSLAMService.ts +130 -0
- package/src/service/index.ts +1 -0
package/cc/keyframe.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#ifndef OPENHPS_OPENVSLAM_KEYFRAME_H
|
|
2
|
+
#define OPENHPS_OPENVSLAM_KEYFRAME_H
|
|
3
|
+
|
|
4
|
+
#include <nan.h>
|
|
5
|
+
#include "graph_node.h"
|
|
6
|
+
|
|
7
|
+
#include <stella_vslam/data/keyframe.h>
|
|
8
|
+
|
|
9
|
+
class KeyFrame : public Nan::ObjectWrap {
|
|
10
|
+
public:
|
|
11
|
+
static void Init(v8::Local<v8::Object> exports);
|
|
12
|
+
explicit KeyFrame();
|
|
13
|
+
static v8::Local<v8::Object> NewInstance(std::shared_ptr<stella_vslam::data::keyframe> native);
|
|
14
|
+
std::shared_ptr<stella_vslam::data::keyframe> self;
|
|
15
|
+
|
|
16
|
+
private:
|
|
17
|
+
~KeyFrame();
|
|
18
|
+
|
|
19
|
+
static void New(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
20
|
+
static void ToJSON(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
21
|
+
static void GetId(v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value>& info);
|
|
22
|
+
static void GetGraphNode(v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value>& info);
|
|
23
|
+
|
|
24
|
+
static Nan::Persistent<v8::Function> constructor;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
#endif
|
package/cc/landmark.cc
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#include "landmark.h"
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <iostream>
|
|
5
|
+
#include <Eigen/Core>
|
|
6
|
+
#include <nlohmann/json.hpp>
|
|
7
|
+
|
|
8
|
+
Nan::Persistent<v8::Function> Landmark::constructor;
|
|
9
|
+
|
|
10
|
+
Landmark::Landmark() {}
|
|
11
|
+
|
|
12
|
+
Landmark::~Landmark() {}
|
|
13
|
+
|
|
14
|
+
void Landmark::Init(v8::Local<v8::Object> exports) {
|
|
15
|
+
v8::Local<v8::Context> context = exports->CreationContext();
|
|
16
|
+
|
|
17
|
+
// Prepare constructor template
|
|
18
|
+
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
|
|
19
|
+
tpl->SetClassName(Nan::New("Landmark").ToLocalChecked());
|
|
20
|
+
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
21
|
+
|
|
22
|
+
// Prototype
|
|
23
|
+
Nan::SetPrototypeMethod(tpl, "getPosInWorld", GetPosInWorld);
|
|
24
|
+
Nan::SetPrototypeMethod(tpl, "toJSON", ToJSON);
|
|
25
|
+
Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New("id").ToLocalChecked(), GetId);
|
|
26
|
+
|
|
27
|
+
constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
|
|
28
|
+
exports->Set(context,
|
|
29
|
+
Nan::New("Landmark").ToLocalChecked(),
|
|
30
|
+
tpl->GetFunction(context).ToLocalChecked());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void Landmark::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
34
|
+
v8::Isolate *isolate = info.GetIsolate();
|
|
35
|
+
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
36
|
+
if (info.IsConstructCall()) {
|
|
37
|
+
// Invoked as constructor
|
|
38
|
+
Landmark* obj = new Landmark();
|
|
39
|
+
obj->Wrap(info.This());
|
|
40
|
+
info.GetReturnValue().Set(info.This());
|
|
41
|
+
} else {
|
|
42
|
+
// Invoked as plain function
|
|
43
|
+
const int argc = 0;
|
|
44
|
+
v8::Local<v8::Value> argv[argc] = { };
|
|
45
|
+
v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
|
|
46
|
+
info.GetReturnValue().Set(
|
|
47
|
+
cons->NewInstance(context, argc, argv).ToLocalChecked());
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
v8::Local<v8::Object> Landmark::NewInstance(std::shared_ptr<stella_vslam::data::landmark> native) {
|
|
52
|
+
v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
|
|
53
|
+
const int argc = 0;
|
|
54
|
+
v8::Local<v8::Value> argv[0] = { };
|
|
55
|
+
const v8::Local<v8::Object> result = Nan::NewInstance(cons, argc, argv).ToLocalChecked();
|
|
56
|
+
|
|
57
|
+
Landmark* obj = Nan::ObjectWrap::Unwrap<Landmark>(result);
|
|
58
|
+
obj->self = native;
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
void Landmark::GetId(v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value>& info) {
|
|
63
|
+
Landmark* obj = ObjectWrap::Unwrap<Landmark>(info.Holder());
|
|
64
|
+
info.GetReturnValue().Set(obj->self->id_);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
void Landmark::GetPosInWorld(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
68
|
+
Landmark* obj = ObjectWrap::Unwrap<Landmark>(info.Holder());
|
|
69
|
+
Eigen::Vector3d pos = obj->self->get_pos_in_world();
|
|
70
|
+
const size_t outSize = pos.size();
|
|
71
|
+
v8::Local<v8::Array> outArray = Nan::New<v8::Array>(outSize);
|
|
72
|
+
for (size_t i = 0; i < outSize; ++i) {
|
|
73
|
+
Nan::Set(outArray, i, Nan::New<v8::Number>(*(pos.data() + i)));
|
|
74
|
+
}
|
|
75
|
+
info.GetReturnValue().Set(outArray);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
void Landmark::ToJSON(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
79
|
+
Landmark* obj = ObjectWrap::Unwrap<Landmark>(info.Holder());
|
|
80
|
+
nlohmann::json json = obj->self->to_json();
|
|
81
|
+
v8::Local<v8::String> json_string = Nan::New(json.dump()).ToLocalChecked();
|
|
82
|
+
Nan::JSON NanJSON;
|
|
83
|
+
Nan::MaybeLocal<v8::Value> result = NanJSON.Parse(json_string);
|
|
84
|
+
info.GetReturnValue().Set(result.ToLocalChecked());
|
|
85
|
+
}
|
package/cc/landmark.h
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef OPENHPS_OPENVSLAM_LANDMARK_H
|
|
2
|
+
#define OPENHPS_OPENVSLAM_LANDMARK_H
|
|
3
|
+
|
|
4
|
+
#include <nan.h>
|
|
5
|
+
|
|
6
|
+
#include <stella_vslam/data/landmark.h>
|
|
7
|
+
|
|
8
|
+
class Landmark : public Nan::ObjectWrap {
|
|
9
|
+
public:
|
|
10
|
+
static void Init(v8::Local<v8::Object> exports);
|
|
11
|
+
explicit Landmark();
|
|
12
|
+
static v8::Local<v8::Object> NewInstance(std::shared_ptr<stella_vslam::data::landmark> native);
|
|
13
|
+
std::shared_ptr<stella_vslam::data::landmark> self;
|
|
14
|
+
|
|
15
|
+
private:
|
|
16
|
+
~Landmark();
|
|
17
|
+
|
|
18
|
+
static void New(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
19
|
+
static void GetPosInWorld(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
20
|
+
static void ToJSON(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
21
|
+
static void GetId(v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value>& info);
|
|
22
|
+
|
|
23
|
+
static Nan::Persistent<v8::Function> constructor;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
#endif
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#include "map_publisher.h"
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
#include <iostream>
|
|
5
|
+
|
|
6
|
+
Nan::Persistent<v8::Function> MapPublisher::constructor;
|
|
7
|
+
|
|
8
|
+
MapPublisher::MapPublisher(const stella_vslam::system* system) {
|
|
9
|
+
self = system->get_map_publisher();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
MapPublisher::~MapPublisher() {}
|
|
13
|
+
|
|
14
|
+
void MapPublisher::Init(v8::Local<v8::Object> exports) {
|
|
15
|
+
v8::Local<v8::Context> context = exports->CreationContext();
|
|
16
|
+
|
|
17
|
+
// Prepare constructor template
|
|
18
|
+
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
|
|
19
|
+
tpl->SetClassName(Nan::New("MapPublisher").ToLocalChecked());
|
|
20
|
+
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
21
|
+
|
|
22
|
+
// Prototype
|
|
23
|
+
Nan::SetPrototypeMethod(tpl, "getCurrentCamPose", GetCurrentCamPose);
|
|
24
|
+
Nan::SetPrototypeMethod(tpl, "getKeyFrames", GetKeyFrames);
|
|
25
|
+
Nan::SetPrototypeMethod(tpl, "getAllLandmarks", GetAllLandmarks);
|
|
26
|
+
Nan::SetPrototypeMethod(tpl, "getLocalLandmarks", GetLocalLandmarks);
|
|
27
|
+
|
|
28
|
+
constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
|
|
29
|
+
exports->Set(context,
|
|
30
|
+
Nan::New("MapPublisher").ToLocalChecked(),
|
|
31
|
+
tpl->GetFunction(context).ToLocalChecked());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
void MapPublisher::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
35
|
+
v8::Isolate *isolate = info.GetIsolate();
|
|
36
|
+
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
37
|
+
if (info.IsConstructCall()) {
|
|
38
|
+
// Invoked as constructor
|
|
39
|
+
System* system = Nan::ObjectWrap::Unwrap<System>(
|
|
40
|
+
info[0]->ToObject(context).ToLocalChecked());
|
|
41
|
+
MapPublisher* obj = new MapPublisher(system->self);
|
|
42
|
+
obj->Wrap(info.This());
|
|
43
|
+
info.GetReturnValue().Set(info.This());
|
|
44
|
+
} else {
|
|
45
|
+
// Invoked as plain function
|
|
46
|
+
const int argc = 1;
|
|
47
|
+
v8::Local<v8::Value> argv[argc] = {info[0]};
|
|
48
|
+
v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
|
|
49
|
+
info.GetReturnValue().Set(
|
|
50
|
+
cons->NewInstance(context, argc, argv).ToLocalChecked());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
v8::Local<v8::Object> MapPublisher::NewInstance(System* system) {
|
|
55
|
+
v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
|
|
56
|
+
const int argc = 1;
|
|
57
|
+
v8::Local<v8::Value> argv[1] = {system->handle()};
|
|
58
|
+
return Nan::NewInstance(cons, argc, argv).ToLocalChecked();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
void MapPublisher::GetCurrentCamPose(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
62
|
+
MapPublisher* obj = ObjectWrap::Unwrap<MapPublisher>(info.Holder());
|
|
63
|
+
Eigen::Matrix4d current_camera_pose = obj->self->get_current_cam_pose();
|
|
64
|
+
|
|
65
|
+
const size_t outSize = current_camera_pose.size();
|
|
66
|
+
v8::Local<v8::Array> outArray = Nan::New<v8::Array>(outSize);
|
|
67
|
+
for (size_t i = 0; i < outSize; ++i) {
|
|
68
|
+
Nan::Set(outArray, i, Nan::New<v8::Number>(*(current_camera_pose.data() + i)));
|
|
69
|
+
}
|
|
70
|
+
info.GetReturnValue().Set(outArray);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
void MapPublisher::GetKeyFrames(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
74
|
+
MapPublisher* obj = ObjectWrap::Unwrap<MapPublisher>(info.Holder());
|
|
75
|
+
std::vector<std::shared_ptr<stella_vslam::data::keyframe>> keyframes;
|
|
76
|
+
obj->self->get_keyframes(keyframes);
|
|
77
|
+
|
|
78
|
+
const size_t outSize = keyframes.size();
|
|
79
|
+
v8::Local<v8::Array> outArray = Nan::New<v8::Array>(outSize);
|
|
80
|
+
for (size_t i = 0; i < outSize; ++i) {
|
|
81
|
+
Nan::Set(outArray, i, KeyFrame::NewInstance(keyframes[i]));
|
|
82
|
+
}
|
|
83
|
+
info.GetReturnValue().Set(outArray);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
void MapPublisher::GetAllLandmarks(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
87
|
+
MapPublisher* obj = ObjectWrap::Unwrap<MapPublisher>(info.Holder());
|
|
88
|
+
std::vector<std::shared_ptr<stella_vslam::data::landmark>> allLandmarks;
|
|
89
|
+
std::set<std::shared_ptr<stella_vslam::data::landmark>> localLandmarks;
|
|
90
|
+
obj->self->get_landmarks(allLandmarks, localLandmarks);
|
|
91
|
+
|
|
92
|
+
const size_t outSize = allLandmarks.size();
|
|
93
|
+
v8::Local<v8::Array> outArray = Nan::New<v8::Array>(outSize);
|
|
94
|
+
for (size_t i = 0; i < outSize; ++i) {
|
|
95
|
+
Nan::Set(outArray, i, Landmark::NewInstance(allLandmarks[i]));
|
|
96
|
+
}
|
|
97
|
+
info.GetReturnValue().Set(outArray);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
void MapPublisher::GetLandmarks(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
void MapPublisher::GetLocalLandmarks(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
105
|
+
MapPublisher* obj = ObjectWrap::Unwrap<MapPublisher>(info.Holder());
|
|
106
|
+
std::vector<std::shared_ptr<stella_vslam::data::landmark>> allLandmarks;
|
|
107
|
+
std::set<std::shared_ptr<stella_vslam::data::landmark>> localLandmarks;
|
|
108
|
+
obj->self->get_landmarks(allLandmarks, localLandmarks);
|
|
109
|
+
|
|
110
|
+
const size_t outSize = localLandmarks.size();
|
|
111
|
+
v8::Local<v8::Array> outArray = Nan::New<v8::Array>(outSize);
|
|
112
|
+
std::set<std::shared_ptr<stella_vslam::data::landmark>>::iterator it;
|
|
113
|
+
size_t i = 0;
|
|
114
|
+
for (it = localLandmarks.begin(); it != localLandmarks.end(); ++it) {
|
|
115
|
+
Nan::Set(outArray, i, Landmark::NewInstance(*it));
|
|
116
|
+
i++;
|
|
117
|
+
}
|
|
118
|
+
info.GetReturnValue().Set(outArray);
|
|
119
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#ifndef OPENHPS_OPENVSLAM_MAPPUBLISHER_H
|
|
2
|
+
#define OPENHPS_OPENVSLAM_MAPPUBLISHER_H
|
|
3
|
+
|
|
4
|
+
#include <nan.h>
|
|
5
|
+
#include "system.h"
|
|
6
|
+
#include "landmark.h"
|
|
7
|
+
#include "keyframe.h"
|
|
8
|
+
|
|
9
|
+
#include <stella_vslam/system.h>
|
|
10
|
+
#include <stella_vslam/data/keyframe.h>
|
|
11
|
+
#include <stella_vslam/publish/map_publisher.h>
|
|
12
|
+
|
|
13
|
+
class MapPublisher : public Nan::ObjectWrap {
|
|
14
|
+
public:
|
|
15
|
+
static void Init(v8::Local<v8::Object> exports);
|
|
16
|
+
explicit MapPublisher(const stella_vslam::system* system);
|
|
17
|
+
static v8::Local<v8::Object> NewInstance(System* system);
|
|
18
|
+
|
|
19
|
+
std::shared_ptr<stella_vslam::publish::map_publisher> self;
|
|
20
|
+
|
|
21
|
+
private:
|
|
22
|
+
~MapPublisher();
|
|
23
|
+
|
|
24
|
+
static void New(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
25
|
+
static void GetCurrentCamPose(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
26
|
+
static void GetKeyFrames(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
27
|
+
static void GetLandmarks(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
28
|
+
static void GetAllLandmarks(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
29
|
+
static void GetLocalLandmarks(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
30
|
+
static Nan::Persistent<v8::Function> constructor;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
#endif
|
package/cc/openvslam.cc
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#include <nan.h>
|
|
2
|
+
#include "config.h"
|
|
3
|
+
#include "system.h"
|
|
4
|
+
#include "frame_publisher.h"
|
|
5
|
+
#include "map_publisher.h"
|
|
6
|
+
#include "landmark.h"
|
|
7
|
+
#include "keyframe.h"
|
|
8
|
+
#include "graph_node.h"
|
|
9
|
+
#include "socket_publisher/publisher.h"
|
|
10
|
+
#include <spdlog/spdlog.h>
|
|
11
|
+
|
|
12
|
+
void Init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module) {
|
|
13
|
+
// Disable logging
|
|
14
|
+
spdlog::set_level(spdlog::level::off);
|
|
15
|
+
|
|
16
|
+
Config::Init(exports);
|
|
17
|
+
System::Init(exports);
|
|
18
|
+
MapPublisher::Init(exports);
|
|
19
|
+
FramePublisher::Init(exports);
|
|
20
|
+
Landmark::Init(exports);
|
|
21
|
+
KeyFrame::Init(exports);
|
|
22
|
+
GraphNode::Init(exports);
|
|
23
|
+
Publisher::Init(exports);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
NODE_MODULE(openvslam, Init)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef OPENHPS_OPENVSLAM_PANGOLIN_VIEWER_H
|
|
2
|
+
#define OPENHPS_OPENVSLAM_PANGOLIN_VIEWER_H
|
|
3
|
+
|
|
4
|
+
#include <nan.h>
|
|
5
|
+
#include "../system.h"
|
|
6
|
+
|
|
7
|
+
#include <yaml-cpp/yaml.h>
|
|
8
|
+
#include <pangolin_viewer/viewer.h>
|
|
9
|
+
|
|
10
|
+
class Viewer : public Nan::ObjectWrap {
|
|
11
|
+
public:
|
|
12
|
+
static void Init(v8::Local<v8::Object> exports);
|
|
13
|
+
std::shared_ptr<pangolin_viewer::viewer> self;
|
|
14
|
+
|
|
15
|
+
private:
|
|
16
|
+
explicit Viewer(stella_vslam::system* system, const std::string& url);
|
|
17
|
+
~Viewer();
|
|
18
|
+
|
|
19
|
+
static void New(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
20
|
+
static void Run(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
21
|
+
static void Terminate(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
22
|
+
|
|
23
|
+
static Nan::Persistent<v8::Function> constructor;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
#endif
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#include "publisher.h"
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
class SocketPublisherWorker : public Nan::AsyncWorker {
|
|
6
|
+
public:
|
|
7
|
+
std::shared_ptr<socket_publisher::publisher> publisher;
|
|
8
|
+
|
|
9
|
+
SocketPublisherWorker(Nan::Callback *callback, std::shared_ptr<socket_publisher::publisher> publisher) : Nan::AsyncWorker(callback) {
|
|
10
|
+
this->publisher = publisher;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
~SocketPublisherWorker() {
|
|
14
|
+
this->publisher->request_terminate();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void Execute () {
|
|
18
|
+
this->publisher->run();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
virtual void HandleOKCallback() {
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
Nan::Persistent<v8::Function> Publisher::constructor;
|
|
27
|
+
|
|
28
|
+
Publisher::Publisher(stella_vslam::system* system, const std::string& url) {
|
|
29
|
+
YAML::Node node;
|
|
30
|
+
node["server_uri"] = url;
|
|
31
|
+
self = std::make_shared<socket_publisher::publisher>(node, system, system->get_frame_publisher(), system->get_map_publisher());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Publisher::~Publisher() {}
|
|
35
|
+
|
|
36
|
+
void Publisher::Init(v8::Local<v8::Object> exports) {
|
|
37
|
+
v8::Local<v8::Context> context = exports->CreationContext();
|
|
38
|
+
Nan::HandleScope scope;
|
|
39
|
+
|
|
40
|
+
// Prepare constructor template
|
|
41
|
+
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
|
|
42
|
+
tpl->SetClassName(Nan::New("SocketPublisher").ToLocalChecked());
|
|
43
|
+
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
44
|
+
|
|
45
|
+
// Prototype
|
|
46
|
+
Nan::SetPrototypeMethod(tpl, "run", Run);
|
|
47
|
+
Nan::SetPrototypeMethod(tpl, "terminate", Terminate);
|
|
48
|
+
|
|
49
|
+
constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
|
|
50
|
+
exports->Set(context,
|
|
51
|
+
Nan::New("SocketPublisher").ToLocalChecked(),
|
|
52
|
+
tpl->GetFunction(context).ToLocalChecked());
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void Publisher::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
56
|
+
v8::Isolate *isolate = info.GetIsolate();
|
|
57
|
+
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
58
|
+
if (info.IsConstructCall()) {
|
|
59
|
+
// Invoked as constructor
|
|
60
|
+
System* system = Nan::ObjectWrap::Unwrap<System>(
|
|
61
|
+
info[0]->ToObject(context).ToLocalChecked());
|
|
62
|
+
v8::String::Utf8Value url(isolate, info[1]);
|
|
63
|
+
Publisher* obj = new Publisher(system->self, std::string(*url));
|
|
64
|
+
obj->Wrap(info.This());
|
|
65
|
+
info.GetReturnValue().Set(info.This());
|
|
66
|
+
} else {
|
|
67
|
+
// Invoked as plain function
|
|
68
|
+
const int argc = 2;
|
|
69
|
+
v8::Local<v8::Value> argv[argc] = {info[0], info[1]};
|
|
70
|
+
v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
|
|
71
|
+
info.GetReturnValue().Set(
|
|
72
|
+
cons->NewInstance(context, argc, argv).ToLocalChecked());
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void Publisher::Run(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
77
|
+
Publisher* obj = ObjectWrap::Unwrap<Publisher>(info.Holder());
|
|
78
|
+
Nan::AsyncQueueWorker(new SocketPublisherWorker(nullptr, obj->self));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void Publisher::Terminate(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
82
|
+
Publisher* obj = ObjectWrap::Unwrap<Publisher>(info.Holder());
|
|
83
|
+
obj->self->request_terminate();
|
|
84
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef OPENHPS_OPENVSLAM_SOCKET_PUBLISHER_H
|
|
2
|
+
#define OPENHPS_OPENVSLAM_SOCKET_PUBLISHER_H
|
|
3
|
+
|
|
4
|
+
#include <nan.h>
|
|
5
|
+
#include "../system.h"
|
|
6
|
+
|
|
7
|
+
#include <yaml-cpp/yaml.h>
|
|
8
|
+
#include <socket_publisher/publisher.h>
|
|
9
|
+
|
|
10
|
+
class Publisher : public Nan::ObjectWrap {
|
|
11
|
+
public:
|
|
12
|
+
static void Init(v8::Local<v8::Object> exports);
|
|
13
|
+
std::shared_ptr<socket_publisher::publisher> self;
|
|
14
|
+
|
|
15
|
+
private:
|
|
16
|
+
explicit Publisher(stella_vslam::system* system, const std::string& url);
|
|
17
|
+
~Publisher();
|
|
18
|
+
|
|
19
|
+
static void New(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
20
|
+
static void Run(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
21
|
+
static void Terminate(const Nan::FunctionCallbackInfo<v8::Value>& info);
|
|
22
|
+
|
|
23
|
+
static Nan::Persistent<v8::Function> constructor;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
#endif
|
package/cc/system.cc
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
#include "system.h"
|
|
2
|
+
#include "config.h"
|
|
3
|
+
#include "frame_publisher.h"
|
|
4
|
+
#include "map_publisher.h"
|
|
5
|
+
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <iostream>
|
|
8
|
+
#include <Eigen/Core>
|
|
9
|
+
|
|
10
|
+
Nan::Persistent<v8::Function> System::constructor;
|
|
11
|
+
stella_vslam::system* self = NULL;
|
|
12
|
+
cv::Mat mask = cv::Mat{};
|
|
13
|
+
|
|
14
|
+
System::System(const Config& config, const std::string& vocab_file_path) {
|
|
15
|
+
self = new stella_vslam::system(config.self, vocab_file_path);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
System::~System() {}
|
|
19
|
+
|
|
20
|
+
void System::Init(v8::Local<v8::Object> exports) {
|
|
21
|
+
v8::Local<v8::Context> context = exports->CreationContext();
|
|
22
|
+
|
|
23
|
+
// Prepare constructor template
|
|
24
|
+
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
|
|
25
|
+
tpl->SetClassName(Nan::New("System").ToLocalChecked());
|
|
26
|
+
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
27
|
+
|
|
28
|
+
// Prototype
|
|
29
|
+
Nan::SetPrototypeMethod(tpl, "startup", Startup);
|
|
30
|
+
Nan::SetPrototypeMethod(tpl, "getFramePublisher", GetFramePublisher);
|
|
31
|
+
Nan::SetPrototypeMethod(tpl, "getMapPublisher", GetMapPublisher);
|
|
32
|
+
Nan::SetPrototypeMethod(tpl, "feedMonocularFrame", FeedMonocularFrame);
|
|
33
|
+
Nan::SetPrototypeMethod(tpl, "feedStereoFrame", FeedStereoFrame);
|
|
34
|
+
Nan::SetPrototypeMethod(tpl, "feedRGBDFrame", FeedRGBDFrame);
|
|
35
|
+
Nan::SetPrototypeMethod(tpl, "loadMap", LoadMapDatabase);
|
|
36
|
+
Nan::SetPrototypeMethod(tpl, "saveMap", SaveMapDatabase);
|
|
37
|
+
Nan::SetPrototypeMethod(tpl, "enableMapping", EnableMappingModule);
|
|
38
|
+
Nan::SetPrototypeMethod(tpl, "reset", Reset);
|
|
39
|
+
Nan::SetPrototypeMethod(tpl, "terminate", Terminate);
|
|
40
|
+
Nan::SetPrototypeMethod(tpl, "disableMapping", DisableMappingModule);
|
|
41
|
+
Nan::SetPrototypeMethod(tpl, "shutdown", Shutdown);
|
|
42
|
+
Nan::SetPrototypeMethod(tpl, "relocalizeByPose", RelocalizeByPose);
|
|
43
|
+
Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New("config").ToLocalChecked(), GetConfig);
|
|
44
|
+
|
|
45
|
+
constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
|
|
46
|
+
exports->Set(context,
|
|
47
|
+
Nan::New("System").ToLocalChecked(),
|
|
48
|
+
tpl->GetFunction(context).ToLocalChecked());
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void System::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
52
|
+
v8::Isolate *isolate = info.GetIsolate();
|
|
53
|
+
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
54
|
+
if (info.IsConstructCall()) {
|
|
55
|
+
// Invoked as constructor
|
|
56
|
+
Config* cfg = Nan::ObjectWrap::Unwrap<Config>(
|
|
57
|
+
info[0]->ToObject(context).ToLocalChecked());
|
|
58
|
+
v8::String::Utf8Value vocab_file_path(isolate, info[1]);
|
|
59
|
+
System* obj = new System(*cfg, std::string(*vocab_file_path));
|
|
60
|
+
obj->Wrap(info.This());
|
|
61
|
+
info.GetReturnValue().Set(info.This());
|
|
62
|
+
} else {
|
|
63
|
+
// Invoked as plain function
|
|
64
|
+
const int argc = 2;
|
|
65
|
+
v8::Local<v8::Value> argv[argc] = {info[0], info[1]};
|
|
66
|
+
v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
|
|
67
|
+
info.GetReturnValue().Set(
|
|
68
|
+
cons->NewInstance(context, argc, argv).ToLocalChecked());
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
void System::GetFramePublisher(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
73
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
74
|
+
info.GetReturnValue().Set(FramePublisher::NewInstance(obj));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
void System::GetMapPublisher(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
78
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
79
|
+
info.GetReturnValue().Set(MapPublisher::NewInstance(obj));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
void System::Startup(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
83
|
+
v8::Isolate *isolate = info.GetIsolate();
|
|
84
|
+
bool initialize = info[0]->IsUndefined() ? true : info[0]->BooleanValue(isolate);
|
|
85
|
+
|
|
86
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
87
|
+
obj->self->startup(initialize);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
void System::FeedMonocularFrame(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
91
|
+
v8::Isolate *isolate = info.GetIsolate();
|
|
92
|
+
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
93
|
+
|
|
94
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
95
|
+
Mat* image = Nan::ObjectWrap::Unwrap<Mat>(
|
|
96
|
+
info[0]->ToObject(context).ToLocalChecked());
|
|
97
|
+
double timestamp = info[1]->NumberValue(context).FromJust();
|
|
98
|
+
cv::Mat mask = info[2]->IsUndefined() ? obj->mask :
|
|
99
|
+
Nan::ObjectWrap::Unwrap<Mat>(
|
|
100
|
+
info[2]->ToObject(context).ToLocalChecked())->self;
|
|
101
|
+
obj->self->feed_monocular_frame(image->self, timestamp, mask);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
void System::FeedStereoFrame(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
105
|
+
v8::Isolate *isolate = info.GetIsolate();
|
|
106
|
+
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
107
|
+
|
|
108
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
109
|
+
Mat* left_image = Nan::ObjectWrap::Unwrap<Mat>(
|
|
110
|
+
info[0]->ToObject(context).ToLocalChecked());
|
|
111
|
+
Mat* right_image = Nan::ObjectWrap::Unwrap<Mat>(
|
|
112
|
+
info[1]->ToObject(context).ToLocalChecked());
|
|
113
|
+
double timestamp = info[2]->NumberValue(context).FromJust();
|
|
114
|
+
cv::Mat mask = info[3]->IsUndefined() ? obj->mask :
|
|
115
|
+
Nan::ObjectWrap::Unwrap<Mat>(
|
|
116
|
+
info[3]->ToObject(context).ToLocalChecked())->self;
|
|
117
|
+
obj->self->feed_stereo_frame(left_image->self, right_image->self, timestamp, mask);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
void System::FeedRGBDFrame(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
121
|
+
v8::Isolate *isolate = info.GetIsolate();
|
|
122
|
+
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
123
|
+
|
|
124
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
125
|
+
Mat* rgb_image = Nan::ObjectWrap::Unwrap<Mat>(
|
|
126
|
+
info[0]->ToObject(context).ToLocalChecked());
|
|
127
|
+
Mat* depth_image = Nan::ObjectWrap::Unwrap<Mat>(
|
|
128
|
+
info[1]->ToObject(context).ToLocalChecked());
|
|
129
|
+
double timestamp = info[2]->NumberValue(context).FromJust();
|
|
130
|
+
cv::Mat mask = info[3]->IsUndefined() ? obj->mask :
|
|
131
|
+
Nan::ObjectWrap::Unwrap<Mat>(
|
|
132
|
+
info[3]->ToObject(context).ToLocalChecked())->self;
|
|
133
|
+
obj->self->feed_RGBD_frame(rgb_image->self, depth_image->self, timestamp, mask);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
void System::LoadMapDatabase(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
137
|
+
v8::Isolate *isolate = info.GetIsolate();
|
|
138
|
+
|
|
139
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
140
|
+
v8::String::Utf8Value path(isolate, info[0]);
|
|
141
|
+
obj->self->load_map_database(std::string(*path));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
void System::SaveMapDatabase(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
145
|
+
v8::Isolate *isolate = info.GetIsolate();
|
|
146
|
+
|
|
147
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
148
|
+
v8::String::Utf8Value path(isolate, info[0]);
|
|
149
|
+
obj->self->save_map_database(std::string(*path));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
void System::GetConfig(v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value>& info) {
|
|
153
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
154
|
+
info.GetReturnValue().Set(Nan::New(obj->config));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
void System::RelocalizeByPose(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
158
|
+
// v8::Isolate *isolate = info.GetIsolate();
|
|
159
|
+
// v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
|
160
|
+
|
|
161
|
+
// System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
162
|
+
// stella_vslam::Mat44_t* mat = Nan::ObjectWrap::Unwrap<stella_vslam::Mat44_t>(
|
|
163
|
+
// info[0]->ToObject(context).ToLocalChecked());
|
|
164
|
+
// obj->self->relocalize_by_pose(*mat);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
void System::EnableMappingModule(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
168
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
169
|
+
obj->self->enable_mapping_module();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
void System::DisableMappingModule(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
173
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
174
|
+
obj->self->disable_mapping_module();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
void System::Shutdown(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
178
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
179
|
+
obj->self->shutdown();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
void System::Terminate(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
183
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
184
|
+
obj->self->request_terminate();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
void System::Reset(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
188
|
+
System* obj = ObjectWrap::Unwrap<System>(info.Holder());
|
|
189
|
+
obj->self->request_reset();
|
|
190
|
+
}
|