pubo-web 1.0.13 → 1.0.17

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.
@@ -1,244 +0,0 @@
1
- var __assign = this && this.__assign || function () {
2
- __assign = Object.assign || function (t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
-
6
- for (var p in s) {
7
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
- }
9
- }
10
-
11
- return t;
12
- };
13
-
14
- return __assign.apply(this, arguments);
15
- };
16
-
17
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) {
19
- return value instanceof P ? value : new P(function (resolve) {
20
- resolve(value);
21
- });
22
- }
23
-
24
- return new (P || (P = Promise))(function (resolve, reject) {
25
- function fulfilled(value) {
26
- try {
27
- step(generator.next(value));
28
- } catch (e) {
29
- reject(e);
30
- }
31
- }
32
-
33
- function rejected(value) {
34
- try {
35
- step(generator["throw"](value));
36
- } catch (e) {
37
- reject(e);
38
- }
39
- }
40
-
41
- function step(result) {
42
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
43
- }
44
-
45
- step((generator = generator.apply(thisArg, _arguments || [])).next());
46
- });
47
- };
48
-
49
- var __generator = this && this.__generator || function (thisArg, body) {
50
- var _ = {
51
- label: 0,
52
- sent: function sent() {
53
- if (t[0] & 1) throw t[1];
54
- return t[1];
55
- },
56
- trys: [],
57
- ops: []
58
- },
59
- f,
60
- y,
61
- t,
62
- g;
63
- return g = {
64
- next: verb(0),
65
- "throw": verb(1),
66
- "return": verb(2)
67
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
68
- return this;
69
- }), g;
70
-
71
- function verb(n) {
72
- return function (v) {
73
- return step([n, v]);
74
- };
75
- }
76
-
77
- function step(op) {
78
- if (f) throw new TypeError("Generator is already executing.");
79
-
80
- while (_) {
81
- try {
82
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
83
- if (y = 0, t) op = [op[0] & 2, t.value];
84
-
85
- switch (op[0]) {
86
- case 0:
87
- case 1:
88
- t = op;
89
- break;
90
-
91
- case 4:
92
- _.label++;
93
- return {
94
- value: op[1],
95
- done: false
96
- };
97
-
98
- case 5:
99
- _.label++;
100
- y = op[1];
101
- op = [0];
102
- continue;
103
-
104
- case 7:
105
- op = _.ops.pop();
106
-
107
- _.trys.pop();
108
-
109
- continue;
110
-
111
- default:
112
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
113
- _ = 0;
114
- continue;
115
- }
116
-
117
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
118
- _.label = op[1];
119
- break;
120
- }
121
-
122
- if (op[0] === 6 && _.label < t[1]) {
123
- _.label = t[1];
124
- t = op;
125
- break;
126
- }
127
-
128
- if (t && _.label < t[2]) {
129
- _.label = t[2];
130
-
131
- _.ops.push(op);
132
-
133
- break;
134
- }
135
-
136
- if (t[2]) _.ops.pop();
137
-
138
- _.trys.pop();
139
-
140
- continue;
141
- }
142
-
143
- op = body.call(thisArg, _);
144
- } catch (e) {
145
- op = [6, e];
146
- y = 0;
147
- } finally {
148
- f = t = 0;
149
- }
150
- }
151
-
152
- if (op[0] & 5) throw op[1];
153
- return {
154
- value: op[0] ? op[1] : void 0,
155
- done: true
156
- };
157
- }
158
- };
159
-
160
- import ROSLIB from 'roslib';
161
- import { InjectUtil } from './inject';
162
- import { basePointCloudOptions, loadLib } from './utils';
163
-
164
- var RosViewer =
165
- /** @class */
166
- function () {
167
- function RosViewer(configure) {
168
- this.iu = new InjectUtil();
169
- this.configure = configure;
170
- }
171
-
172
- RosViewer.prototype.init = function (_a) {
173
- var elem = _a.elem,
174
- _b = _a.view,
175
- view = _b === void 0 ? {} : _b,
176
- _c = _a.tf,
177
- tf = _c === void 0 ? {} : _c;
178
- return __awaiter(this, void 0, void 0, function () {
179
- var _d, tfClient;
180
-
181
- return __generator(this, function (_e) {
182
- switch (_e.label) {
183
- case 0:
184
- if (!this.configure.conf.ros3d_lib_url) {
185
- throw new Error('ros3djs lib not found');
186
- }
187
-
188
- _d = this;
189
- return [4
190
- /*yield*/
191
- , loadLib(this.configure.conf.ros3d_lib_url)];
192
-
193
- case 1:
194
- _d.ROS3D = _e.sent();
195
- this.elem = elem;
196
- this.iu.install('ros', this.configure.ros);
197
- this.viewer = new this.ROS3D.Viewer(__assign({
198
- elem: elem,
199
- width: elem.clientWidth,
200
- height: elem.clientHeight,
201
- antialias: true,
202
- cameraPose: {
203
- x: 100,
204
- y: 100,
205
- z: 100
206
- },
207
- displayPanAndZoomFrame: false,
208
- background: '#000000'
209
- }, view));
210
- this.iu.install('rootObject', this.viewer.scene);
211
- tfClient = this.iu.inject(ROSLIB.TFClient, __assign({
212
- angularThres: 0.01,
213
- transThres: 0.01,
214
- fixedFrame: '/base_link'
215
- }, tf));
216
- this.iu.install('tfClient', tfClient);
217
- return [2
218
- /*return*/
219
- ];
220
- }
221
- });
222
- });
223
- };
224
-
225
- RosViewer.prototype.destroy = function () {
226
- if (this.viewer && typeof this.viewer.stop === 'function') {
227
- this.viewer.stop();
228
- }
229
-
230
- this.elem.innerHTML = '';
231
- };
232
-
233
- RosViewer.prototype.initPointClouds = function (optList) {
234
- var _this = this;
235
-
236
- return optList.map(function (opt) {
237
- return _this.iu.inject(_this.ROS3D.PointCloud2, __assign(__assign({}, basePointCloudOptions), opt));
238
- });
239
- };
240
-
241
- return RosViewer;
242
- }();
243
-
244
- export { RosViewer };
@@ -1,14 +0,0 @@
1
- interface RosConfig {
2
- ros_bridge_url: string;
3
- ros3d_lib_url?: string;
4
- }
5
- export declare class RosConfigure {
6
- private _conf;
7
- private readonly getConfig;
8
- private _ros;
9
- constructor(getConfig: () => Promise<RosConfig>);
10
- get conf(): RosConfig;
11
- get ros(): any;
12
- init(): Promise<void>;
13
- }
14
- export {};
@@ -1,243 +0,0 @@
1
- "use strict";
2
-
3
- var __assign = this && this.__assign || function () {
4
- __assign = Object.assign || function (t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
-
8
- for (var p in s) {
9
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
- }
11
- }
12
-
13
- return t;
14
- };
15
-
16
- return __assign.apply(this, arguments);
17
- };
18
-
19
- var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
20
- function adopt(value) {
21
- return value instanceof P ? value : new P(function (resolve) {
22
- resolve(value);
23
- });
24
- }
25
-
26
- return new (P || (P = Promise))(function (resolve, reject) {
27
- function fulfilled(value) {
28
- try {
29
- step(generator.next(value));
30
- } catch (e) {
31
- reject(e);
32
- }
33
- }
34
-
35
- function rejected(value) {
36
- try {
37
- step(generator["throw"](value));
38
- } catch (e) {
39
- reject(e);
40
- }
41
- }
42
-
43
- function step(result) {
44
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
45
- }
46
-
47
- step((generator = generator.apply(thisArg, _arguments || [])).next());
48
- });
49
- };
50
-
51
- var __generator = this && this.__generator || function (thisArg, body) {
52
- var _ = {
53
- label: 0,
54
- sent: function sent() {
55
- if (t[0] & 1) throw t[1];
56
- return t[1];
57
- },
58
- trys: [],
59
- ops: []
60
- },
61
- f,
62
- y,
63
- t,
64
- g;
65
- return g = {
66
- next: verb(0),
67
- "throw": verb(1),
68
- "return": verb(2)
69
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
70
- return this;
71
- }), g;
72
-
73
- function verb(n) {
74
- return function (v) {
75
- return step([n, v]);
76
- };
77
- }
78
-
79
- function step(op) {
80
- if (f) throw new TypeError("Generator is already executing.");
81
-
82
- while (_) {
83
- try {
84
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
85
- if (y = 0, t) op = [op[0] & 2, t.value];
86
-
87
- switch (op[0]) {
88
- case 0:
89
- case 1:
90
- t = op;
91
- break;
92
-
93
- case 4:
94
- _.label++;
95
- return {
96
- value: op[1],
97
- done: false
98
- };
99
-
100
- case 5:
101
- _.label++;
102
- y = op[1];
103
- op = [0];
104
- continue;
105
-
106
- case 7:
107
- op = _.ops.pop();
108
-
109
- _.trys.pop();
110
-
111
- continue;
112
-
113
- default:
114
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
115
- _ = 0;
116
- continue;
117
- }
118
-
119
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
120
- _.label = op[1];
121
- break;
122
- }
123
-
124
- if (op[0] === 6 && _.label < t[1]) {
125
- _.label = t[1];
126
- t = op;
127
- break;
128
- }
129
-
130
- if (t && _.label < t[2]) {
131
- _.label = t[2];
132
-
133
- _.ops.push(op);
134
-
135
- break;
136
- }
137
-
138
- if (t[2]) _.ops.pop();
139
-
140
- _.trys.pop();
141
-
142
- continue;
143
- }
144
-
145
- op = body.call(thisArg, _);
146
- } catch (e) {
147
- op = [6, e];
148
- y = 0;
149
- } finally {
150
- f = t = 0;
151
- }
152
- }
153
-
154
- if (op[0] & 5) throw op[1];
155
- return {
156
- value: op[0] ? op[1] : void 0,
157
- done: true
158
- };
159
- }
160
- };
161
-
162
- var __importDefault = this && this.__importDefault || function (mod) {
163
- return mod && mod.__esModule ? mod : {
164
- "default": mod
165
- };
166
- };
167
-
168
- Object.defineProperty(exports, "__esModule", {
169
- value: true
170
- });
171
- exports.RosConfigure = void 0;
172
-
173
- var roslib_1 = __importDefault(require("roslib"));
174
-
175
- var RosConfigure =
176
- /** @class */
177
- function () {
178
- function RosConfigure(getConfig) {
179
- this._conf = null;
180
- this._ros = null;
181
- this.getConfig = getConfig;
182
- }
183
-
184
- Object.defineProperty(RosConfigure.prototype, "conf", {
185
- get: function get() {
186
- var initialValues = {};
187
-
188
- if (!this._conf) {
189
- return initialValues;
190
- }
191
-
192
- return __assign({}, this._conf);
193
- },
194
- enumerable: false,
195
- configurable: true
196
- });
197
- Object.defineProperty(RosConfigure.prototype, "ros", {
198
- get: function get() {
199
- if (!this._ros) {
200
- throw Error('please init first!');
201
- }
202
-
203
- return this._ros;
204
- },
205
- enumerable: false,
206
- configurable: true
207
- });
208
-
209
- RosConfigure.prototype.init = function () {
210
- return __awaiter(this, void 0, void 0, function () {
211
- var _a;
212
-
213
- return __generator(this, function (_b) {
214
- switch (_b.label) {
215
- case 0:
216
- if (this._conf) {
217
- return [2
218
- /*return*/
219
- ];
220
- }
221
-
222
- _a = this;
223
- return [4
224
- /*yield*/
225
- , this.getConfig()];
226
-
227
- case 1:
228
- _a._conf = _b.sent();
229
- this._ros = new roslib_1["default"].Ros({
230
- url: this._conf.ros_bridge_url
231
- });
232
- return [2
233
- /*return*/
234
- ];
235
- }
236
- });
237
- });
238
- };
239
-
240
- return RosConfigure;
241
- }();
242
-
243
- exports.RosConfigure = RosConfigure;
@@ -1,32 +0,0 @@
1
- import ROSLIB from 'roslib';
2
- import { RosConfigure } from './configure';
3
- import type { CreateFactory } from './super';
4
- interface RosActionConfig {
5
- serverName: string;
6
- actionName: string;
7
- }
8
- interface TopicType {
9
- name: string;
10
- messageType: string;
11
- }
12
- interface RoseServiceConfig {
13
- name: string;
14
- serviceType: string;
15
- }
16
- declare type RoseServiceFunc = (payload: any) => Promise<any>;
17
- declare type RoseActionFunc = (goalMessage: any) => Promise<any>;
18
- interface RosTopic extends ROSLIB.Topic {
19
- publishMessage: (payload: any) => void;
20
- }
21
- declare type RosTopicFunc = () => RosTopic;
22
- export declare class RosUtils {
23
- private readonly configure;
24
- constructor(configure: RosConfigure);
25
- private readonly publishService;
26
- private readonly publishAction;
27
- private readonly rosTopic;
28
- createRosService: CreateFactory<RoseServiceConfig, RoseServiceFunc>;
29
- createRosAction: CreateFactory<RosActionConfig, RoseActionFunc>;
30
- createRosTopic: CreateFactory<TopicType, RosTopicFunc>;
31
- }
32
- export {};
@@ -1,130 +0,0 @@
1
- "use strict";
2
-
3
- var __assign = this && this.__assign || function () {
4
- __assign = Object.assign || function (t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
-
8
- for (var p in s) {
9
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
- }
11
- }
12
-
13
- return t;
14
- };
15
-
16
- return __assign.apply(this, arguments);
17
- };
18
-
19
- var __importDefault = this && this.__importDefault || function (mod) {
20
- return mod && mod.__esModule ? mod : {
21
- "default": mod
22
- };
23
- };
24
-
25
- Object.defineProperty(exports, "__esModule", {
26
- value: true
27
- });
28
- exports.RosUtils = void 0;
29
-
30
- var roslib_1 = __importDefault(require("roslib"));
31
-
32
- var super_1 = require("./super");
33
-
34
- var RosUtils =
35
- /** @class */
36
- function () {
37
- function RosUtils(configure) {
38
- var _this = this;
39
-
40
- this.configure = null;
41
-
42
- this.publishService = function (_a) {
43
- var name = _a.name,
44
- serviceType = _a.serviceType,
45
- payload = _a.payload;
46
- return new Promise(function (resolve, reject) {
47
- var service = new roslib_1["default"].Service({
48
- ros: _this.configure.ros,
49
- name: name,
50
- serviceType: serviceType
51
- });
52
- var request = new roslib_1["default"].ServiceRequest(payload);
53
- service.callService(request, resolve, reject);
54
- });
55
- };
56
-
57
- this.publishAction = function (_a) {
58
- var serverName = _a.serverName,
59
- actionName = _a.actionName,
60
- goalMessage = _a.goalMessage;
61
- return new Promise(function (resolve, reject) {
62
- var actionClient = new roslib_1["default"].ActionClient({
63
- ros: _this.configure.ros,
64
- serverName: serverName,
65
- actionName: actionName,
66
- timeout: 0
67
- });
68
- var goal = new roslib_1["default"].Goal({
69
- actionClient: actionClient,
70
- goalMessage: goalMessage
71
- });
72
- goal.on('result', function (result) {
73
- return resolve(result);
74
- });
75
- goal.on('error', function (err) {
76
- return reject(err);
77
- });
78
- goal.send();
79
- });
80
- };
81
-
82
- this.rosTopic = function (props) {
83
- var topic = new roslib_1["default"].Topic(__assign({
84
- ros: _this.configure.ros
85
- }, props));
86
-
87
- topic.publishMessage = function (payload) {
88
- if (typeof topic.publish === 'function') {
89
- topic.publish(new roslib_1["default"].Message(payload));
90
- }
91
- };
92
-
93
- return topic;
94
- };
95
-
96
- this.createRosService = function (services) {
97
- return super_1.superFactory(function (options) {
98
- return function (payload) {
99
- return _this.publishService(__assign(__assign({}, options), {
100
- payload: payload
101
- }));
102
- };
103
- })(services);
104
- };
105
-
106
- this.createRosAction = function (actions) {
107
- return super_1.superFactory(function (options) {
108
- return function (goalMessage) {
109
- return _this.publishAction(__assign(__assign({}, options), {
110
- goalMessage: goalMessage
111
- }));
112
- };
113
- })(actions);
114
- };
115
-
116
- this.createRosTopic = function (topic) {
117
- return super_1.superFactory(function (options) {
118
- return function () {
119
- return _this.rosTopic(options);
120
- };
121
- })(topic);
122
- };
123
-
124
- this.configure = configure;
125
- }
126
-
127
- return RosUtils;
128
- }();
129
-
130
- exports.RosUtils = RosUtils;
@@ -1,11 +0,0 @@
1
- declare type OptionsObject<T, C> = {
2
- [key in keyof T]: C;
3
- };
4
- declare type ProductsObject<T, F> = {
5
- [key in keyof T]: F;
6
- };
7
- declare type Factory<C> = (config: C) => any;
8
- export declare type CreateFactory<C, F> = <T>(apis: OptionsObject<T, C>) => ProductsObject<T, F>;
9
- export declare type SuperFactory = <C, F>(factory: Factory<C>) => CreateFactory<C, F>;
10
- export declare const superFactory: SuperFactory;
11
- export {};