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

Initialize parameters before ROS2 callbacks #74

Conversation

amalnanavati
Copy link
Contributor

@amalnanavati amalnanavati commented Aug 23, 2024

In general, it is best practice to initial all parameters before ROS interfaces that have callbacks. Because as soon as we initialize the ROS2 interfaces, they can theoretically be called, even if their necessary parameters are not yet initialized.

A real-world example I faced on a particularly slow computer:

  1. __init__ created the joint state subscriber, but did not yet create self.__joint_names
  2. The first joint state message was received.
  3. The code crashed (because self.__joint_names) does not exist.

This PR should address issues like that.

Copy link
Owner

@AndrejOrsula AndrejOrsula left a comment

Choose a reason for hiding this comment

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

Thank you, @amalnanavati, for another contribution! Apologies for taking my time.

@AndrejOrsula AndrejOrsula merged commit 60cc171 into AndrejOrsula:master Nov 25, 2024
2 checks passed
@amalnanavati amalnanavati deleted the amaln/parameters_before-callbacks branch November 27, 2024 18:13
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.

2 participants