-
Notifications
You must be signed in to change notification settings - Fork 336
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 LifecycleNode in tests #1470
Conversation
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.
The changes look good to me. The range_sensor_broadcaster tests seem to fail. Can you take a look?
[ RUN ] RangeSensorBroadcasterTest.Initialize_RangeBroadcaster_Exception
unknown file: Failure
C++ exception with description "Lifecycle node hasn't been initialized yet!" thrown in TearDown().
[ FAILED ] RangeSensorBroadcasterTest.Initialize_RangeBroadcaster_Exception (0 ms)
try | ||
{ | ||
controller_->get_node()->shutdown(); | ||
} | ||
catch (...) | ||
{ | ||
// ignore case where node is not initialized | ||
} |
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.
try | |
{ | |
controller_->get_node()->shutdown(); | |
} | |
catch (...) | |
{ | |
// ignore case where node is not initialized | |
} | |
if(controller_->get_node().get_state() != lifecycle_msgs::msg::State::PRIMARY_STATE_UNKNOWN) | |
{ | |
controller_->get_node()->shutdown(); | |
} |
I think it is better to have it like this no?. trying and catching everything might hide some issues we might add in future. What's your opinion on this @christophfroehlich ?. If you think it's fine, I'm okay with it
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.
The following code
if(range_broadcaster_->get_node()->get_current_state().id() != lifecycle_msgs::msg::State::PRIMARY_STATE_UNKNOWN)
{
range_broadcaster_->get_node()->shutdown();
}
still throws
2: [ RUN ] RangeSensorBroadcasterTest.Initialize_RangeBroadcaster_Exception
2: unknown file: Failure
2: C++ exception with description "Lifecycle node hasn't been initialized yet!" thrown in TearDown().
here
I don't see any other possibility with the controller_interface API.
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.
we could only catch std::runtime_error
and rethrow others.
Or we change the upstream API to check if the node is initialized or add a shutdown method, which itself checks if the node is initialized.
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.
Ahh I didn't know that this exception is in the controller interface base. If this is the case, we can add an upstream API to check if the controller is initialized or may be in the destructor of the base class, call shutdown if the node is valid and also the state makes sense. What do you think?
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.
we never trigger the shutdown transition in the controller_manager, maybe this is a bug we should solve?
Currently we only have virtual default destructors of the ControllerInterfaceBase
and ControllerInterface
class, where would you add that?
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.
I would say in the destructor of the controller_interface_base. As that's the common one for both normal and chained controllers
As suggested by @saikishor we should fix that upstream -> ros-controls/ros2_control#1979 |
Since ros2/rclcpp#2562 we get lots of warnings in the test logs like
Triggering the shutdown transition before calling the destructor fixes this.