Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Hiroaki-K4 opened this issue Mar 2, 2021 · 17 comments

Comments

@Hiroaki-K4
Copy link

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
Copy link
Member

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
Copy link
Author

@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
Copy link
Member

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
Copy link
Member

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

@minggangw
Copy link
Member

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
Copy link
Member

minggangw commented Apr 23, 2021

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

@minggangw
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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

@minggangw
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Contributor

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
Copy link
Member

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
Copy link
Contributor

newcanopies commented May 27, 2021

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
Copy link
Contributor

newcanopies commented May 27, 2021

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
Copy link
Contributor

newcanopies commented Jun 7, 2021

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

$ node examples/index_rclnode.js

Publisher

Subscriber

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants