RobotWebTools / ros2-web-bridge

Bridging your browser to the ROS 2.0
Apache License 2.0
208 stars 68 forks source link

does ros2-web-bridge support to pub or sub msgs created by user ? #110

Closed lxbeyond closed 6 years ago

lxbeyond commented 6 years ago

I want to use ros2-web-bridge to transport msgs created by myself, but a error occurs as follow: ros2-web-bridge:Bridge Exception caught in Bridge.executeCommand(): Error: The message required does not exist: entity_msgs, msg, EntityMsg @minggangw

minggangw commented 6 years ago

Yes, it supports. The process of generating the messages from user defined .msg or .srv is handled by rclnodejs, not the ros2-web-bridge. To achieve this, please add the path of your .msg files to the AMENT_PREFIX_PATH variable.

If you add these .msg files after the installation of ros2-web-bridge, you have to manually reinstall the rclnodejs which will trigger the generation again. (actually, the rclnodejs has function which can generate the messages compulsively, but the bridge doesn't make use of it)

minggangw commented 6 years ago

I am going to close this issue, @lxbeyond please feel free to reopen it if you still cannot to create the messages defined by yourself.

rukie commented 5 years ago

I could use a little direction here. I'm trying to add ackermann msgs that I used in ROS1 to a Unity environment. It doesn't look like Ackermann is in ROS2 yet.

minggangw commented 5 years ago

If you want to leverage a customized msg, the usage is different from ROS1. The general steps I can think about are:

rukie commented 5 years ago

So I was able to get a new message to compile. I sourced it. Running ros2 msg list, my ackermann message shows up. ros2 msg show gives me the info on it.

Trying

cd ~/ros2-web-bridge
node bin/rosbridge.js

gives me

/home/rukie/ros2-web-bridge/node_modules/bindings/bindings.js:121
        throw e;
        ^

Error: The module '/home/rukie/ros2-web-bridge/node_modules/rclnodejs/build/Release/rclnodejs.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 72. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:800:18)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at bindings (/home/rukie/ros2-web-bridge/node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (/home/rukie/ros2-web-bridge/node_modules/rclnodejs/lib/logging.js:18:38)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
npm install

gives me

up to date in 12.54s

and

npm rebuild

gives me

> rclnodejs@0.9.0 install /home/rukie/ros2-web-bridge/node_modules/rclnodejs
> node-gyp rebuild

make: Entering directory '/home/rukie/ros2-web-bridge/node_modules/rclnodejs/build'
  CXX(target) Release/obj.target/rclnodejs/src/addon.o
  CXX(target) Release/obj.target/rclnodejs/src/executor.o
../src/executor.cpp:17:10: fatal error: rcl/error_handling.h: No such file or directory
 #include <rcl/error_handling.h>
          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
rclnodejs.target.mk:126: recipe for target 'Release/obj.target/rclnodejs/src/executor.o' failed
make: *** [Release/obj.target/rclnodejs/src/executor.o] Error 1
make: Leaving directory '/home/rukie/ros2-web-bridge/node_modules/rclnodejs/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/rukie/.nvm/versions/node/v10.15.2/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 4.18.0-18-generic
gyp ERR! command "/home/rukie/.nvm/versions/node/v10.15.2/bin/node" "/home/rukie/.nvm/versions/node/v10.15.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/rukie/ros2-web-bridge/node_modules/rclnodejs
gyp ERR! node -v v10.15.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! rclnodejs@0.9.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the rclnodejs@0.9.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/rukie/.npm/_logs/2019-04-30T13_14_33_630Z-debug.log

And now I'm all kinds of confused.

minggangw commented 5 years ago

Did you source your .bash for your ROS2? It seems that the headers cannot be found through your path env.

rukie commented 5 years ago

Full context: I initially installed ROS2 with apt binaries and that functioned fine. I wanted to create a new message, and couldn't compile without FASTRTPS, so I compiled ROS2 from source. I removed /opt/ros/crystal from my .bash script, and instead source ~/ros2_ws where it was compiled. My ackermann message is compiled in a different folder, ~/ackermann.

I source ~/ros2_ws, and source ~/ackermann. I do get a warning from opensplice_cmake_module that OSPL_URI is set to ~/ros2_ws and it won't overwrite the default of /opt/ros/crystal.

source ros2_ws/install/setup.bash 
source ackermann/install/setup.bash

gives

[opensplice_cmake_module] Warning: OSPL_URI was already set to [[file:///home/rukie/ros2_ws/install/opensplice_cmake_module/share/opensplice_cmake_module/config/ros_ospl.xml]]. This will not override it to the ROS default [[file:///opt/ros/crystal/share/opensplice_cmake_module/config/ros_ospl.xml]]. Please make sure this is the config that you want.
minggangw commented 5 years ago

Thanks for your detailed information, if you build your ROS2 from scratch, you have to use the flag --merge-install which will install all packages into a combined directory. Finally, source the local_setup*.

rukie commented 5 years ago

Thank you for all the help, sorry this isn't directly related to ros2-web-bridge anymore. I've done the following:

cd ~/ros2_ws
colcon build --symlink-install --merge-install

with no issues, followed by

source ~/ros2_ws/install/local_setup.bash

and I get

not found: /home/rukie/ros2_ws/install/share/$packagehere/local_setup.sh
not found: /home/rukie/ros2_ws/install/share/$packagehere/local_setup.bash

I guess I'm still not sure what merge-install does exactly.

After reading about overlays I'm pretty confident I'd want to source local_setup.bash for ROS, and setup.bash for my ackermann message.

I'm a little stuck here.