rclnodejs 0.31.0 → 0.32.1

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.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/lib/action/client.js +1 -1
  3. package/lib/clock_type.js +0 -2
  4. package/lib/distro.js +1 -1
  5. package/lib/interface_loader.js +1 -2
  6. package/lib/lifecycle.js +0 -5
  7. package/lib/lifecycle_publisher.js +1 -1
  8. package/lib/node.js +3 -3
  9. package/lib/parameter.js +6 -9
  10. package/lib/parameter_service.js +1 -2
  11. package/lib/publisher.js +1 -1
  12. package/lib/qos.js +0 -2
  13. package/lib/rate.js +0 -1
  14. package/lib/rmw.js +12 -0
  15. package/lib/time_source.js +0 -1
  16. package/package.json +23 -21
  17. package/rosidl_gen/action_msgs.js +0 -1
  18. package/rosidl_gen/filter.js +14 -1
  19. package/rosidl_gen/generator.json +1 -1
  20. package/rosidl_gen/index.js +0 -1
  21. package/rosidl_gen/message_translator.js +2 -9
  22. package/rosidl_gen/packages.js +1 -3
  23. package/rosidl_gen/primitive_types.js +0 -4
  24. package/rosidl_gen/templates/message.dot +4 -0
  25. package/rostsd_gen/index.js +0 -3
  26. package/scripts/cpplint.js +3 -4
  27. package/scripts/generate_messages.js +1 -1
  28. package/scripts/npmjs-readme.md +1 -1
  29. package/scripts/ros_distro.js +12 -0
  30. package/scripts/run_test.js +0 -2
  31. package/src/executor.hpp +3 -3
  32. package/src/handle_manager.hpp +3 -3
  33. package/src/macros.hpp +3 -3
  34. package/src/rcl_action_bindings.hpp +3 -3
  35. package/src/rcl_bindings.cpp +7 -7
  36. package/src/rcl_bindings.hpp +3 -3
  37. package/src/rcl_handle.hpp +3 -3
  38. package/src/rcl_lifecycle_bindings.hpp +3 -3
  39. package/src/rcl_utilities.hpp +3 -3
  40. package/src/shadow_node.hpp +3 -3
  41. package/types/action_client.d.ts +0 -1
  42. package/types/action_server.d.ts +0 -1
  43. package/types/base.d.ts +27 -28
  44. package/types/index.d.ts +1 -2
  45. package/types/lifecycle.d.ts +1 -3
  46. package/types/node.d.ts +0 -1
  47. package/types/parameter.d.ts +0 -2
  48. package/types/publisher.d.ts +0 -1
  49. package/types/time.d.ts +1 -5
  50. package/.gitattributes +0 -117
  51. package/CONTRIBUTORS.md +0 -63
  52. package/electron_demo/README.md +0 -54
  53. package/electron_demo/electron-demo.gif +0 -0
  54. package/electron_demo/index.html +0 -25
  55. package/electron_demo/main.js +0 -66
  56. package/electron_demo/package.json +0 -22
  57. package/electron_demo/renderer.js +0 -22
  58. package/suppr.txt +0 -3
  59. package/types/interfaces.d.ts +0 -4482
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_RCL_ACTION_BINDINGS_HPP_
16
- #define RCLNODEJS_RCL_ACTION_BINDINGS_HPP_
15
+ #ifndef SRC_RCL_ACTION_BINDINGS_HPP_
16
+ #define SRC_RCL_ACTION_BINDINGS_HPP_
17
17
 
18
18
  #include <nan.h>
19
19
  #include <rcl/rcl.h>
@@ -28,4 +28,4 @@ extern std::vector<BindingMethod> action_binding_methods;
28
28
 
29
29
  } // namespace rclnodejs
30
30
 
31
- #endif
31
+ #endif // SRC_RCL_ACTION_BINDINGS_HPP_
@@ -40,6 +40,7 @@
40
40
  #include <rcl/service_introspection.h>
41
41
  #endif
42
42
 
43
+ #include <cstdio>
43
44
  #include <iostream>
44
45
  #include <memory>
45
46
  #include <string>
