rclnodejs 0.26.1 → 0.27.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.
package/lib/client.js CHANGED
@@ -73,7 +73,7 @@ class Client extends Entity {
73
73
  this._sequenceNumberToCallbackMap.delete(sequenceNumber);
74
74
  callback(response.toPlainObject(this.typedArrayEnabled));
75
75
  } else {
76
- throw new Error(
76
+ debug(
77
77
  `Client has received an unexpected ${this._serviceName} with sequence number ${sequenceNumber}.`
78
78
  );
79
79
  }
package/lib/distro.js CHANGED
@@ -24,6 +24,7 @@ const DistroId = {
24
24
  GALACTIC: 2105,
25
25
  HUMBLE: 2205,
26
26
  IRON: 2305,
27
+ JAZZY: 2405,
27
28
  ROLLING: 5000,
28
29
  };
29
30
 
@@ -33,6 +34,7 @@ DistroNameIdMap.set('foxy', DistroId.FOXY);
33
34
  DistroNameIdMap.set('galactic', DistroId.GALACTIC);
34
35
  DistroNameIdMap.set('humble', DistroId.HUMBLE);
35
36
  DistroNameIdMap.set('iron', DistroId.IRON);
37
+ DistroNameIdMap.set('jazzy', DistroId.JAZZY);
36
38
  DistroNameIdMap.set('rolling', DistroId.ROLLING);
37
39
 
38
40
  const DistroUtils = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rclnodejs",
3
- "version": "0.26.1",
3
+ "version": "0.27.1",
4
4
  "description": "ROS2.0 JavaScript client with Node.js",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rosidl-generator",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "Generate JavaScript object from ROS IDL(.msg) files",
5
5
  "main": "index.js",
6
6
  "authors": [
@@ -20,6 +20,7 @@ const packages = require('./packages.js');
20
20
  const path = require('path');
21
21
 
22
22
  const generatedRoot = path.join(__dirname, '../generated/');
23
+ const serviceMsgPath = path.join(generatedRoot, 'srv_msg');
23
24
 
24
25
  function getInstalledPackagePaths() {
25
26
  return process.env.AMENT_PREFIX_PATH.split(path.delimiter);
@@ -50,7 +51,7 @@ async function generateAll(forcedGenerating) {
50
51
  path.join(__dirname, 'generator.json'),
51
52
  path.join(generatedRoot, 'generator.json')
52
53
  );
53
-
54
+ await fse.mkdir(serviceMsgPath);
54
55
  // Process in AMENT_PREFIX_PATH in reverse order to
55
56
  // such that interfaces defined earlier on the AMENX_PREFIX_PATH
56
57
  // have higher priority over earlier versions and will override
@@ -26,6 +26,7 @@ const pkgFilters = require('../rosidl_gen/filter.js');
26
26
  const fsp = fs.promises;
27
27
 
28
28
  const generatedRoot = path.join(__dirname, '../generated/');
29
+ const serviceMsgPath = path.join(generatedRoot, 'srv_msg');
29
30
 
30
31
  function getPackageName(filePath, amentExecuted) {
31
32
  if (os.type() === 'Windows_NT') {
@@ -131,6 +132,58 @@ async function getPackageDefinitionsFiles(packageName, amentRoot) {
131
132
  return rosFiles;
132
133
  }
133
134
 
135
+ async function generateMsgForSrv(filePath, interfaceInfo, pkgMap) {
136
+ const requestMsgName = `${path.parse(filePath).name}_Request.msg`;
137
+ const responseMsgName = `${path.parse(filePath).name}_Response.msg`;
138
+ const data = await fsp.readFile(filePath, 'utf8');
139
+
140
+ const arr = data.split(/-{3,}/);
141
+ if (arr.length == 2) {
142
+ const packagePath = path.join(serviceMsgPath, interfaceInfo.pkgName);
143
+ if (!fs.existsSync(packagePath)) {
144
+ fs.mkdirSync(packagePath);
145
+ }
146
+
147
+ await fsp.writeFile(path.join(packagePath, requestMsgName), arr[0]);
148
+ await fsp.writeFile(path.join(packagePath, responseMsgName), arr[1]);
149
+ let requestInfo = Object.assign({}, interfaceInfo);
150
+ requestInfo.filePath = path.join(packagePath, requestMsgName);
151
+ requestInfo.interfaceName = requestInfo.interfaceName + "_Request"
152
+ let responseInfo = Object.assign({}, interfaceInfo);
153
+ responseInfo.filePath = path.join(packagePath, responseMsgName);
154
+ responseInfo.interfaceName = responseInfo.interfaceName + "_Response"
155
+
156
+ addInterfaceInfo(requestInfo, 'messages', pkgMap);
157
+ addInterfaceInfo(responseInfo, 'messages', pkgMap);
158
+ }
159
+ }
160
+
161
+ async function addInterfaceInfos(filePath, dir, pkgMap) {
162
+ const interfaceInfo = grabInterfaceInfo(filePath, true);
163
+ const ignore = pkgFilters.matchesAny(interfaceInfo);
164
+ if (ignore) {
165
+ console.log('Omitting filtered interface: ', interfaceInfo);
166
+ } else {
167
+ if (path.extname(filePath) === '.msg') {
168
+ // Some .msg files were generated prior to 0.3.2 for .action files,
169
+ // which has been disabled. So these files should be ignored here.
170
+ if (path.dirname(dir).split(path.sep).pop() !== 'action') {
171
+ addInterfaceInfo(interfaceInfo, 'messages', pkgMap);
172
+ }
173
+ } else if (path.extname(filePath) === '.srv') {
174
+ const requestMsgName = `${path.parse(filePath).name}_Request.msg`;
175
+ if (!fs.existsSync(path.join(path.dirname(filePath), requestMsgName))) {
176
+ await generateMsgForSrv(filePath, interfaceInfo, pkgMap);
177
+ }
178
+ addInterfaceInfo(interfaceInfo, 'services', pkgMap);
179
+ } else if (path.extname(filePath) === '.action') {
180
+ addInterfaceInfo(interfaceInfo, 'actions', pkgMap);
181
+ } else {
182
+ // we ignore all other files
183
+ }
184
+ }
185
+ }
186
+
134
187
  /**
135
188
  * Collects all packages in a directory by using the ament index.
136
189
  * @param {string} dir - the directory to search in
@@ -144,32 +197,11 @@ async function findAmentPackagesInDirectory(dir) {
144
197
 
145
198
  // Support flat() method for nodejs < 11.
146
199
  const rosFiles = Array.prototype.flat ? files.flat() : flat(files);
147
-
148
200
  const pkgMap = new Map();
149
- return new Promise((resolve, reject) => {
150
- rosFiles.forEach((filePath) => {
151
- const interfaceInfo = grabInterfaceInfo(filePath, true);
152
- const ignore = pkgFilters.matchesAny(interfaceInfo);
153
- if (ignore) {
154
- console.log('Omitting filtered interface: ', interfaceInfo);
155
- } else {
156
- if (path.extname(filePath) === '.msg') {
157
- // Some .msg files were generated prior to 0.3.2 for .action files,
158
- // which has been disabled. So these files should be ignored here.
159
- if (path.dirname(dir).split(path.sep).pop() !== 'action') {
160
- addInterfaceInfo(interfaceInfo, 'messages', pkgMap);
161
- }
162
- } else if (path.extname(filePath) === '.srv') {
163
- addInterfaceInfo(interfaceInfo, 'services', pkgMap);
164
- } else if (path.extname(filePath) === '.action') {
165
- addInterfaceInfo(interfaceInfo, 'actions', pkgMap);
166
- } else {
167
- // we ignore all other files
168
- }
169
- }
170
- });
171
- resolve(pkgMap);
172
- });
201
+ await Promise.all(
202
+ rosFiles.map(filePath => addInterfaceInfos(filePath, dir, pkgMap))
203
+ );
204
+ return pkgMap;
173
205
  }
174
206
 
175
207
  /**