RobotWebTools / ros2-web-bridge

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

Failed to recieve self-defined messages via bridge #153

Open mayuribh opened 4 years ago

mayuribh commented 4 years ago

Let's say I have created a message Allmsg in the package named my_msgs. I am not able to receive the message when subscribed to the concerned topic. I get an error stating the message required does not exist

ros2-web-bridge:Bridge JSON command received: {"op":"subscribe","id":"subscribe:/nmea:1","type":"my_msgs/Allmsg","topic":"/nmea","compression":"none","throttle_rate":0,"queue_length":0} +112ms ros2-web-bridge:Bridge subscribe a topic named /nmea +1ms ros2-web-bridge:Bridge Response: {"op":"status","level":"error","msg":"subscribe: Error: The message required does not exist: my_msgs, msg, Allmsg","id":"subscribe:/nmea:1"} +2ms

I am able to successfully subscribe and publish this above topic within ROS but the same with connecting over the bridge gives me and issue.

Here is my code for creating a new object for a topic with the related message type.

var txt_listener = new ROSLIB.Topic({
ros : ros,
name : '/nmea',
messageType : 'my_msgs/Allmsg'
minggangw commented 4 years ago

I think the root cause is that you created and compiled the message (my_msgs/Allmsg) defined by yourself after you ran the web bridge the first time. Normally, the generated JS messages are generated when the first time you run the web bridge, and if you want to add other message types later, you have to regenerate them forcibly, which is not exposed to the web bridge.

One possible solution is: delete $YOUR_APP_PATH/node_modules/rclnodejs/generated/ manually, then re-run the web bridge which will trigger the regeneration of all JS messages.