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.
@bmagyar please comment on this. Maybe you have an idea how to achieve the behavior I described.
There was a problem hiding this comment.
@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.
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.
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.
@bmagyar @destogl We could then maybe refactor parts in the hardware_interface
| 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.
@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.
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.