-
Notifications
You must be signed in to change notification settings - Fork 304
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 controller starting with later load of robot description test #1624
Fix controller starting with later load of robot description test #1624
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1624 +/- ##
==========================================
+ Coverage 87.30% 87.60% +0.29%
==========================================
Files 108 108
Lines 9866 9918 +52
Branches 890 889 -1
==========================================
+ Hits 8614 8689 +75
+ Misses 929 912 -17
+ Partials 323 317 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -327,6 +327,61 @@ TEST_F(TestLoadController, unload_on_kill) | |||
ASSERT_EQ(cm_->get_loaded_controllers().size(), 0ul); | |||
} | |||
|
|||
TEST_F(TestLoadController, spawner_test_fallback_controllers) |
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.
Why was this moved?
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 moved it for better log tracking as the newly added test is placed in between an original test.
ros2_control/controller_manager/test/test_spawner_unspawner.cpp
Lines 330 to 407 in 9d1aff9
class TestLoadControllerWithoutRobotDescription | |
: public ControllerManagerFixture<controller_manager::ControllerManager> | |
{ | |
public: | |
TestLoadControllerWithoutRobotDescription() | |
: ControllerManagerFixture<controller_manager::ControllerManager>("") | |
{ | |
} | |
void SetUp() override | |
{ | |
ControllerManagerFixture::SetUp(); | |
update_timer_ = cm_->create_wall_timer( | |
std::chrono::milliseconds(10), | |
[&]() | |
{ | |
cm_->read(time_, PERIOD); | |
cm_->update(time_, PERIOD); | |
cm_->write(time_, PERIOD); | |
}); | |
update_executor_ = | |
std::make_shared<rclcpp::executors::MultiThreadedExecutor>(rclcpp::ExecutorOptions(), 2); | |
update_executor_->add_node(cm_); | |
update_executor_spin_future_ = | |
std::async(std::launch::async, [this]() -> void { update_executor_->spin(); }); | |
// This sleep is needed to prevent a too fast test from ending before the | |
// executor has began to spin, which causes it to hang | |
std::this_thread::sleep_for(50ms); | |
} | |
void TearDown() override { update_executor_->cancel(); } | |
rclcpp::TimerBase::SharedPtr robot_description_sending_timer_; | |
protected: | |
rclcpp::TimerBase::SharedPtr update_timer_; | |
// Using a MultiThreadedExecutor so we can call update on a separate thread from service callbacks | |
std::shared_ptr<rclcpp::Executor> update_executor_; | |
std::future<void> update_executor_spin_future_; | |
}; | |
TEST_F(TestLoadControllerWithoutRobotDescription, when_no_robot_description_spawner_times_out) | |
{ | |
cm_->set_parameter(rclcpp::Parameter("ctrl_1.type", test_controller::TEST_CONTROLLER_CLASS_NAME)); | |
ControllerManagerRunner cm_runner(this); | |
EXPECT_EQ(call_spawner("ctrl_1 -c test_controller_manager"), 256) | |
<< "could not spawn controller because not robot description and not services for controller " | |
"manager are active"; | |
} | |
TEST_F( | |
TestLoadControllerWithoutRobotDescription, | |
controller_starting_with_later_load_of_robot_description) | |
{ | |
cm_->set_parameter(rclcpp::Parameter("ctrl_1.type", test_controller::TEST_CONTROLLER_CLASS_NAME)); | |
// Delay sending robot description | |
robot_description_sending_timer_ = cm_->create_wall_timer( | |
std::chrono::milliseconds(2500), [&]() { pass_robot_description_to_cm_and_rm(); }); | |
ControllerManagerRunner cm_runner(this); | |
EXPECT_EQ(call_spawner("ctrl_1 -c test_controller_manager"), 0) | |
<< "could not activate control because not robot description"; | |
ASSERT_EQ(cm_->get_loaded_controllers().size(), 1ul); | |
{ | |
auto ctrl_1 = cm_->get_loaded_controllers()[0]; | |
ASSERT_EQ(ctrl_1.info.name, "ctrl_1"); | |
ASSERT_EQ(ctrl_1.info.type, test_controller::TEST_CONTROLLER_CLASS_NAME); | |
ASSERT_EQ(ctrl_1.c->get_state().id(), lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE); | |
} | |
} |
diagnostics_updater_.setHardwareID("ros2_control"); | ||
diagnostics_updater_.add( | ||
"Controllers Activity", this, &ControllerManager::controller_activity_diagnostic_callback); | ||
init_controller_manager(); |
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.
Did we have all this duplicated code here the whole time?
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.
Well only from the #1358. So it is not so long
@@ -305,6 +295,10 @@ void ControllerManager::robot_description_callback(const std_msgs::msg::String & | |||
init_resource_manager(robot_description_); | |||
if (is_resource_manager_initialized()) | |||
{ | |||
RCLCPP_INFO( |
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.
Isn't this a debug print?
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.
yes! it is. I think it is very helpful to know somehow via log that it initialized properly and we are going to start the services. If you want, I can remove it as well. I'm fine with anything
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.
A few small questions, sorry for the vagueness, can't do proper checks from the phone
Done. Thanks for reviewing it quickly |
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.
Thanks for dealing with it. May also fix #1620
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.
Thanks for the great work!
* [ResourceManager] Make destructor virtual for use in derived classes (#1607) * Fix typos in test_resource_manager.cpp (#1609) * [CM] Remove support for the description parameter and use only `robot_description` topic (#1358) --------- Co-authored-by: Felix Exner <exner@fzi.de> Co-authored-by: Christoph Froehlich <christoph.froehlich@ait.ac.at> * move critical variables to the private context (#1623) * Fix controller starting with later load of robot description test (#1624) * Fix the duplicated restart of the controller_manager services initialization * Scope the ControllerManagerRunner to avoid malloc and other test issues * reorder the tests for consistent log at the end * Remove noqa (#1626) * Unused header cleanup (#1627) * Create debugging.rst (#1625) --------- Co-authored-by: Sai Kishor Kothakota <saisastra3@gmail.com> Co-authored-by: Christoph Froehlich <christoph.froehlich@ait.ac.at> * Update changelogs * 4.14.0 * add missing rclcpp logging include for Humble compatibility build (#1635) * [CM] Remove deprecated spawner args (#1639) * Add a pytest launch file to test ros2_control_node (#1636) * Fix rst markup (#1642) * Fix rqt_cm paragraph * Fix indent * CM: Add missing includes (#1641) * [RM] Add `get_hardware_info` method to the Hardware Components (#1643) * Fix the namespaced controller_manager spawner + added tests (#1640) * Bump version of pre-commit hooks (#1649) Co-authored-by: christophfroehlich <3367244+christophfroehlich@users.noreply.github.com> * Add missing include for executors (#1653) * Update changelogs * 4.15.0 * refactor SwitchParams to fix the incosistencies in the spawner tests (#1638) * Modify test with missing CM to have a timeout * Catch exception when CM services are not found And print the error and exit in the application * Exit with code 1 on unreached CM --------- Co-authored-by: Sai Kishor Kothakota <sai.kishor@pal-robotics.com> Co-authored-by: Parker Drouillard <parker@pepcorp.ca> Co-authored-by: Dr. Denis <denis@stoglrobotics.de> Co-authored-by: Christoph Froehlich <christoph.froehlich@ait.ac.at> Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com> Co-authored-by: Henry Moore <henry.moore@picknik.ai> Co-authored-by: Lennart Nachtigall <firesurfer127@gmail.com> Co-authored-by: Sai Kishor Kothakota <saisastra3@gmail.com> Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: christophfroehlich <3367244+christophfroehlich@users.noreply.github.com>
Fixes the failing tests in the ros2_control_ci jobs: ros-controls/ros2_control_ci#98 after the recent merge of #1358. The following tests is failing
TestLoadControllerWithoutRobotDescription.controller_starting_with_later_load_of_robot_description
. This PR tries to address this as well as some minor adjustments needed to clean the codeFixes: ros-controls/ros2_control_ci#98
Fixes: #1620