-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a test controller that fails at activation
- Loading branch information
Lennart Nachtigall
committed
Apr 19, 2024
1 parent
47a7245
commit a6a4d5d
Showing
4 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
controller_manager/test/test_controller_failed_activate/test_controller_failed_activate.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2021 Department of Engineering Cybernetics, NTNU. | ||
// | ||
// 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 "test_controller_failed_activate.hpp" | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "lifecycle_msgs/msg/transition.hpp" | ||
|
||
namespace test_controller_failed_activate | ||
{ | ||
TestControllerFailedActivate::TestControllerFailedActivate() | ||
: controller_interface::ControllerInterface() | ||
{ | ||
} | ||
|
||
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn | ||
TestControllerFailedActivate::on_init() | ||
{ | ||
return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS; | ||
} | ||
|
||
controller_interface::return_type TestControllerFailedActivate::update( | ||
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/) | ||
{ | ||
return controller_interface::return_type::OK; | ||
} | ||
|
||
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn | ||
TestControllerFailedActivate::on_configure(const rclcpp_lifecycle::State & /*previous_state&*/) | ||
{ | ||
return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS; | ||
} | ||
|
||
|
||
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn | ||
TestControllerFailedActivate::on_activate(const rclcpp_lifecycle::State & /*previous_state&*/) | ||
{ | ||
//Simply simulate a controller that can not be activated | ||
return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::FAILURE; | ||
} | ||
|
||
|
||
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn | ||
TestControllerFailedActivate::on_cleanup(const rclcpp_lifecycle::State & /*previous_state*/) | ||
{ | ||
return rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS; | ||
} | ||
|
||
} // namespace test_controller_with_interfaces | ||
|
||
#include "pluginlib/class_list_macros.hpp" | ||
|
||
PLUGINLIB_EXPORT_CLASS( | ||
test_controller_failed_activate::TestControllerFailedActivate, | ||
controller_interface::ControllerInterface) |
76 changes: 76 additions & 0 deletions
76
controller_manager/test/test_controller_failed_activate/test_controller_failed_activate.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright 2020 Department of Engineering Cybernetics, NTNU | ||
// | ||
// 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. | ||
|
||
#ifndef TEST_CONTROLLER_WITH_INTERFACES__TEST_CONTROLLER_WITH_INTERFACES_HPP_ | ||
#define TEST_CONTROLLER_WITH_INTERFACES__TEST_CONTROLLER_WITH_INTERFACES_HPP_ | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "controller_interface/visibility_control.h" | ||
#include "controller_manager/controller_manager.hpp" | ||
|
||
namespace test_controller_failed_activate | ||
{ | ||
// Corresponds to the name listed within the pluginglib xml | ||
constexpr char TEST_CONTROLLER_WITH_INTERFACES_CLASS_NAME[] = | ||
"controller_manager/test_controller_failed_activate"; | ||
// Corresponds to the command interface to claim | ||
constexpr char TEST_CONTROLLER_COMMAND_INTERFACE[] = "joint2/velocity"; | ||
class TestControllerFailedActivate : public controller_interface::ControllerInterface | ||
{ | ||
public: | ||
CONTROLLER_MANAGER_PUBLIC | ||
TestControllerFailedActivate(); | ||
|
||
CONTROLLER_MANAGER_PUBLIC | ||
virtual ~TestControllerFailedActivate() = default; | ||
|
||
controller_interface::InterfaceConfiguration command_interface_configuration() const override | ||
{ | ||
return controller_interface::InterfaceConfiguration{ | ||
controller_interface::interface_configuration_type::INDIVIDUAL, | ||
{TEST_CONTROLLER_COMMAND_INTERFACE}}; | ||
} | ||
|
||
controller_interface::InterfaceConfiguration state_interface_configuration() const override | ||
{ | ||
return controller_interface::InterfaceConfiguration{ | ||
controller_interface::interface_configuration_type::NONE}; | ||
} | ||
|
||
CONTROLLER_MANAGER_PUBLIC | ||
controller_interface::return_type update( | ||
const rclcpp::Time & time, const rclcpp::Duration & period) override; | ||
|
||
CONTROLLER_MANAGER_PUBLIC | ||
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_init() override; | ||
|
||
CONTROLLER_MANAGER_PUBLIC | ||
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_configure( | ||
const rclcpp_lifecycle::State & previous_state) override; | ||
|
||
CONTROLLER_MANAGER_PUBLIC | ||
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_activate( | ||
const rclcpp_lifecycle::State & previous_state) override; | ||
|
||
|
||
CONTROLLER_MANAGER_PUBLIC | ||
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_cleanup( | ||
const rclcpp_lifecycle::State & previous_state) override; | ||
}; | ||
|
||
} // namespace test_controller_with_interfaces | ||
|
||
#endif // TEST_CONTROLLER_WITH_INTERFACES__TEST_CONTROLLER_WITH_INTERFACES_HPP_ |
9 changes: 9 additions & 0 deletions
9
controller_manager/test/test_controller_failed_activate/test_controller_failed_activate.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<library path="test_controller_failed_activate"> | ||
|
||
<class name="controller_manager/test_controller_failed_activate" type="test_controller_failed_activate::TestControllerFailedActivate" base_class_type="controller_interface::ControllerInterface"> | ||
<description> | ||
Controller used for testing | ||
</description> | ||
</class> | ||
|
||
</library> |