Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Docmentation for running gendeps2 #44

Closed
huyaoyu opened this issue Jan 10, 2024 · 8 comments · Fixed by #47
Closed

Docmentation for running gendeps2 #44

huyaoyu opened this issue Jan 10, 2024 · 8 comments · Fixed by #47
Labels
bug Something isn't working

Comments

@huyaoyu
Copy link

huyaoyu commented Jan 10, 2024

Description

Sorry to bother you with this. I think we need simple documentation for people to run gendeps2 locally, especially for people like me who come from a C++/python background and know nothing about JavaScript/TypeScript.

  • Version: Current main branch 1b9df73
  • Platform: macOS Sonoma 14.2.1

Steps To Reproduce
Just want to use gendeps2 to generate similar files that are recorded at https://github.com/foxglove/rosmsg-msgs-common/tree/main

I have zero experience with JavaScript/TypeScript and related things. I did everything by quickly googling around. But apparently, I messed up some simple things. The following is what I did.

cd <a random place>
git clone https://github.com/foxglove/rosmsg.git
cd rosmsg
npm run build
cd ../
npm install ./rosmsg

After the above operations, I have gendeps2 available locally in my terminal. But when I do

gendeps2

I got the following error

node:internal/modules/cjs/loader:1146
  throw err;
  ^

Error: Cannot find module '../dist/gendeps2'
Require stack:
- /Users/yaoyuh/Projects/foxglove_packages/rosmsg/bin/gendeps2
    at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at Module.require (node:internal/modules/cjs/loader:1234:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/Users/yaoyuh/Projects/foxglove_packages/rosmsg/bin/gendeps2:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1375:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1434:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/yaoyuh/Projects/foxglove_packages/rosmsg/bin/gendeps2' ]
}

I checked the source folder and there is a dist folder with the content of

buildRos2Type.d.ts
buildRos2Type.d.ts.map
gendeps2.d.ts
gendeps2.d.ts.map
index.d.ts
index.d.ts.map
index.js
index.js.map
md5.d.ts
md5.d.ts.map
parse.d.ts
parse.d.ts.map
stringify.d.ts
stringify.d.ts.map

Expected Behavior

I think I have done something stupid but I cannot tell by myself. However, what I'm expecting to see is the terminal complains like

"Usage: gendeps <msgdefs-dir> <msg-file>"

as designed at

console.error("Usage: gendeps <msgdefs-dir> <msg-file>");

My final goal is to use gendeps2 to generate .msg files that look like those recorded in foxglove/rosmsg-msgs-common, where a single .msg file contains all the content of its dependent messages.

Thank you!

@huyaoyu huyaoyu added the bug Something isn't working label Jan 10, 2024
@foxhubber
Copy link

foxhubber bot commented Jan 10, 2024

Internal tracking ticket: FG-6257

@jtbandes
Copy link
Member

Based on reading #24 I believe you may need to run build:gendeps2.

What are you planning to use the generated .msg files for? I don't think this is a common workflow so I wonder if there is a better solution.

@defunctzombie
Copy link
Contributor

Related:

I thought that npx @foxglove/rosmsg gendeps2 would do it but it fails with:

node:internal/modules/cjs/loader:1051
  throw err;
  ^

Error: Cannot find module '../dist/gendeps2'
Require stack:
- /Users/roman/.npm/_npx/f2c186887b20d95e/node_modules/@foxglove/rosmsg/bin/gendeps2
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/Users/roman/.npm/_npx/f2c186887b20d95e/node_modules/@foxglove/rosmsg/bin/gendeps2:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/roman/.npm/_npx/f2c186887b20d95e/node_modules/@foxglove/rosmsg/bin/gendeps2'
  ]
}

Node.js v20.9.0

I suspect we don't actually build gendeps2 for the library release which would make sense since it has nothing to do with the features of the library. Maybe we need a new home for it?

@huyaoyu
Copy link
Author

huyaoyu commented Jan 11, 2024

Reply to jtbandes

Thank you for the instructions! It is now working.

What are you planning to use the generated .msg files for? I don't think this is a common workflow so I wonder if there is a better solution.

I'm trying to write custom ROS2 messages directly to an MCAP file. By reading the documentation of MCAP, I figured that I need a special .msg file that contains the definitions of all the other dependant .msgs. Since I will have many customized ROS2 messages and I want some tools to help me to automatically generate the special .msg files whenever the definitions of the customized messages change. Then I found gendeps2 and I figured I could use it for my purpose.

Do you have a recommended workflow for similar tasks?

Thanks!

@jtbandes
Copy link
Member

jtbandes commented Jan 11, 2024

@huyaoyu
Copy link
Author

huyaoyu commented Jan 12, 2024

Do you mean that even for customized messages, the ways shown in the above python/c++ examples can write messages directly to MCAP? Then how do the schemes of the custom messages get set up for the MCAP writer?

@jtbandes
Copy link
Member

@huyaoyu
Copy link
Author

huyaoyu commented Jan 29, 2024

Yes, rosbag2 handles it internally. See https://github.com/ros2/rosbag2/blob/rolling/docs/message_definition_encoding.md

Thank you for pointing me to the documentation.

Sorry, I think I didn't mention that I need to do this as an offline pre-processing because I'm working on an iOS App that does not have (good) support for C++/Python. I am trying to write customized data as ROS2 messages and save them into an MCAP file. My current solution is generating these .msg files for my customized messages and using these files in the App.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

3 participants