@@ -710,7 +711,6 @@ NAN_METHOD(HasContentFilter) {
710
711
  info.GetReturnValue().Set(Nan::False());
711
712
  return;
712
713
  #else
713
-
714
714
  RclHandle* subscription_handle = RclHandle::Unwrap<RclHandle>(
715
715
  Nan::To<v8::Object>(info[0]).ToLocalChecked());
716
716
  rcl_subscription_t* subscription =
@@ -964,7 +964,7 @@ NAN_METHOD(SendRequest) {
964
964
  THROW_ERROR_IF_NOT_EQUAL(rcl_send_request(client, buffer, &sequence_number),
965
965
  RCL_RET_OK, rcl_get_error_string().str);
966
966
 
967
- info.GetReturnValue().Set(Nan::New((uint32_t)sequence_number));
967
+ info.GetReturnValue().Set(Nan::New(static_cast<uint32_t>(sequence_number)));
968
968
  }
969
969
 
970
970
  NAN_METHOD(RclTakeResponse) {
@@ -981,7 +981,7 @@ NAN_METHOD(RclTakeResponse) {
981
981
  int64_t sequence_number = header.request_id.sequence_number;
982
982
 
983
983
  if (ret == RCL_RET_OK) {
984
- info.GetReturnValue().Set(Nan::New((uint32_t)sequence_number));
984
+ info.GetReturnValue().Set(Nan::New(static_cast<uint32_t>(sequence_number)));
985
985
  return;
986
986
  }
987
987
 
@@ -1162,7 +1162,7 @@ NAN_METHOD(ValidateFullTopicName) {
1162
1162
  Nan::Set(
1163
1163
  result_list, 0,
1164
1164
  Nan::New<v8::String>(std::string(validation_message)).ToLocalChecked());
1165
- Nan::Set(result_list, 1, Nan::New((int32_t)invalid_index));
1165
+ Nan::Set(result_list, 1, Nan::New(static_cast<int32_t>(invalid_index)));
1166
1166
 
1167
1167
  info.GetReturnValue().Set(result_list);
1168
1168
  }
@@ -1197,7 +1197,7 @@ NAN_METHOD(ValidateNodeName) {
1197
1197
  Nan::Set(
1198
1198
  result_list, 0,
1199
1199
  Nan::New<v8::String>(std::string(validation_message)).ToLocalChecked());
1200
- Nan::Set(result_list, 1, Nan::New((int32_t)invalid_index));
1200
+ Nan::Set(result_list, 1, Nan::New(static_cast<int32_t>(invalid_index)));
1201
1201
 
1202
1202
  info.GetReturnValue().Set(result_list);
1203
1203
  }
@@ -1232,7 +1232,7 @@ NAN_METHOD(ValidateTopicName) {
1232
1232
  Nan::Set(
1233
1233
  result_list, 0,
1234
1234
  Nan::New<v8::String>(std::string(validation_message)).ToLocalChecked());
1235
- Nan::Set(result_list, 1, Nan::New((int32_t)invalid_index));
1235
+ Nan::Set(result_list, 1, Nan::New(static_cast<int32_t>(invalid_index)));
1236
1236
 
1237
1237
  info.GetReturnValue().Set(result_list);
1238
1238
  }
@@ -1267,7 +1267,7 @@ NAN_METHOD(ValidateNamespace) {
1267
1267
  Nan::Set(
1268
1268
  result_list, 0,
1269
1269
  Nan::New<v8::String>(std::string(validation_message)).ToLocalChecked());
1270
- Nan::Set(result_list, 1, Nan::New((int32_t)invalid_index));
1270
+ Nan::Set(result_list, 1, Nan::New(static_cast<int32_t>(invalid_index)));
1271
1271
 
1272
1272
  info.GetReturnValue().Set(result_list);
1273
1273
  }
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_RCL_BINDINGS_HPP_
16
- #define RCLNODEJS_RCL_BINDINGS_HPP_
15
+ #ifndef SRC_RCL_BINDINGS_HPP_
16
+ #define SRC_RCL_BINDINGS_HPP_
17
17
 
18
18
  #include <nan.h>
19
19
  #include <rcl/graph.h>
@@ -43,4 +43,4 @@ extern std::vector<BindingMethod> binding_methods;
43
43
 
44
44
  } // namespace rclnodejs
45
45
 
46
- #endif
46
+ #endif // SRC_RCL_BINDINGS_HPP_
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_RCL_HANDLE_HPP_
16
- #define RCLNODEJS_RCL_HANDLE_HPP_
15
+ #ifndef SRC_RCL_HANDLE_HPP_
16
+ #define SRC_RCL_HANDLE_HPP_
17
17
 
18
18
  #include <nan.h>
19
19
 
@@ -68,4 +68,4 @@ class RclHandle : public Nan::ObjectWrap {
68
68
 
69
69
  } // namespace rclnodejs
70
70
 
71
- #endif
71
+ #endif // SRC_RCL_HANDLE_HPP_
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_RCL_LIFECYCLE_BINDINGS_HPP_
16
- #define RCLNODEJS_RCL_LIFECYCLE_BINDINGS_HPP_
15
+ #ifndef SRC_RCL_LIFECYCLE_BINDINGS_HPP_
16
+ #define SRC_RCL_LIFECYCLE_BINDINGS_HPP_
17
17
 
18
18
  #include <vector>
19
19
 
@@ -25,4 +25,4 @@ extern std::vector<BindingMethod> lifecycle_binding_methods;
25
25
 
26
26
  } // namespace rclnodejs
27
27
 
28
- #endif
28
+ #endif // SRC_RCL_LIFECYCLE_BINDINGS_HPP_
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_RCL_UTILITIES_HPP_
16
- #define RCLNODEJS_RCL_UTILITIES_HPP_
15
+ #ifndef SRC_RCL_UTILITIES_HPP_
16
+ #define SRC_RCL_UTILITIES_HPP_
17
17
 
18
18
  #include <string>
19
19
 
@@ -37,4 +37,4 @@ std::string GetErrorMessageAndClear();
37
37
 
38
38
  } // namespace rclnodejs
