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

refactor: remove lifecycle predicates and add lifecycle state getter #130

Merged
merged 5 commits into from
Jul 19, 2024

Conversation

domire8
Copy link
Member

@domire8 domire8 commented Jul 10, 2024

Description

As title suggests.
For the lifecycle state getter, I made an enum in modulo core because I feel like the ROS PRIMARY_STATE_XXX is too verbose and has a long name/namespace.

Review guidelines

Estimated Time of Review: 10 minutes

Checklist before merging:

  • Confirm that the relevant changelog(s) are up-to-date in case of any user-facing changes

bpapaspyros
bpapaspyros previously approved these changes Jul 11, 2024
Copy link
Member

@eeberhard eeberhard left a comment

Choose a reason for hiding this comment

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

I don't think that adding a wrapper enum for the primary states is particularly useful, especially if you hide all the transition states as "UNKNOWN".
I think the main use case for a component to check its own state is during parameter validation callback, which will usually happen during a primary state like inactive. But, this is also something that might feasibly happen during transition states, for example by internally setting a parameter during on_activate; treating transition states as UNKNOWN states would then make it less clear.

The underlying lifecycle node already has get_current_state() which you use here, and I think returning the rclcpp_lifecycle::State is already very useful (because you can get id() for switch cases and label() for logging). If you really want, you could just wrap the get_current_state() method with get_lifecycle_state(), but keep the same return type.

I would prefer to have this PR just remove the lifecycle predicate.

@domire8
Copy link
Member Author

domire8 commented Jul 19, 2024

Okay, I added a wrapper. It's just quite complicated to use really IMO because the return type rclcpp_lifecycle::State is different from the enum type lifecycle_msgs::msg::State::XXX

Copy link
Member

@eeberhard eeberhard left a comment

Choose a reason for hiding this comment

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

it's just quite complicated to use really IMO because the return type rclcpp_lifecycle::State is different from the enum type lifecycle_msgs::msg::State::XXX

I do agree that using the lifecycle_msgs::msgs::State::XXX is quite verbose, but again I wouldn't suggest redefining the existing standard if it leads to a loss of information with no other real gain, especially as we get both id() and label() from the State class.

@domire8 domire8 merged commit eeea583 into main Jul 19, 2024
4 checks passed
@domire8 domire8 deleted the fix/remove-predicates branch July 19, 2024 15:21
@github-actions github-actions bot locked and limited conversation to collaborators Jul 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants