Skip to content

Add ROS2TFClient#731

Merged
EzraBrooks merged 6 commits intoRobotWebTools:developfrom
pac48:pr-add-TF2Client
Jun 10, 2024
Merged

Add ROS2TFClient#731
EzraBrooks merged 6 commits intoRobotWebTools:developfrom
pac48:pr-add-TF2Client

Conversation

@pac48
Copy link
Copy Markdown
Contributor

@pac48 pac48 commented May 29, 2024

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

pac48 added 2 commits May 28, 2024 09:58
Signed-off-by: Paul Gesel <paul.gesel@picknik.ai>
Signed-off-by: Paul Gesel <paul.gesel@picknik.ai>
Copy link
Copy Markdown
Contributor

@EzraBrooks EzraBrooks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! Can you explain the API difference between your ROS 2 version of tf2_web_republisher and the ROS 1 version? If we can figure out a way to unify them (instead of renaming this ROS2TFClient or similar) that would be ideal!

/**
* A TF Client that listens to TFs from tf2_web_republisher.
*/
export default class TF2Client extends EventEmitter {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be called something like ROS2TFClient, since "TF2" works on both ROS1 and ROS2.

}
this.currentGoal = goalMessage;

// this.currentGoal.on('feedback', this.processTFArray.bind(this));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code

// this.currentGoal.on('feedback', this.processTFArray.bind(this));
const id = this.actionClient.sendGoal(goalMessage,
(result) => {
console.log('Result for action goal on :');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not pollute the logs with debug info

this.updateDelay = options.updateDelay || 50;
var seconds = options.topicTimeout || 2.0;
var secs = Math.floor(seconds);
var nsecs = Math.floor((seconds - secs) * 1E9);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicky but change these var to const

pac48 and others added 2 commits May 30, 2024 09:38
Co-authored-by: Ezra Brooks <ezra@brooks.cx>
@pac48 pac48 marked this pull request as ready for review June 3, 2024 16:15
Copy link
Copy Markdown
Contributor

@EzraBrooks EzraBrooks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as a first cut. Naming it ROS2TFClient makes extra certain that we won't accidentally step on ROS 1 users' toes. Later on it may make sense to combine the two classes and use a flag, or something like that.

@EzraBrooks
Copy link
Copy Markdown
Contributor

EzraBrooks commented Jun 10, 2024

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.

@EzraBrooks EzraBrooks changed the title Add TF2Client Add ROS2TFClient Jun 10, 2024
@EzraBrooks EzraBrooks merged commit 233aaba into RobotWebTools:develop Jun 10, 2024
@pfarinha91
Copy link
Copy Markdown

pfarinha91 commented Jun 18, 2024

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

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

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

@pfarinha91
Copy link
Copy Markdown

pfarinha91 commented Jun 18, 2024

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

I've created the Discussion topic on #742

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

Successfully merging this pull request may close these issues.

4 participants