RobotWebTools / roslibjs

The Standard ROS JavaScript Library
https://robotwebtools.github.io/roslibjs
Other
659 stars 372 forks source link

Add `ROS2TFClient` #731

Closed pac48 closed 3 weeks ago

pac48 commented 1 month ago

This PR adds a ROS2TFClient class to interact with the ROS 2 tf2_web_republisher.

EzraBrooks commented 3 weeks ago

For posterity, the "ROS 2 version of tf2_web_republisher" we are currently working against is @pac48's fork of it at https://github.com/pac48/tf2_web_republisher. We're still deciding where this implementation should live long-term; it may become a ros2 branch of the RobotWebTools project that is largely currently defunct.

pfarinha91 commented 2 weeks ago

Thanks for your work on this TF2 client for ROS2!

I'm trying to make this approach work on a react application, but I'm struggling. I stumbled upon this thread and this one, changed the Roslibjs version on package.json to github:pac48/roslibjs#pr-add-TF2Client. Installed it and the rosbridge complained about not having the send_action goal operation. Basically actions are still not implemented on the main release of rosbridge for Ros Humble, which is behind the repository. So I cloned and compiled the most recent version of rosbridge, launched the websocket plus the tf2_web_republisher fork from @pac48 and I finally can subscribe to TFs and they start arriving through the callback! But...

I can't unsubscribe or dispose the ROS2TFClient when the parent React component unmounts (or in any moment whatsoever). Worst, the moment I subscribe to a new frame using the client, I can no longer unsubscribe from any topic (even in normal subscribers) and eventually WebSocketClosedError: Tried to write to a closed websocket errors start raining on the rosbridge websocket if I try to reconnect.

EzraBrooks commented 2 weeks ago

Hi, that's interesting - I'm not experiencing the same symptom. Could you start a Discussion on this topic? I can provide some insight there as to integrating this with React (as my team is also using it with React), but would rather have that conversation in a Discussion than a PR thread so we can "mark as answer" when we find the solution :)

EzraBrooks commented 2 weeks ago

I just realized Discussions weren't enabled here - I've enabled them!

pfarinha91 commented 2 weeks ago

Thanks! Are you talking about discourse.ros.org? When I try to create a Discussion it redirects there.

Edit: nevermind, thay have appeared now!

pfarinha91 commented 1 week ago

I've created the Discussion topic on https://github.com/RobotWebTools/roslibjs/discussions/742