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

Not quite solved #1

Open
nslay opened this issue Dec 12, 2018 · 5 comments
Open

Not quite solved #1

nslay opened this issue Dec 12, 2018 · 5 comments

Comments

@nslay
Copy link

nslay commented Dec 12, 2018

I think this is a very clever solution. In fact, when I read your response in some github PR, I almost immediately knew this should be the solution to the problem!

However, when playing with, say, 20+ static transforms, somehow static_transform_mux is not necessarily the last /tf_static message recorded/played back by rosbag record/play. I don't know why or how the messages get fumbled or received, stored or played out of order, just that they do and that this clever solution is not 100%. In fact, it doesn't work most of the time with one or two stray static transforms somehow arriving or playing back after the aggregate /tf_static message is sent by static_transform_mux (no matter what I do, whether I start it first or last or 10 seconds after... it doesn't matter).

@peci1
Copy link
Member

peci1 commented Dec 13, 2018

Hi, thanks for the feedback. Would you think some periodic publishing (e.g. once in 1 or 10 seconds) would help? I could add that as an option.

@nslay
Copy link
Author

nslay commented Dec 13, 2018

Yeah. As long as static_transform_mux eventually has the last say, this solution will work! I find it completely confusing that static_transform_mux's message does not already arrive last. But I suppose there is no guarantee that rosbag record necessarily process or receive in order the 20+ messages from multiple nodes publishing to /tf_static. If it was on a single TCP connection, it should be in order. But I think ROS is probably more point-to-point and that there are actually 20+ connections. Throw in callback queues and maybe some parallel processing aspects happening in rosbag record, it's probably only more confusing to think about!

Alternatively, static_transform_publisher could be taught to do what static_transform_mux already does, except from the start and with 1 single TFMessage. My solution was to make a multiple_static_transform_publisher that reads a file line-by-line with each line having static_transform_publisher-like arguments. Then I simply publish one single combined TFMessage like static_transform_mux and all my rosbag headaches go away. I think this is a bit more elegant than having a launch file... ~20 lines vs hundreds saturated by XML formatting.

This, of course, doesn't mean static_transform_mux isn't still useful. If someone wanted to publish static transforms from multiple nodes (for whatever reason), then my solution doesn't apply anymore.

@peci1
Copy link
Member

peci1 commented Dec 13, 2018

That's exactly what we do - we have zillions of launch files for various sensors, and some of them need to publish some static transforms - and the easiest way to do that is to put a line in the launch file... So we also have like 10 static TF publishers...

So no, editing static_transform_publisher is also not a general solution... I think a really working general solution would need a big rework of the already exising API, which is IMO not happening any more in ROS 1.

@nslay
Copy link
Author

nslay commented Dec 13, 2018

Yeah... latched topics are a real mess! It works out from rosbag play if you slowly step through the initial /tf_static messages one at a time so that every node receives each message. But when these messages are sent too quickly, a node does not necessarily see all of them.

Before playing with aggregated TFMessage, I was originally just pressing the step key 20 times until rviz or rostopic echo would see each one. Very annoying...

I think if static_transform_mux sends the transforms periodically, this would be a good and general workaround.

@ihadzic
Copy link

ihadzic commented Dec 20, 2022

Might be a bit belated comment relative to when this was open, but the only way I was able to fully solve the problem is to separate the mux input and mux output topics. That requires always running the mux and remapping all sources of tf_static topic to use a different topic name (e.g. tf_static_in). That guarantees that /tf_static has one and only one publisher which resolves the race discussed above.

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