-
Notifications
You must be signed in to change notification settings - Fork 292
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
fix: 🐛 make force_torque_sensor_broadcaster wait for realtime_publisher #327
Conversation
…er loop to be ready before finishing configure refs: ros-controls#263
Thank you for finding this! I have a few questions about possible solutions.
|
We could just add a sleep to the test and that should work. I personally prefer synchronizing tests so there is no way they can fail but I couldn't find a way to do that from the test directly as the publisher is a protected member. If you think a sleep would be better, I'd be be happy to switch it. If there are only two threads in the test then it would seem very unlikely to fail as cpu time should go to the publisher thread. You are correct. The real world affect is that messages would get dropped near the beginning of initialization. |
if you need to access protected members from tests, then you can use
Direct sync, as you proposed, is a much better approach. |
I wouldn't classify this as behaviour modification, it simply ensures better initialization in perhaps a throttled warning in the lock-loop would be useful to detect cases of deadlocks? |
I would still prefer direct sync in the tests for this. Just to make them more (100%?) stable. |
I propose the following resolution of this issue:
One more question before proceeding as suggested: Do we then actually acquire lock in the line 127 to set default values? @jaron-l can you please check this if you didn't yet? |
I'm not sure I know what you mean for setting default values but yes, the lock is acquired there and used for setting the message frame id. I briefly investigated moving the wait to the real time publisher constructor and that seems like the best route; however, I hit a problem that I'm still investigating. I'll report back tomorrow. |
Okay, I think I understand better what is going on. Hopefully this makes sense. The root of the problem is that So if the publisher thread is running, why are messages getting dropped? It's because the the publisher periodically obtains a lock. If the publisher thread holds the lock, or Proposed solutions:
As a side note, we could still implement the wait in the |
Few more possibilities:
|
…caster - create a loop that checks if force_torque_sensor_broadcaster published before checking subscribed message refs: ros-controls#263
My most recent commits show how solution 1 would work. I tested it and I couldn't get it to fail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Can you "roll-out" this solution to the IMUController
and JTC
?
…oint_state_broadcaster refs: ros-controls#263
I ported changed to |
@jaron-l sorry, I introduced |
I went ahead and removed them. Should be good to go now. |
…er (ros-controls#327) * fix: 🐛 make force_torque_sensor_broadcaster wait for realtime_publisher loop to be ready before finishing configure * test: ✅ check for published message in test_force_torque_sensor_broadcaster - create a loop that checks if force_torque_sensor_broadcaster published before checking subscribed message * refactor: ♻️ remove unnecessary includes * test: ✅ port realtime_publisher check to imu_sensor_broadcaster and joint_state_broadcaster * refactor: ♻️ remove unnecessary wait_for code from tests Co-authored-by: Denis Štogl <denis@stogl.de>
The referenced issue shows that some of the tests in
test_force_torque_sensor_broadcaster
are flaky. This is because therealtime_publisher
thread doesn't have time to start before the test tries to publish a message. Any subscription test will fail as the message will not get published if the publishing thread hasn't started.This is one example solution, but since it modifies the life-cycle behavior of
force_torque_sensor_broadcaster
, I'm not exactly aware of all of the consequences. I imagine that most nodes will wait for the broadcaster to move to the inactive state anyways so this shouldn't have a negative effect but I am open to feedback.refs: #263