RobotWebTools / ros2-web-bridge

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

Is it possible to publish msg from a website to a specific robot using this ros2-web-bridge? #180

Open Hiroaki-K4 opened 3 years ago

Hiroaki-K4 commented 3 years ago

Hi, I have a question. Is it possible to publish msg from a website to a specific robot using this ros2-web-bridge? Thanks!

minggangw commented 3 years ago

I'm afraid you cannot send a topic to a specific subscriber (robot) by the current ros2-web-bridge. Will Hidden Topic or Service Names introduced in topic_and_service_names help you?

Hiroaki-K4 commented 3 years ago

@minggangw Thank you for reply. What are the uses of row-web-bridge? Does it play a role in connecting the localhost server and ros2 on the same device?

minggangw commented 3 years ago

row-web-bridge can run on an independent device and the web server connects to it through WebSocket, the ros2 can run on another device, neither the row-web-bridge nor the web server. Normally, to simply the implementation, you can install row-web-bridge and ros2 on the same machine.

minggangw commented 3 years ago

Would you use ros2cli to verify if the message has been sent practically?

minggangw commented 3 years ago

I noticed that when publishing a topic by the ros2-web-bridge, there is always an error

17:49:45 Received   Message:   {"op":"status","level":"error","msg":"publish:   TypeError: Cannot read property 'get' of undefined"} from undefined   ::ffff:127.0.0.1

I think that is why it failed. Please check if you have a field named get in the JSON object.

minggangw commented 3 years ago

Do you get these logs by running DEBUG=ros2-web-bridge* node bin/rosbridge.js?

minggangw commented 3 years ago

If you are using ros2-web-bridge and want to check if the bridge works correctly, I suggest you run DEBUG=ros2-web-bridge* node bin/rosbridge.js

minggangw commented 3 years ago

Let me try to understand your problem, and I want to clarify the difference between rosbridge_suite and ros2-web-bridge first:

gzweb uses roslibjs to communicate with the bridge implemented by a nodejs addon if I understand correctly, the bridge is not rosbridge_suite or ros2-web-bridge. Does gzweb support ROS2 already?

minggangw commented 3 years ago

I'm not clear about your entire scenario, but it seems that you use some ROS1 component?

minggangw commented 3 years ago

ros2-web-bridge is compatible with roslibjs by complying with rosbridge v2 protocol

I'm not familiar with Gazebo simulator, but I deem publishing a PoseStamped topic is enough to control your virtual robot. Would you have a brief graph for your entire framework? It seems that you use the gzweb bridge and ros2-web-bridge simultaneously?

minggangw commented 3 years ago

I'm not clear why do you need a ros2-web-bridge here. For my understanding, GzWeb's NodeJS server will work as a bridge between the Javascript and gazebo C++ side. So, what is the role of ros2-web-bridge, I think the whole system is running on ROS2.

minggangw commented 3 years ago

isn't ros2-web-bridge's node_module rclnodejs required to publish PoseStamped?

Yes, rclnodejs acts as back-end of ros2-web-bridge to access the ROS2, e.g. pub/sub a topic, but it cannot connect to the gzserver. A general usage is below:

image

newcanopies commented 3 years ago

hi @minggangw still racking my brains on this. is this the missing interface for Gazebo to receive the web-cli published message? https://github.com/RobotWebTools/tf2_web_republisher what would it take to adapt it to ROS2?

thank you!

minggangw commented 3 years ago

To adapt the tf2_web_republisher to ROS2, I think you have to re-implement it, which needs a lot of work. To identify if the ros2-web-bridge works correctly, I suggest you could change the topic type of pub and sub to PoseStamped, then you can check if the topic can be received.

newcanopies commented 3 years ago

change the topic type of pub and sub to PoseStamped, then you can check if the topic can be received.

The topic is published in the bash terminal, and can be echoed in the bash terminal with this modified Index script: $ node examples/index_rclnode.js

but the message is not displayed in the web browser:

Publisher https://gist.github.com/newcanopies/85ccc01a27a60a82fccd0fd7a1d7398e image

Subscriber https://gist.github.com/newcanopies/f679c3ad8464534d29ed5690d56a0532 image

newcanopies commented 3 years ago

Ending index_rclnode.js

gives this error:

ros2-web-bridge/node_modules/rclnodejs/lib/publisher.js:59
      rclnodejs.publish(this._handle, rawMessage);
                ^

Error: publisher pointer is invalid, at /tmp/binarydeb/ros-foxy-rcl-1.1.11/src/rcl/publisher.c:434
    at Publisher.publish (/home/user/ros2-web-bridge/node_modules/rclnodejs/lib/publisher.js:59:17)
    at Timeout._onTimeout (/home/user/ros2-web-bridge/examples/index_rclnode.js:24:17)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)

ros2-web-bridge/examples/index_rclnode.js:24:17

setInterval(function () { publisher.publish({ header{
newcanopies commented 3 years ago

hi @minggangw do you think there is an error in below scripts or bridge?

$ node examples/index_rclnode.js

Publisher

Subscriber