-
Notifications
You must be signed in to change notification settings - Fork 427
Ros2 control node #216
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
Ros2 control node #216
Changes from all commits
a5b3631
b350a48
026b760
2e53e01
5df5fc3
4d5fc13
62a4d7c
dc2e08c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Copyright 2020 ROS2-Control Development Team | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "controller_manager/controller_manager.hpp" | ||
| #include "hardware_interface/robot_hardware.hpp" | ||
| #include "rclcpp/rclcpp.hpp" | ||
| #include "test_robot_hardware/test_robot_hardware.hpp" | ||
|
|
||
| using namespace std::chrono_literals; | ||
|
|
||
| constexpr const auto kLoggerName = "ros2_control_node"; | ||
|
|
||
| int main(int argc, char ** argv) | ||
| { | ||
| rclcpp::init(argc, argv); | ||
|
|
||
| std::shared_ptr<rclcpp::Executor> executor = | ||
| std::make_shared<rclcpp::executors::MultiThreadedExecutor>(); | ||
| std::string manager_node_name = "controller_manager"; | ||
| rclcpp::TimerBase::SharedPtr timer; | ||
|
|
||
| auto cm = std::make_shared<controller_manager::ControllerManager>( | ||
| // TODO(anyone): remove robot_hw when ResourceManager is added | ||
| // since RobotHW is not a plugin we had to take some type of robot | ||
| std::make_shared<test_robot_hardware::TestRobotHardware>(), | ||
| executor, | ||
| manager_node_name); | ||
|
Comment on lines
+36
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is that? Why would you hardcode
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we need to have something here otherwise it will not work. As soon is there the The |
||
|
|
||
| // Declare default controller manager rate of 100Hz | ||
| cm->declare_parameter("update_rate", 100); | ||
| // load controller_manager update time parameter | ||
| int update_rate; | ||
| if (!cm->get_parameter("update_rate", update_rate)) { | ||
| throw std::runtime_error("update_rate parameter not existing or empty"); | ||
| } | ||
| RCLCPP_INFO(rclcpp::get_logger(kLoggerName), "update rate is %d Hz", update_rate); | ||
|
|
||
| timer = cm->create_wall_timer( | ||
| std::chrono::milliseconds(1000 / update_rate), | ||
| std::bind(&controller_manager::ControllerManager::update, cm.get()), | ||
| cm->deterministic_callback_group_); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks a bit like a dependency inversion to me. If the executor is handled outside of the controller manager in its own node, then the associated callback groups should be handled externally as well.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Realistically, I see two executors being used here. The first one spawns the controller and handles the update (as well as the read and write) loop with a given frequency. That executor can then be assigned a higher realtime priority by the operating system to guarantee a deterministic behavior. That workaround is needed as we're targeting foxy and we can't leverage the changes introduced in here: ros2/rclcpp#1218
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please submit a PR with a suggested alternative
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Karsten1987 I agree with you. I added here are @v-lopez and @gavanderhoorn commented that they want to temper with the execution of update function. Or should they then just call specialize |
||
|
|
||
| executor->add_node(cm); | ||
| executor->spin(); | ||
| rclcpp::shutdown(); | ||
| return 0; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.