39
39
 
40
- #endif
40
+ #endif // SRC_RCL_UTILITIES_HPP_
@@ -12,8 +12,8 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
 
15
- #ifndef RCLNODEJS_SHADOW_NODE_HPP_
16
- #define RCLNODEJS_SHADOW_NODE_HPP_
15
+ #ifndef SRC_SHADOW_NODE_HPP_
16
+ #define SRC_SHADOW_NODE_HPP_
17
17
 
18
18
  #include <nan.h>
19
19
 
@@ -60,4 +60,4 @@ class ShadowNode : public Nan::ObjectWrap, public Executor::Delegate {
60
60
 
61
61
  } // namespace rclnodejs
62
62
 
63
- #endif
63
+ #endif // SRC_SHADOW_NODE_HPP_
@@ -1,4 +1,3 @@
1
- /* eslint-disable camelcase */
2
1
  declare module 'rclnodejs' {
3
2
  type ActionGoal<T> = T extends ActionTypeClassName
4
3
  ? InstanceType<ActionsMap[T]['Goal']>
@@ -1,4 +1,3 @@
1
- /* eslint-disable camelcase */
2
1
  declare module 'rclnodejs' {
3
2
  /**
4
3
  * Goal handle for working with Action Servers.
package/types/base.d.ts CHANGED
@@ -1,28 +1,27 @@
1
- /* eslint-disable spaced-comment */
2
- /// <reference path="action_client.d.ts" />
3
- /// <reference path="action_server.d.ts" />
4
- /// <reference path="action_uuid.d.ts" />
5
- /// <reference path="client.d.ts" />
6
- /// <reference path="clock_type.d.ts" />
7
- /// <reference path="clock.d.ts" />
8
- /// <reference path="context.d.ts" />
9
- /// <reference path="distro.d.ts" />
10
- /// <reference path="duration.d.ts" />
11
- /// <reference path="entity.d.ts" />
12
- /// <reference path="guard_condition.d.ts" />
13
- /// <reference path="interfaces.d.ts" />
14
- /// <reference path="lifecycle.d.ts" />
15
- /// <reference path="lifecycle_publisher.d.ts" />
16
- /// <reference path="logging.d.ts" />
17
- /// <reference path="node.d.ts" />
18
- /// <reference path="node_options.d.ts" />
19
- /// <reference path="parameter.d.ts" />
20
- /// <reference path="publisher.d.ts" />
21
- /// <reference path="qos.d.ts" />
22
- /// <reference path="rate.d.ts" />
23
- /// <reference path="service.d.ts" />
24
- /// <reference path="service_introspection.d.ts" />
25
- /// <reference path="subscription.d.ts" />
26
- /// <reference path="time_source.d.ts" />
27
- /// <reference path="time.d.ts" />
28
- /// <reference path="timer.d.ts" />
1
+ /// <reference types="./action_client.d.ts" />
2
+ /// <reference types="./action_server.d.ts" />
3
+ /// <reference types="./action_uuid.d.ts" />
4
+ /// <reference types="./client.d.ts" />
5
+ /// <reference types="./clock_type.d.ts" />
6
+ /// <reference types="./clock.d.ts" />
7
+ /// <reference types="./context.d.ts" />
8
+ /// <reference types="./distro.d.ts" />
9
+ /// <reference types="./duration.d.ts" />
10
+ /// <reference types="./entity.d.ts" />
11
+ /// <reference types="./guard_condition.d.ts" />
12
+ /// <reference types="./interfaces.d.ts" />
13
+ /// <reference types="./lifecycle.d.ts" />
14
+ /// <reference types="./lifecycle_publisher.d.ts" />
15
+ /// <reference types="./logging.d.ts" />
16
+ /// <reference types="./node.d.ts" />
17
+ /// <reference types="./node_options.d.ts" />
18
+ /// <reference types="./parameter.d.ts" />
19
+ /// <reference types="./publisher.d.ts" />
20
+ /// <reference types="./qos.d.ts" />
21
+ /// <reference types="./rate.d.ts" />
22
+ /// <reference types="./service.d.ts" />
23
+ /// <reference types="./service_introspection.d.ts" />
24
+ /// <reference types="./subscription.d.ts" />
25
+ /// <reference types="./time_source.d.ts" />
26
+ /// <reference types="./time.d.ts" />
27
+ /// <reference types="./timer.d.ts" />
package/types/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- // eslint-disable-next-line spaced-comment
2
- /// <reference path="base.d.ts" />
1
+ /// <reference types="./base.d.ts" />
3
2
 
4
3
  declare module 'rclnodejs' {
5
4
  /**
@@ -53,10 +53,8 @@ declare module 'rclnodejs' {
53
53
  asMessage(): {
54
54
  transition: SerializedState;
55
55
 
56
- // eslint-disable-next-line camelcase
57
56
  start_state: SerializedState;
58
57
 
59
- // eslint-disable-next-line camelcase
60
58
  goal_state: SerializedState;
61
59
  };
62
60
  }
@@ -249,7 +247,7 @@ declare module 'rclnodejs' {
249
247
  * Register a callback function to be invoked during the deactivate() action.
250
248
  * @param cb - The callback function to invoke.
251
249
  */
252
- registerOnDectivate(cb: TransitionCallback): void;
250
+ registerOnDeactivate(cb: TransitionCallback): void;
253
251
 
254
252
  /**
255
253
  * Register a callback function to be invoked during the cleanup() action.
package/types/node.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable camelcase */
2
1
  declare module 'rclnodejs' {
3
2
  /**
4
3
  * Identifies type of ROS message such as msg or srv.
@@ -1,5 +1,3 @@
1
- /* eslint-disable camelcase */
2
-
3
1
  declare module 'rclnodejs' {
4
2
  /**
5
3
  * The plus/minus tolerance for determining number equivalence.
@@ -8,7 +8,6 @@ declare module 'rclnodejs' {
8
8
  * Topic on which messages are published.
9
9
  */
10
10
  readonly topic: string;
11
-
12
11
  /**
13
12
  * Publish a message
14
13
  *
package/types/time.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- /* eslint-disable camelcase */
2
-
3
- import { Message, builtin_interfaces } from 'rclnodejs';
1
+ import { builtin_interfaces } from 'rclnodejs';
4
2
 
5
3
  declare module 'rclnodejs' {
6
4
  /**
@@ -100,7 +98,6 @@ declare module 'rclnodejs' {
100
98
  *
101
99
  * @returns The new Time message.
102
100
  */
103
- // eslint-disable-next-line camelcase
104
101
  toMsg(): builtin_interfaces.msg.Time;
105
102
 
106
103
  /**
@@ -110,7 +107,6 @@ declare module 'rclnodejs' {
110
107
  * @param clockType - The type of the time object. Default is ClockType.ROS_TIME
111
108
  * @returns The new Time.
112
109
  */
113
- // eslint-disable-next-line camelcase
114
110
  static fromMsg(
115
111
  msg: builtin_interfaces.msg.Time,
116
112
  clockType?: ClockType
package/.gitattributes DELETED
@@ -1,117 +0,0 @@
1
- # Based on https://github.com/alexkaratarakis/gitattributes/blob/master/Web.gitattributes
2
-
3
- # Auto detect
4
- ## Handle line endings automatically for files detected as
5
- ## text and leave all files detected as binary untouched.
6
- ## This will handle all files NOT defined below.
7
- * text=auto
8
-
9
- # Source code
10
- *.bash text eol=lf
11
- *.bat text eol=crlf
12
- *.c text eol=lf
13
- *.cmd text eol=crlf
14
- *.cpp text eol=lf
15
- *.css text diff=css
16
- *.hpp text eol=lf
17
- *.htm text diff=html
18
- *.html text diff=html
19
- *.inc text
20
- *.ini text
21
- *.js text eol=lf
22
- *.json text eol=lf
23
- *.jsx text eol=lf
24
- *.less text
25
- *.ls text
26
- *.map text -diff
27
- *.ps1 text eol=crlf
28
- *.py text diff=python
29
- *.sh text eol=lf
30
- *.ts text eol=lf
31
- *.tsx text eol=lf
32
- *.xml text eol=lf
33
- *.xhtml text diff=html
34
-
35
- # Templates
36
- *.em text eol=lf
37
-
38
- # Docker
39
- Dockerfile text
40
-
41
- # Documentation
42
- *.ipynb text
43
- *.markdown text diff=markdown
44
- *.md text diff=markdown
45
- *.mdwn text diff=markdown
46
- *.mdown text diff=markdown
47
- *.mkd text diff=markdown
48
- *.mkdn text diff=markdown
49
- *.mdtxt text
50
- *.mdtext text
51
- *.txt text
52
- AUTHORS text
53
- CHANGELOG text
54
- CHANGES text
55
- CONTRIBUTING text
56
- COPYING text
57
- copyright text
58
- *COPYRIGHT* text
59
- license text
60
- LICENSE text
61
- readme text
62
- *README* text
63
- TODO text
64
-
65
- # Configs
66
- *.cnf text
67
- *.conf text
68
- *.config text
69
- .editorconfig text
70
- .env text
71
- .gitattributes text
72
- .gitconfig text
73
- .htaccess text
74
- *.lock text -diff
75
- *.gyp text
76
- package.json text eol=lf
77
- package-lock.json text -diff
78
- pnpm-lock.yaml text eol=lf -diff
79
- yarn.lock text -diff
80
- *.toml text
81
- *.yaml text eol=lf
82
- *.yml text eol=lf
83
- Makefile text
84
- makefile text
85
-
86
- # Graphics
87
- *.bmp binary
88
- *.gif binary
89
- *.ico binary
90
- *.jng binary
91
- *.jp2 binary
92
- *.jpg binary
93
- *.jpeg binary
94
- *.jpx binary
95
- *.jxr binary
96
- *.pdf binary
97
- *.png binary
98
- # SVG treated as an asset (binary) by default.
99
- *.svg text
100
- # If you want to treat it as binary,
101
- # use the following line instead.
102
- # *.svg binary
103
- *.svgz binary
104
- *.tif binary
105
- *.tiff binary
106
- *.wbmp binary
107
- *.webp binary
108
-
109
- # Executables
110
- *.exe binary
111
- *.pyc binary
112
-
113
- # RC files (like .babelrc or .eslintrc)
114
- *.*rc text
115
-
116
- # Ignore files (like .npmignore or .gitignore)
117
- *.*ignore text
package/CONTRIBUTORS.md DELETED
@@ -1,63 +0,0 @@
1
- # rclnodejs contributors (sorted alphabetically)
2
-
3
- - **[Alaa El Jawad](https://github.com/ejalaa12), [Ian McElroy](https://github.com/imcelroy)**
4
-
5
- - Fix compatibility with ROS2 parameters array types
6
- - Unit tests for all parameter types
7
- - Handle concurrent ROS2 client calls, with unit tests
8
-
9
- - **[Alex Mikhalev](https://github.com/amikhalev)**
10
-
11
- - Fix build for AMENT_PREFIX_PATH with multiple entries
12
-
13
- - **[Felix Divo](https://github.com/felixdivo)**
14
-
15
- - Code cleanup of index.js, tests cases & message generation
16
- - Improved shutdown behavior
17
- - Fixed compilation warnings
18
-
19
- - **[Hanyia](https://github.com/hanyia)**
20
-
21
- - Benchmark test script
22
-
23
- - **[Kenny Yuan](https://github.com/kenny-y)**
24
-
25
- - Message features: JS generation, typed arrays, plain JS object, compound msgs, many others...
26
- - npm publish scripts
27
- - Mac support
28
-
29
- - **[Matt Richard](https://github.com/mattrichard)**
30
-
31
- - ROS2 Actions
32
- - Guard conditions
33
- - Node utility methods (countPublishers/subscribers...)
34
- - TypeScript improvements
35
- - Node 12 compatibility
36
-
37
- - **[Minggang Wang](https://github.com/minggangw)**
38
-
39
- - Author, lead developer, maintainer
40
- - Core, CI
41
-
42
- - **[Martins Mozeiko](https://github.com/martins-mozeiko)**
43
-
44
- - QoS new/delete fix
45
-
46
- - **[Qiuzhong](https://github.com/qiuzhong)**
47
-
48
- - Test coverage for actions, topics, multi-array messages, cross platform, security
49
- - Converted from setTimeout to ROS2 Timer
50
-
51
- - **[Teo Koon Peng](https://github.com/koonpeng)**
52
-
53
- - TypeScript improvements
54
- - Added Client#waitForService
55
- - Code style improvements, e.g., Prettier formatting
56
- - Improved code generation smarts and efficiency
57
-
58
- - **[Wayne Parrott](https://github.com/wayneparrott)**
59
- - TypeScript support with interface generation
60
- - ROS2 parameter support
61
- - ROS2 lifecycle node
62
- - Rate class
63
- - Node class hierarchy
@@ -1,54 +0,0 @@
1
- # Rclnodejs Electron demo
2
-
3
- ## Introduction
4
-
5
- This is a minimal rclnodejs demo using Electron. More information about Electron, please check with [Electron documentation](https://electronjs.org/docs/latest/tutorial/quick-start).
6
-
7
- The demo includes the following files:
8
-
9
- - `package.json` - Points to the app's main file and lists its details and dependencies.
10
- - `main.js` - Introduces the `rclnodejs` native module, starts the app and creates a browser window to render HTML. This is the app's **main process**.
11
- - `index.html` - Includes a text editor where you can input the the topic to be published. This is the app's **renderer process**.
12
- - `renderer.js` - Communicate with main process to publish a topic and get it through a subscription.
13
-
14
- ## To run the demo
15
-
16
- Before starting, please ensure you have installed [nodejs](https://nodejs.org/en).
17
-
18
- 1. Clone this repository.
19
-
20
- ```bash
21
- git clone https://github.com/RobotWebTools/rclnodejs.git
22
- ```
23
-
24
- 2. Go into the demo.
25
- ```bash
26
- cd rclnodejs/electron_demo
27
- ```
28
-
29
- 3. [SOURCE THE ROS 2 SETUP FILE](https://docs.ros.org/en/jazzy/Tutorials/Beginner-CLI-Tools/Configuring-ROS2-Environment.html#source-the-setup-files)
30
-
31
- 4. Install dependencies
32
- ```bash
33
- npm install
34
- ```
35
-
36
- 5. Rebuild rclnodejs for Electron
37
- ```bash
38
- # Every time you run "npm install", run this:
39
- ./node_modules/.bin/electron-rebuild
40
- ```
41
-
42
- 6. Run the app
43
- ```
44
- npm start
45
- ```
46
-
47
- If it works, you can see the demo as:
48
- ![demo screenshot](./electron-demo.gif)
49
-
50
- ## Resources for Learning Electron
51
-
52
- - [electronjs.org/docs](https://electronjs.org/docs) - all of Electron's documentation.
53
- - [Native Node Modules](https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules) - Use a native node module.
54
-
Binary file
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
-
4
- <head>
5
- <meta charset="UTF-8">
6
- <meta http-equiv="Content-Security-Policy"
7
- content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
8
- <title>RCLNODEJS Electron Demo</title>
9
- </head>
10
-
11
- <body>
12
- <div>
13
- <div style="height: 20px;"></div>
14
- <div>
15
- <input id="topic-input"></input>
16
- <button id="publish-topic">Publish topic</button>
17
- </div>
18
- <div style="height: 20px;"></div>
19
- <span>Received topic:</span>
20
- <span id="received-topic"></span>
21
- </div>
22
- <script src="./renderer.js"></script>
23
- </body>
24
-
25
- </html>
@@ -1,66 +0,0 @@
1
- // Licensed under the Apache License, Version 2.0 (the "License");
2
- // you may not use this file except in compliance with the License.
3
- // You may obtain a copy of the License at
4
- //
5
- // http://www.apache.org/licenses/LICENSE-2.0
6
- //
7
- // Unless required by applicable law or agreed to in writing, software
8
- // distributed under the License is distributed on an "AS IS" BASIS,
9
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- // See the License for the specific language governing permissions and
11
- // limitations under the License.
12
-
13
- const { app, BrowserWindow } = require('electron')
14
- let rclnodejs = require("rclnodejs");
15
- const { ipcMain } = require('electron');
16
-
17
- function createWindow() {
18
- // Create the browser window.
19
- const mainWindow = new BrowserWindow({
20
- width: 800,
21
- height: 600,
22
- webPreferences: {
23
- // Add the following two lines in order to use require() in renderer, see details
24
- // https://stackoverflow.com/questions/44391448/electron-require-is-not-defined
25
- nodeIntegration: true,
26
- contextIsolation: false,
27
- }
28
- });
29
-
30
- mainWindow.loadFile('index.html');
31
- }
32
-
33
- // This method will be called when Electron has finished
34
- // initialization and is ready to create browser windows.
35
- // Some APIs can only be used after this event occurs.
36
- app.whenReady().then(() => {
37
- createWindow();
38
- rclnodejs.init().then(() => {
39
- let sender = null;
40
- const node = rclnodejs.createNode('publisher_example_node');
41
- node.createSubscription('std_msgs/msg/String', 'topic', (msg) => {
42
- if (sender) {
43
- sender.send('topic-received', msg.data);
44
- }
45
- });
46
- const publisher = node.createPublisher('std_msgs/msg/String', 'topic');
47
- ipcMain.on('publish-topic', (event, topic) => {
48
- publisher.publish(topic);
49
- sender = event.sender;
50
- });
51
- rclnodejs.spin(node);
52
- });
53
-
54
- app.on('activate', function () {
55
- // On macOS it's common to re-create a window in the app when the
56
- // dock icon is clicked and there are no other windows open.
57
- if (BrowserWindow.getAllWindows().length === 0) createWindow();
58
- });
59
- });
60
-
61
- // Quit when all windows are closed, except on macOS. There, it's common
62
- // for applications and their menu bar to stay active until the user quits
63
- // explicitly with Cmd + Q.
64
- app.on('window-all-closed', function () {
65
- if (process.platform !== 'darwin') app.quit()
66
- });
@@ -1,22 +0,0 @@
1
- {
2
- "name": "rclnodejs-electron-demo",
3
- "version": "1.0.0",
4
- "description": "A minimal rclnodejs Electron application",
5
- "main": "main.js",
6
- "scripts": {
7
- "start": "electron ."
8
- },
9
- "keywords": [
10
- "Electron",
11
- "rclnodejs",
12
- "demo"
13
- ],
14
- "license": "Apache",
15
- "dependencies": {
16
- "rclnodejs": "^0.27.4"
17
- },
18
- "devDependencies": {
19
- "@electron/rebuild": "^3.6.0",
20
- "electron": "^31.0.0"
21
- }
22
- }