-
Notifications
You must be signed in to change notification settings - Fork 372
Add tests for ControllerInterface class. #662
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
Add tests for ControllerInterface class. #662
Conversation
925bfef to
a23bb91
Compare
a23bb91 to
6bdc685
Compare
|
This pull request is in conflict. Could you fix it @destogl? |
| const rclcpp_lifecycle::State & ControllerInterface::configure() | ||
| { | ||
| update_rate_ = node_->get_parameter("update_rate").as_int(); | ||
| // TODO(destogl): this should actually happen in "on_configure" but I am not sure how to get |
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.
@bmagyar please comment on this. Maybe you have an idea how to achieve the behavior I described.
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.
@destogl I am maybe more a fan of:
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
ControllerInterface::on_configure(const rclcpp_lifecycle::State &previous_state) {
if (get_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED)
{
update_rate_ = get_node()->get_parameter("update_rate").as_int();
}
return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS;
}
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
ControllerInterfaceImpl::on_configure(const rclcpp_lifecycle::State & previous_state)
{
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn cb_ret = ControllerInterface::on_configure(previous_state);
// rest of the code
return cb_ret;
}
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 is also a valid approach, for sure. @bmagyar what do you think?
The only “drawback” from my side is that uses have to explicit call this on the parent class. If someone forgets to do this, it may come with an issue that this is not working.
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 shouldn't rely on people remembering stuff for us... the code in this PR may be ugly but we don't spill complexity into user code
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.
@bmagyar @destogl We could then maybe refactor parts in the hardware_interface
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.
Generally, it looks good to me. There is only one comment regarding the configuration process.
We can decide this later when @bmagyar takes a look.
| const rclcpp_lifecycle::State & ControllerInterface::configure() | ||
| { | ||
| update_rate_ = node_->get_parameter("update_rate").as_int(); | ||
| // TODO(destogl): this should actually happen in "on_configure" but I am not sure how to get |
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.
@destogl I am maybe more a fan of:
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
ControllerInterface::on_configure(const rclcpp_lifecycle::State &previous_state) {
if (get_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_UNCONFIGURED)
{
update_rate_ = get_node()->get_parameter("update_rate").as_int();
}
return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS;
}
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
ControllerInterfaceImpl::on_configure(const rclcpp_lifecycle::State & previous_state)
{
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn cb_ret = ControllerInterface::on_configure(previous_state);
// rest of the code
return cb_ret;
}
| const rclcpp_lifecycle::State & ControllerInterface::configure() | ||
| { | ||
| update_rate_ = node_->get_parameter("update_rate").as_int(); | ||
| // TODO(destogl): this should actually happen in "on_configure" but I am not sure how to get |
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 shouldn't rely on people remembering stuff for us... the code in this PR may be ugly but we don't spill complexity into user code
|
I going to merge this to unblock other things. |
This PR adds explicit tests for the
ControllerInterfaceclass where basic behaviors are tested.The most important behavior definition here is:
update_rate parameter is read at configuration and can be updated only when controller is cleaned-up and configured again
The PR depends on #538 to be merged first.