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

Move communication setup to on_configure instead of on_activate #732

Merged
merged 3 commits into from
Feb 26, 2024

Conversation

fmauch
Copy link
Collaborator

@fmauch fmauch commented Jul 5, 2023

Corrects point of initialization / connection to the robot by moving it to on_configure instead of on_activate.

@destogl we talked about this yesterday, I found my commit I had in mind :-)

Copy link
Collaborator

@RobertWilbrandt RobertWilbrandt left a comment

Choose a reason for hiding this comment

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

This change seems reasonable, but if we start all communication in on_configure i would expect the corresponding cleanup to move to on_cleanup.

@firesurfer
Copy link
Contributor

@fmauch Just saw this PR and thought I take a look at it as it might has the potential breaking multiarm support. Given that on_configure and on_activate run in different threads (configure in the non rt and activate in the rt one) - If I understood the documentation right - I would suggest changing:

bool rtde_comm_has_been_started_ = false;

to

std::atomic_bool rtde_comm_has_been_started_ = false;

This goes btw. probably also for all other variables which are used from multiple threads (e.g. everything being set by URPositionHardwareInterface::checkAsyncIO())

@mergify mergify bot added the humble Relevant for humble and higher ROS versions label Aug 28, 2023
@fmauch fmauch self-assigned this Nov 14, 2023
@fmauch fmauch marked this pull request as draft November 14, 2023 11:05
@firesurfer
Copy link
Contributor

@fmauch I agree with you. For passing information between the non-rt and rt thread and std::atomic_bool should be used in this case.

This goes btw. probably also for all other variables which are used from multiple threads (e.g. everything being set by URPositionHardwareInterface::checkAsyncIO())

In general you are right. Often one can get away with it if only one thread writes and one thread reads and it is okey to have partially updated data.
But in this case I would use the RTBuffer from the realtime_tools package.

@fmauch
Copy link
Collaborator Author

fmauch commented Nov 14, 2023

@firesurfer yes, thank you for your comments. Thread safety is definitively something we need to tackle at some point. For now, for this PR I would restrict things to the rtde_comm_has_been_started_ member.

@fmauch fmauch marked this pull request as ready for review November 14, 2023 12:36
@fmauch fmauch requested review from VinDp and urmahp February 1, 2024 19:52
@fmauch
Copy link
Collaborator Author

fmauch commented Feb 1, 2024

I just rebased and tested this. Especially with the deprecation and upcoming removal of passing the robot_description as a parameter and instead using a topic this becomes a required step.

@fmauch fmauch removed the humble Relevant for humble and higher ROS versions label Feb 1, 2024
Copy link
Collaborator

@VinDp VinDp left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@fmauch
Copy link
Collaborator Author

fmauch commented Feb 25, 2024

@RobertWilbrandt a review from you would be required to merge this.

Copy link
Collaborator

@RobertWilbrandt RobertWilbrandt left a comment

Choose a reason for hiding this comment

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

Sorry about that, i was not aware that i needed to be the person to re-review this. Looks good now.

@RobertWilbrandt RobertWilbrandt merged commit da7b09f into UniversalRobots:main Feb 26, 2024
7 checks passed
mergify bot pushed a commit that referenced this pull request Feb 26, 2024
* Move communication setup to on_configure instead of on_activate

* Cleanup in on_cleanup instead on_deactivate

* Use std::atomic_bool for rtde_comm_has_been_started_

(cherry picked from commit da7b09f)
@fmauch fmauch deleted the improve_initialization branch February 26, 2024 09:35
@fmauch
Copy link
Collaborator Author

fmauch commented Feb 26, 2024

@Mergifyio backport iron

Copy link

mergify bot commented Feb 26, 2024

backport iron

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Feb 26, 2024
* Move communication setup to on_configure instead of on_activate

* Cleanup in on_cleanup instead on_deactivate

* Use std::atomic_bool for rtde_comm_has_been_started_

(cherry picked from commit da7b09f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants