diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml index fdd94c7c..16d6f6af 100644 --- a/.github/workflows/ci-lint.yml +++ b/.github/workflows/ci-lint.yml @@ -10,13 +10,11 @@ jobs: strategy: fail-fast: false matrix: - linter: [cppcheck, lint_cmake] + linter: [cppcheck, cpplint, lint_cmake] arguments: [""] include: - linter: copyright - arguments: "--exclude CONTRIBUTING.md conf.py test_robot_description.launch.py view_robot.launch.py controller.cpp controller.hpp test_controller.cpp test_controller.hpp test_load_controller.cpp robot_hardware_interface.cpp robot_hardware_interface.hpp test_robot_hardware_interface.cpp visibility_control.h robot_ros2_control.launch.py test_forward_position_controller.launch.py test_joint_trajectory_controller.launch.py" - - linter: cpplint - arguments: "--exclude ./templates/ros2_control/controller/controller.cpp ./templates/ros2_control/controller/controller.hpp ./templates/ros2_control/controller/test_controller.cpp ./templates/ros2_control/controller/test_controller.hpp ./templates/ros2_control/controller/test_load_controller.cpp ./templates/ros2_control/controller/test_load_controller.hpp ./templates/ros2_control/hardware/robot_hardware_interface.cpp ./templates/ros2_control/hardware/robot_hardware_interface.hpp ./templates/ros2_control/hardware/visibility_control.cpp ./templates/ros2_control/hardware/test_robot_hardware_interface.cpp ./templates/ros2_control/hardware/visibility_control.h" + arguments: "--exclude conf.py test_robot_description.launch.py view_robot.launch.py robot_ros2_control.launch.py test_forward_position_controller.launch.py test_joint_trajectory_controller.launch.py" steps: - uses: actions/checkout@v2 - uses: ros-tooling/setup-ros@master diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f74b5e1..e9b474c5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,13 +50,13 @@ repos: # Python hooks - repo: https://github.com/asottile/pyupgrade - rev: v2.31.0 + rev: v2.31.1 hooks: - id: pyupgrade args: [--py36-plus] - repo: https://github.com/psf/black - rev: 21.12b0 + rev: 22.3.0 hooks: - id: black args: ["--line-length=99"] @@ -127,11 +127,11 @@ repos: stages: [commit] entry: ament_copyright language: system - exclude: ^(templates/) + exclude: ^(templates/)|docs/conf.py # Docs - RestructuredText hooks - repo: https://github.com/PyCQA/doc8 - rev: 0.10.1 + rev: 0.11.0 hooks: - id: doc8 args: ['--max-line-length=100', '--ignore=D001'] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3611fa54..e859b5f4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,7 +50,9 @@ As this project, by default, uses the default GitHub issue labels ## Licensing -Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license]: +Any contribution that you make to this repository will +be under the Apache 2 License, as dictated by that +[license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, @@ -61,8 +63,6 @@ Any contribution that you make to this repository will be under the Apache 2 Lic the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ - [issues]: https://github.com/StoglRobotics/ros_team_workspace/issues [closed-issues]: https://github.com/StoglRobotics/ros_team_workspace/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20 [help-wanted]: https://github.com/StoglRobotics/ros_team_workspace/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22 -[license]: http://www.apache.org/licenses/LICENSE-2.0.html diff --git a/scripts/ros2_control/setup-controller-package.bash b/scripts/ros2_control/setup-controller-package.bash index 0b362b54..6ac0ea0c 100755 --- a/scripts/ros2_control/setup-controller-package.bash +++ b/scripts/ros2_control/setup-controller-package.bash @@ -48,7 +48,7 @@ fi PKG_NAME=$3 if [ -z "$3" ]; then - current=`pwd` + current=$(pwd) PKG_NAME=$(basename "$current") echo "Package name guessed from the current path is '$PKG_NAME'. Is this correct? If not provide it as the third parameter." fi @@ -63,7 +63,7 @@ choice=${choice:="1"} if [ "$choice" != 0 ]; then read -p "Insert your company or personal name (copyright): " NAME_ON_LICENSE NAME_ON_LICENSE=${NAME_ON_LICENSE=""} - YEAR_ON_LICENSE=`date +%Y` + YEAR_ON_LICENSE=$(date +%Y) fi LICENSE_HEADER="" @@ -103,12 +103,12 @@ TEST_HPP="test/test_$FILE_NAME.hpp" if [[ ! -f "$VC_H" ]]; then cp -n $ROS2_CONTROL_HW_ITF_TEMPLATES/visibility_control.h $VC_H fi -cat $ROS2_CONTROL_CONTROLLER_TEMPLATES/controller_pluginlib.xml >> $PLUGIN_XML -cp -n $ROS2_CONTROL_CONTROLLER_TEMPLATES/controller.hpp $CTRL_HPP -cp -n $ROS2_CONTROL_CONTROLLER_TEMPLATES/controller.cpp $CTRL_CPP -cp -n $ROS2_CONTROL_CONTROLLER_TEMPLATES/test_load_controller.cpp $LOAD_TEST_CPP -cp -n $ROS2_CONTROL_CONTROLLER_TEMPLATES/test_controller.cpp $TEST_CPP -cp -n $ROS2_CONTROL_CONTROLLER_TEMPLATES/test_controller.hpp $TEST_HPP +cat $ROS2_CONTROL_CONTROLLER_TEMPLATES/dummy_controller_pluginlib.xml >> $PLUGIN_XML +cp -n $ROS2_CONTROL_CONTROLLER_TEMPLATES/dummy_package_namespace/dummy_controller.hpp $CTRL_HPP +cp -n $ROS2_CONTROL_CONTROLLER_TEMPLATES/dummy_controller.cpp $CTRL_CPP +cp -n $ROS2_CONTROL_CONTROLLER_TEMPLATES/test_load_dummy_controller.cpp $LOAD_TEST_CPP +cp -n $ROS2_CONTROL_CONTROLLER_TEMPLATES/test_dummy_controller.cpp $TEST_CPP +cp -n $ROS2_CONTROL_CONTROLLER_TEMPLATES/test_dummy_controller.hpp $TEST_HPP echo "Template files copied." @@ -124,8 +124,7 @@ if [[ "$LICENSE_HEADER" != "" ]]; then touch $TMP_FILE for FILE_TO_LIC in "${FILES_TO_LICENSE[@]}"; do cat $LICENSE_HEADER > $TMP_FILE - cat $FILE_TO_LIC >> $TMP_FILE - sed -i "/\\\$LICENSE\\\$/d" $TMP_FILE + sed "1,13d" $FILE_TO_LIC >> $TMP_FILE # delete first 13 lines which correspond to fake license mv $TMP_FILE $FILE_TO_LIC sed -i "s/\\\$YEAR\\\$/${YEAR_ON_LICENSE}/g" $FILE_TO_LIC sed -i "s/\\\$NAME_ON_LICENSE\\\$/${NAME_ON_LICENSE}/g" $FILE_TO_LIC @@ -139,13 +138,15 @@ FILES_TO_SED+=("$PLUGIN_XML") # declare -p FILES_TO_SED for SED_FILE in "${FILES_TO_SED[@]}"; do - sed -i "s/\\\$PACKAGE_NAME\\\$/${PKG_NAME^^}/g" $SED_FILE - sed -i "s/\\\$package_name\\\$/${PKG_NAME}/g" $SED_FILE - sed -i "s/\\\$file_name\\\$/${FILE_NAME}/g" $SED_FILE - sed -i "s/\\\$FILE_NAME\\\$/${FILE_NAME^^}/g" $SED_FILE - sed -i "s/\\\$ClassName\\\$/${CLASS_NAME}/g" $SED_FILE - sed -i "s/\\\$interface_type\\\$/${INTERFACE_TYPE}/g" $SED_FILE - sed -i "s/\\\$Interface_Type\\\$/${INTERFACE_TYPE^}/g" $SED_FILE + sed -i "s/TEMPLATES__ROS2_CONTROL__CONTROLLER__DUMMY_PACKAGE_NAMESPACE/${PKG_NAME^^}/g" $SED_FILE # package name for include guard + sed -i "s/TEMPLATES__ROS2_CONTROL__CONTROLLER/${PKG_NAME^^}/g" $SED_FILE # package name for include guard + sed -i "s/TEMPLATES__ROS2_CONTROL__HARDWARE/${PKG_NAME^^}/g" $SED_FILE # package name for include guard from hardware + sed -i "s/dummy_package_namespace/${PKG_NAME}/g" $SED_FILE # package name for includes + sed -i "s/dummy_controller/${FILE_NAME}/g" $SED_FILE # file name + sed -i "s/DUMMY_CONTROLLER/${FILE_NAME^^}/g" $SED_FILE # file name for include guard + sed -i "s/DummyClassName/${CLASS_NAME}/g" $SED_FILE # class name + sed -i "s/dummy_interface_type/${INTERFACE_TYPE}/g" $SED_FILE # interface type for includes + sed -i "s/Dummy_Interface_Type/${INTERFACE_TYPE^}/g" $SED_FILE # Interface type in namespace resolution done @@ -173,9 +174,8 @@ echo ")" >> $TMP_FILE echo "target_include_directories(" >> $TMP_FILE echo " $FILE_NAME" >> $TMP_FILE -echo " PUBLIC" >> $TMP_FILE -echo " $" >> $TMP_FILE -echo " $" >> $TMP_FILE +echo " PRIVATE" >> $TMP_FILE +echo " include" >> $TMP_FILE echo ")" >> $TMP_FILE # TODO(anyone): Add this dependencies in a loop @@ -190,10 +190,6 @@ echo " rclcpp_lifecycle" >> $TMP_FILE echo " realtime_tools" >> $TMP_FILE echo ")" >> $TMP_FILE -# TODO(anyone): Delete after Foxy!!! -echo "# prevent pluginlib from using boost" >> $TMP_FILE -echo "target_compile_definitions($FILE_NAME PUBLIC \"PLUGINLIB__DISABLE_BOOST_FUNCTIONS\")" >> $TMP_FILE - if [[ "$package_configured" == "no" ]]; then echo "" >> $TMP_FILE diff --git a/scripts/ros2_control/setup-hardware-interface-package.bash b/scripts/ros2_control/setup-hardware-interface-package.bash index c24c0fc3..09781f54 100755 --- a/scripts/ros2_control/setup-hardware-interface-package.bash +++ b/scripts/ros2_control/setup-hardware-interface-package.bash @@ -112,7 +112,7 @@ TEST_CPP="test/test_$FILE_NAME.cpp" # Copy files cp -n $ROS2_CONTROL_HW_ITF_TEMPLATES/visibility_control.h $VC_H -cp -n $ROS2_CONTROL_HW_ITF_TEMPLATES/robot_hardware_interface.hpp $HW_ITF_HPP +cp -n $ROS2_CONTROL_HW_ITF_TEMPLATES/dummy_package_namespace/robot_hardware_interface.hpp $HW_ITF_HPP cp -n $ROS2_CONTROL_HW_ITF_TEMPLATES/robot_hardware_interface.cpp $HW_ITF_CPP cp -n $ROS2_CONTROL_HW_ITF_TEMPLATES/robot_pluginlib.xml $PLUGIN_XML cp -n $ROS2_CONTROL_HW_ITF_TEMPLATES/test_robot_hardware_interface.cpp $TEST_CPP @@ -130,8 +130,7 @@ if [[ "$LICENSE_HEADER" != "" ]]; then touch $TMP_FILE for FILE_TO_LIC in "${FILES_TO_LICENSE[@]}"; do cat $LICENSE_HEADER > $TMP_FILE - cat $FILE_TO_LIC >> $TMP_FILE - sed -i "/\\\$LICENSE\\\$/d" $TMP_FILE + sed "1,13d" $FILE_TO_LIC >> $TMP_FILE # delete first 13 lines which correspond to fake license mv $TMP_FILE $FILE_TO_LIC sed -i "s/\\\$YEAR\\\$/${YEAR_ON_LICENSE}/g" $FILE_TO_LIC sed -i "s/\\\$NAME_ON_LICENSE\\\$/${NAME_ON_LICENSE}/g" $FILE_TO_LIC @@ -149,13 +148,13 @@ FILES_TO_SED+=("$PLUGIN_XML") # declare -p FILES_TO_SED for SED_FILE in "${FILES_TO_SED[@]}"; do - sed -i "s/\\\$PACKAGE_NAME\\\$/${PKG_NAME^^}/g" $SED_FILE - sed -i "s/\\\$package_name\\\$/${PKG_NAME}/g" $SED_FILE - sed -i "s/\\\$file_name\\\$/${FILE_NAME}/g" $SED_FILE - sed -i "s/\\\$FILE_NAME\\\$/${FILE_NAME^^}/g" $SED_FILE - sed -i "s/\\\$ClassName\\\$/${CLASS_NAME}/g" $SED_FILE - sed -i "s/\\\$interface_type\\\$/${INTERFACE_TYPE}/g" $SED_FILE - sed -i "s/\\\$Interface_Type\\\$/${INTERFACE_TYPE^}/g" $SED_FILE + sed -i "s/TEMPLATES__ROS2_CONTROL__HARDWARE__DUMMY_PACKAGE_NAMESPACE/${PKG_NAME^^}/g" $SED_FILE # package name for include guard + sed -i "s/dummy_package_namespace/${PKG_NAME}/g" $SED_FILE # package name for includes + sed -i "s/dummy_file_name/${FILE_NAME}/g" $SED_FILE # file name + sed -i "s/ROBOT_HARDWARE_INTERFACE/${FILE_NAME^^}/g" $SED_FILE # file name for include guard + sed -i "s/DummyClassName/${CLASS_NAME}/g" $SED_FILE # class name + sed -i "s/dummy_interface_type/${INTERFACE_TYPE}/g" $SED_FILE # interface type for includes + sed -i "s/Dummy_Interface_Type/${INTERFACE_TYPE^}/g" $SED_FILE # Interface type in namespace resolution done # If type is "sensor" remove write and command_interfaces methods diff --git a/templates/ros2_control/controller/controller_pluginlib.xml b/templates/ros2_control/controller/controller_pluginlib.xml deleted file mode 100644 index 84d38cf3..00000000 --- a/templates/ros2_control/controller/controller_pluginlib.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - $ClassName$ ros2_control controller. - - - diff --git a/templates/ros2_control/controller/controller.cpp b/templates/ros2_control/controller/dummy_controller.cpp similarity index 72% rename from templates/ros2_control/controller/controller.cpp rename to templates/ros2_control/controller/dummy_controller.cpp index ff534ad3..28f7b60b 100644 --- a/templates/ros2_control/controller/controller.cpp +++ b/templates/ros2_control/controller/dummy_controller.cpp @@ -1,6 +1,18 @@ -$LICENSE$ - -#include "$package_name$/$file_name$.hpp" +// Copyright (c) 2022, Stogl Robotics Consulting UG (haftungsbeschränkt) (template) +// +// 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 "dummy_package_namespace/dummy_controller.hpp" #include #include @@ -9,11 +21,11 @@ #include "controller_interface/helpers.hpp" -namespace $package_name$ +namespace dummy_package_namespace { -$ClassName$::$ClassName$() : controller_interface::ControllerInterface() {} +DummyClassName::DummyClassName() : controller_interface::ControllerInterface() {} -CallbackReturn $ClassName$::on_init() +CallbackReturn DummyClassName::on_init() { try { get_node()->declare_parameter>("joints", std::vector({})); @@ -26,7 +38,7 @@ CallbackReturn $ClassName$::on_init() return CallbackReturn::SUCCESS; } -CallbackReturn $ClassName$::on_configure(const rclcpp_lifecycle::State & /*previous_state*/) +CallbackReturn DummyClassName::on_configure(const rclcpp_lifecycle::State & /*previous_state*/) { auto error_if_empty = [&](const auto & parameter, const char * parameter_name) { if (parameter.empty()) { @@ -82,7 +94,7 @@ CallbackReturn $ClassName$::on_configure(const rclcpp_lifecycle::State & /*previ return CallbackReturn::SUCCESS; } -controller_interface::InterfaceConfiguration $ClassName$::command_interface_configuration() const +controller_interface::InterfaceConfiguration DummyClassName::command_interface_configuration() const { controller_interface::InterfaceConfiguration command_interfaces_config; command_interfaces_config.type = controller_interface::interface_configuration_type::INDIVIDUAL; @@ -95,7 +107,7 @@ controller_interface::InterfaceConfiguration $ClassName$::command_interface_conf return command_interfaces_config; } -controller_interface::InterfaceConfiguration $ClassName$::state_interface_configuration() const +controller_interface::InterfaceConfiguration DummyClassName::state_interface_configuration() const { controller_interface::InterfaceConfiguration state_interfaces_config; state_interfaces_config.type = controller_interface::interface_configuration_type::INDIVIDUAL; @@ -108,29 +120,7 @@ controller_interface::InterfaceConfiguration $ClassName$::state_interface_config return state_interfaces_config; } -// Fill ordered_interfaces with references to the matching interfaces -// in the same order as in joint_names -// TODO(anyone): use the method from controller_interface/helpers.hpp when ros2_contol#370 -// is merged -template -bool get_ordered_interfaces( - std::vector & unordered_interfaces, const std::vector & joint_names, - const std::string & interface_type, std::vector> & ordered_interfaces) -{ - for (const auto & joint_name : joint_names) { - for (auto & command_interface : unordered_interfaces) { - if ( - (command_interface.get_name() == joint_name) && - (command_interface.get_interface_name() == interface_type)) { - ordered_interfaces.push_back(std::ref(command_interface)); - } - } - } - - return joint_names.size() == ordered_interfaces.size(); -} - -CallbackReturn $ClassName$::on_activate(const rclcpp_lifecycle::State & /*previous_state*/) +CallbackReturn DummyClassName::on_activate(const rclcpp_lifecycle::State & /*previous_state*/) { // Set default value in command std::shared_ptr msg = std::make_shared(); @@ -141,12 +131,12 @@ CallbackReturn $ClassName$::on_activate(const rclcpp_lifecycle::State & /*previo return CallbackReturn::SUCCESS; } -CallbackReturn $ClassName$::on_deactivate(const rclcpp_lifecycle::State & /*previous_state*/) +CallbackReturn DummyClassName::on_deactivate(const rclcpp_lifecycle::State & /*previous_state*/) { return CallbackReturn::SUCCESS; } -controller_interface::return_type $ClassName$::update( +controller_interface::return_type DummyClassName::update( const rclcpp::Time & time, const rclcpp::Duration & /*period*/) { auto current_command = input_command_.readFromRT(); @@ -167,8 +157,9 @@ controller_interface::return_type $ClassName$::update( return controller_interface::return_type::OK; } -} // namespace $package_name$ +} // namespace dummy_package_namespace #include "pluginlib/class_list_macros.hpp" -PLUGINLIB_EXPORT_CLASS($package_name$::$ClassName$, controller_interface::ControllerInterface) +PLUGINLIB_EXPORT_CLASS( + dummy_package_namespace::DummyClassName, controller_interface::ControllerInterface) diff --git a/templates/ros2_control/controller/dummy_controller_pluginlib.xml b/templates/ros2_control/controller/dummy_controller_pluginlib.xml new file mode 100644 index 00000000..b11cb929 --- /dev/null +++ b/templates/ros2_control/controller/dummy_controller_pluginlib.xml @@ -0,0 +1,8 @@ + + + + DummyClassName ros2_control controller. + + + diff --git a/templates/ros2_control/controller/controller.hpp b/templates/ros2_control/controller/dummy_package_namespace/dummy_controller.hpp similarity index 56% rename from templates/ros2_control/controller/controller.hpp rename to templates/ros2_control/controller/dummy_package_namespace/dummy_controller.hpp index 77104b19..f91f90b1 100644 --- a/templates/ros2_control/controller/controller.hpp +++ b/templates/ros2_control/controller/dummy_package_namespace/dummy_controller.hpp @@ -1,14 +1,26 @@ -$LICENSE$ - -#ifndef $PACKAGE_NAME$__$FILE_NAME$_HPP_ -#define $PACKAGE_NAME$__$FILE_NAME$_HPP_ +// Copyright (c) 2022, Stogl Robotics Consulting UG (haftungsbeschränkt) (template) +// +// 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 TEMPLATES__ROS2_CONTROL__CONTROLLER__DUMMY_PACKAGE_NAMESPACE__DUMMY_CONTROLLER_HPP_ +#define TEMPLATES__ROS2_CONTROL__CONTROLLER__DUMMY_PACKAGE_NAMESPACE__DUMMY_CONTROLLER_HPP_ #include #include #include -#include "$package_name$/visibility_control.h" #include "controller_interface/controller_interface.hpp" +#include "dummy_package_namespace/visibility_control.h" #include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp" #include "rclcpp_lifecycle/state.hpp" #include "realtime_tools/realtime_buffer.h" @@ -18,35 +30,35 @@ #include "control_msgs/msg/joint_controller_state.hpp" #include "control_msgs/msg/joint_jog.hpp" -namespace $package_name$ +namespace dummy_package_namespace { using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn; -class $ClassName$ : public controller_interface::ControllerInterface +class DummyClassName : public controller_interface::ControllerInterface { public: - $PACKAGE_NAME$_PUBLIC - $ClassName$(); + TEMPLATES__ROS2_CONTROL__CONTROLLER_PUBLIC + DummyClassName(); - $PACKAGE_NAME$_PUBLIC + TEMPLATES__ROS2_CONTROL__CONTROLLER_PUBLIC CallbackReturn on_init() override; - $PACKAGE_NAME$_PUBLIC + TEMPLATES__ROS2_CONTROL__CONTROLLER_PUBLIC controller_interface::InterfaceConfiguration command_interface_configuration() const override; - $PACKAGE_NAME$_PUBLIC + TEMPLATES__ROS2_CONTROL__CONTROLLER_PUBLIC controller_interface::InterfaceConfiguration state_interface_configuration() const override; - $PACKAGE_NAME$_PUBLIC + TEMPLATES__ROS2_CONTROL__CONTROLLER_PUBLIC CallbackReturn on_configure(const rclcpp_lifecycle::State & previous_state) override; - $PACKAGE_NAME$_PUBLIC + TEMPLATES__ROS2_CONTROL__CONTROLLER_PUBLIC CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override; - $PACKAGE_NAME$_PUBLIC + TEMPLATES__ROS2_CONTROL__CONTROLLER_PUBLIC CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override; - $PACKAGE_NAME$_PUBLIC + TEMPLATES__ROS2_CONTROL__CONTROLLER_PUBLIC controller_interface::return_type update( const rclcpp::Time & time, const rclcpp::Duration & period) override; @@ -68,6 +80,6 @@ class $ClassName$ : public controller_interface::ControllerInterface std::unique_ptr state_publisher_; }; -} // namespace $package_name$ +} // namespace dummy_package_namespace -#endif // $PACKAGE_NAME$__$FILE_NAME$_HPP_ +#endif // TEMPLATES__ROS2_CONTROL__CONTROLLER__DUMMY_PACKAGE_NAMESPACE__DUMMY_CONTROLLER_HPP_ diff --git a/templates/ros2_control/controller/test_controller.cpp b/templates/ros2_control/controller/test_dummy_controller.cpp similarity index 79% rename from templates/ros2_control/controller/test_controller.cpp rename to templates/ros2_control/controller/test_dummy_controller.cpp index 468487f5..299154e9 100644 --- a/templates/ros2_control/controller/test_controller.cpp +++ b/templates/ros2_control/controller/test_dummy_controller.cpp @@ -1,6 +1,18 @@ -$LICENSE$ - -#include "test_$file_name$.hpp" +// Copyright (c) 2022, Stogl Robotics Consulting UG (haftungsbeschränkt) (template) +// +// 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_dummy_controller.hpp" #include #include @@ -9,7 +21,7 @@ // When there are many mandatory parameters, set all by default and remove one by one in a // parameterized test -TEST_P($ClassName$TestParameterizedParameters, one_parameter_is_missing) +TEST_P(DummyClassNameTestParameterizedParameters, one_parameter_is_missing) { SetUpController(); @@ -18,12 +30,12 @@ TEST_P($ClassName$TestParameterizedParameters, one_parameter_is_missing) // TODO(anyone): the new gtest version after 1.8.0 uses INSTANTIATE_TEST_SUITE_P INSTANTIATE_TEST_SUITE_P( - MissingMandatoryParameterDuringConfiguration, $ClassName$TestParameterizedParameters, + MissingMandatoryParameterDuringConfiguration, DummyClassNameTestParameterizedParameters, ::testing::Values( std::make_tuple(std::string("joints"), rclcpp::ParameterValue(std::vector({}))), std::make_tuple(std::string("interface_name"), rclcpp::ParameterValue("")))); -TEST_F($ClassName$Test, joint_names_parameter_not_set) +TEST_F(DummyClassNameTest, joint_names_parameter_not_set) { SetUpController(false); @@ -38,7 +50,7 @@ TEST_F($ClassName$Test, joint_names_parameter_not_set) ASSERT_TRUE(controller_->interface_name_.empty()); } -TEST_F($ClassName$Test, interface_parameter_not_set) +TEST_F(DummyClassNameTest, interface_parameter_not_set) { SetUpController(false); @@ -50,7 +62,7 @@ TEST_F($ClassName$Test, interface_parameter_not_set) ASSERT_TRUE(controller_->interface_name_.empty()); } -TEST_F($ClassName$Test, all_parameters_set_configure_success) +TEST_F(DummyClassNameTest, all_parameters_set_configure_success) { SetUpController(); @@ -69,7 +81,7 @@ TEST_F($ClassName$Test, all_parameters_set_configure_success) ASSERT_TRUE(controller_->interface_name_ == interface_name_); } -TEST_F($ClassName$Test, check_intefaces) +TEST_F(DummyClassNameTest, check_intefaces) { SetUpController(); @@ -82,7 +94,7 @@ TEST_F($ClassName$Test, check_intefaces) ASSERT_EQ(state_intefaces.names.size(), joint_state_values_.size()); } -TEST_F($ClassName$Test, activate_success) +TEST_F(DummyClassNameTest, activate_success) { SetUpController(); @@ -90,7 +102,7 @@ TEST_F($ClassName$Test, activate_success) ASSERT_EQ(controller_->on_activate(rclcpp_lifecycle::State()), NODE_SUCCESS); } -TEST_F($ClassName$Test, update_success) +TEST_F(DummyClassNameTest, update_success) { SetUpController(); @@ -102,7 +114,7 @@ TEST_F($ClassName$Test, update_success) ASSERT_EQ(controller_->update(node_time, duration), controller_interface::return_type::OK); } -TEST_F($ClassName$Test, deactivate_success) +TEST_F(DummyClassNameTest, deactivate_success) { SetUpController(); @@ -111,7 +123,7 @@ TEST_F($ClassName$Test, deactivate_success) ASSERT_EQ(controller_->on_deactivate(rclcpp_lifecycle::State()), NODE_SUCCESS); } -TEST_F($ClassName$Test, reactivate_success) +TEST_F(DummyClassNameTest, reactivate_success) { SetUpController(); @@ -125,7 +137,7 @@ TEST_F($ClassName$Test, reactivate_success) ASSERT_EQ(controller_->update(node_time, duration), controller_interface::return_type::OK); } -TEST_F($ClassName$Test, publish_status_success) +TEST_F(DummyClassNameTest, publish_status_success) { SetUpController(); @@ -142,7 +154,7 @@ TEST_F($ClassName$Test, publish_status_success) ASSERT_EQ(msg.set_point, 101.101); } -TEST_F($ClassName$Test, receive_message_and_publish_updated_status) +TEST_F(DummyClassNameTest, receive_message_and_publish_updated_status) { SetUpController(); rclcpp::executors::MultiThreadedExecutor executor; diff --git a/templates/ros2_control/controller/test_controller.hpp b/templates/ros2_control/controller/test_dummy_controller.hpp similarity index 77% rename from templates/ros2_control/controller/test_controller.hpp rename to templates/ros2_control/controller/test_dummy_controller.hpp index db825894..eae67f54 100644 --- a/templates/ros2_control/controller/test_controller.hpp +++ b/templates/ros2_control/controller/test_dummy_controller.hpp @@ -1,7 +1,19 @@ -$LICENSE$ - -#ifndef TEST_$PACKAGE_NAME$_HPP_ -#define TEST_$PACKAGE_NAME$_HPP_ +// Copyright (c) 2022, Stogl Robotics Consulting UG (haftungsbeschränkt) (template) +// +// 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 TEMPLATES__ROS2_CONTROL__CONTROLLER__TEST_DUMMY_CONTROLLER_HPP_ +#define TEMPLATES__ROS2_CONTROL__CONTROLLER__TEST_DUMMY_CONTROLLER_HPP_ #include #include @@ -10,7 +22,7 @@ #include #include -#include "$package_name$/$file_name$.hpp" +#include "dummy_package_namespace/dummy_controller.hpp" #include "gmock/gmock.h" #include "hardware_interface/loaned_command_interface.hpp" #include "hardware_interface/loaned_state_interface.hpp" @@ -46,16 +58,16 @@ rclcpp::WaitResultKind wait_for(rclcpp::SubscriptionBase::SharedPtr subscription } // namespace // subclassing and friending so we can access member variables -class Testable$ClassName$ : public $package_name$::$ClassName$ +class TestableDummyClassName : public dummy_package_namespace::DummyClassName { - FRIEND_TEST($ClassName$Test, joint_names_parameter_not_set); - FRIEND_TEST($ClassName$Test, interface_parameter_not_set); - FRIEND_TEST($ClassName$Test, all_parameters_set_configure_success); + FRIEND_TEST(DummyClassNameTest, joint_names_parameter_not_set); + FRIEND_TEST(DummyClassNameTest, interface_parameter_not_set); + FRIEND_TEST(DummyClassNameTest, all_parameters_set_configure_success); public: CallbackReturn on_configure(const rclcpp_lifecycle::State & previous_state) override { - auto ret = $package_name$::$ClassName$::on_configure(previous_state); + auto ret = dummy_package_namespace::DummyClassName::on_configure(previous_state); // Only if on_configure is successful create subscription if (ret == CallbackReturn::SUCCESS) { command_subscriber_wait_set_.add_subscription(command_subscriber_); @@ -86,7 +98,7 @@ class Testable$ClassName$ : public $package_name$::$ClassName$ rclcpp::WaitSet command_subscriber_wait_set_; }; -class $ClassName$Test : public ::testing::Test +class DummyClassNameTest : public ::testing::Test { public: static void SetUpTestCase() { rclcpp::init(0, nullptr); } @@ -94,11 +106,11 @@ class $ClassName$Test : public ::testing::Test void SetUp() { // initialize controller - controller_ = std::make_unique(); + controller_ = std::make_unique(); command_publisher_node_ = std::make_shared("command_publisher"); command_publisher_ = command_publisher_node_->create_publisher( - "/test_$package_name$/commands", rclcpp::SystemDefaultsQoS()); + "/test_dummy_package_namespace/commands", rclcpp::SystemDefaultsQoS()); } static void TearDownTestCase() { rclcpp::shutdown(); } @@ -108,7 +120,7 @@ class $ClassName$Test : public ::testing::Test protected: void SetUpController(bool set_parameters = true) { - const auto result = controller_->init("test_$package_name$"); + const auto result = controller_->init("test_dummy_package_namespace"); ASSERT_EQ(result, controller_interface::return_type::OK); std::vector command_ifs; @@ -147,7 +159,7 @@ class $ClassName$Test : public ::testing::Test rclcpp::Node test_subscription_node("test_subscription_node"); auto subs_callback = [&](const ControllerStateMsg::SharedPtr) {}; auto subscription = test_subscription_node.create_subscription( - "/test_$package_name$/state", 10, subs_callback); + "/test_dummy_package_namespace/state", 10, subs_callback); // call update to publish the test value rclcpp::Time node_time = controller_->get_node()->now(); @@ -201,27 +213,27 @@ class $ClassName$Test : public ::testing::Test std::vector command_itfs_; // Test related parameters - std::unique_ptr controller_; + std::unique_ptr controller_; rclcpp::Node::SharedPtr command_publisher_node_; rclcpp::Publisher::SharedPtr command_publisher_; }; // From the tutorial: https://www.sandordargo.com/blog/2019/04/24/parameterized-testing-with-gtest -class $ClassName$TestParameterizedParameters -: public $ClassName$Test, +class DummyClassNameTestParameterizedParameters +: public DummyClassNameTest, public ::testing::WithParamInterface> { public: - virtual void SetUp() { $ClassName$Test::SetUp(); } + virtual void SetUp() { DummyClassNameTest::SetUp(); } - static void TearDownTestCase() { $ClassName$Test::TearDownTestCase(); } + static void TearDownTestCase() { DummyClassNameTest::TearDownTestCase(); } protected: void SetUpController(bool set_parameters = true) { - $ClassName$Test::SetUpController(set_parameters); + DummyClassNameTest::SetUpController(set_parameters); controller_->get_node()->set_parameter({std::get<0>(GetParam()), std::get<1>(GetParam())}); } }; -#endif // TEST_$PACKAGE_NAME$_HPP_ +#endif // TEMPLATES__ROS2_CONTROL__CONTROLLER__TEST_DUMMY_CONTROLLER_HPP_ diff --git a/templates/ros2_control/controller/test_load_controller.cpp b/templates/ros2_control/controller/test_load_controller.cpp deleted file mode 100644 index 029751a2..00000000 --- a/templates/ros2_control/controller/test_load_controller.cpp +++ /dev/null @@ -1,28 +0,0 @@ -$LICENSE$ - -#include -#include - -#include "controller_manager/controller_manager.hpp" -#include "hardware_interface/resource_manager.hpp" -#include "rclcpp/executor.hpp" -#include "rclcpp/executors/single_threaded_executor.hpp" -#include "rclcpp/utilities.hpp" -#include "ros2_control_test_assets/descriptions.hpp" - -TEST(TestLoad$ClassName$, load_controller) -{ - rclcpp::init(0, nullptr); - - std::shared_ptr executor = - std::make_shared(); - - controller_manager::ControllerManager cm( - std::make_unique( - ros2_control_test_assets::minimal_robot_urdf), - executor, "test_controller_manager"); - - ASSERT_NO_THROW(cm.load_controller("test_$package_name$", "$package_name$/$ClassName$")); - - rclcpp::shutdown(); -} diff --git a/templates/ros2_control/controller/test_load_dummy_controller.cpp b/templates/ros2_control/controller/test_load_dummy_controller.cpp new file mode 100644 index 00000000..e1ea359c --- /dev/null +++ b/templates/ros2_control/controller/test_load_dummy_controller.cpp @@ -0,0 +1,41 @@ +// Copyright (c) 2022, Stogl Robotics Consulting UG (haftungsbeschränkt) (template) +// +// 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 +#include + +#include "controller_manager/controller_manager.hpp" +#include "hardware_interface/resource_manager.hpp" +#include "rclcpp/executor.hpp" +#include "rclcpp/executors/single_threaded_executor.hpp" +#include "rclcpp/utilities.hpp" +#include "ros2_control_test_assets/descriptions.hpp" + +TEST(TestLoadDummyClassName, load_controller) +{ + rclcpp::init(0, nullptr); + + std::shared_ptr executor = + std::make_shared(); + + controller_manager::ControllerManager cm( + std::make_unique( + ros2_control_test_assets::minimal_robot_urdf), + executor, "test_controller_manager"); + + ASSERT_NO_THROW( + cm.load_controller("test_dummy_package_namespace", "dummy_package_namespace/DummyClassName")); + + rclcpp::shutdown(); +} diff --git a/templates/ros2_control/hardware/dummy_package_namespace/robot_hardware_interface.hpp b/templates/ros2_control/hardware/dummy_package_namespace/robot_hardware_interface.hpp new file mode 100644 index 00000000..3daa1911 --- /dev/null +++ b/templates/ros2_control/hardware/dummy_package_namespace/robot_hardware_interface.hpp @@ -0,0 +1,64 @@ +// Copyright (c) 2022, Stogl Robotics Consulting UG (haftungsbeschränkt) (template) +// +// 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 TEMPLATES__ROS2_CONTROL__HARDWARE__DUMMY_PACKAGE_NAMESPACE__ROBOT_HARDWARE_INTERFACE_HPP_ +#define TEMPLATES__ROS2_CONTROL__HARDWARE__DUMMY_PACKAGE_NAMESPACE__ROBOT_HARDWARE_INTERFACE_HPP_ + +#include +#include + +#include "dummy_package_namespace/visibility_control.h" +#include "hardware_interface/dummy_interface_type_interface.hpp" +#include "hardware_interface/handle.hpp" +#include "hardware_interface/hardware_info.hpp" +#include "hardware_interface/types/hardware_interface_return_values.hpp" +#include "rclcpp/macros.hpp" +#include "rclcpp_lifecycle/state.hpp" + +namespace dummy_package_namespace +{ +using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn; + +class DummyClassName : public hardware_interface::Dummy_Interface_TypeInterface +{ +public: + TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC + CallbackReturn on_init(const hardware_interface::HardwareInfo & info) override; + + TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC + std::vector export_state_interfaces() override; + + TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC + std::vector export_command_interfaces() override; + + TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC + CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override; + + TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC + CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override; + + TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC + hardware_interface::return_type read() override; + + TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC + hardware_interface::return_type write() override; + +private: + std::vector hw_commands_; + std::vector hw_states_; +}; + +} // namespace dummy_package_namespace + +#endif // TEMPLATES__ROS2_CONTROL__HARDWARE__DUMMY_PACKAGE_NAMESPACE__ROBOT_HARDWARE_INTERFACE_HPP_ diff --git a/templates/ros2_control/hardware/robot_hardware_interface.cpp b/templates/ros2_control/hardware/robot_hardware_interface.cpp index dfbe3a67..b0b5ae2f 100644 --- a/templates/ros2_control/hardware/robot_hardware_interface.cpp +++ b/templates/ros2_control/hardware/robot_hardware_interface.cpp @@ -1,17 +1,29 @@ -$LICENSE$ +// Copyright (c) 2022, Stogl Robotics Consulting UG (haftungsbeschränkt) (template) +// +// 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 #include -#include "$package_name$/$file_name$.hpp" +#include "dummy_package_namespace/dummy_file_name.hpp" #include "hardware_interface/types/hardware_interface_type_values.hpp" #include "rclcpp/rclcpp.hpp" -namespace $package_name$ +namespace dummy_package_namespace { -CallbackReturn $ClassName$::on_init(const hardware_interface::HardwareInfo & info) +CallbackReturn DummyClassName::on_init(const hardware_interface::HardwareInfo & info) { - if (hardware_interface::$Interface_Type$Interface::on_init(info) != CallbackReturn::SUCCESS) { + if (hardware_interface::Dummy_Interface_TypeInterface::on_init(info) != CallbackReturn::SUCCESS) { return CallbackReturn::ERROR; } @@ -22,7 +34,7 @@ CallbackReturn $ClassName$::on_init(const hardware_interface::HardwareInfo & inf return CallbackReturn::SUCCESS; } -std::vector $ClassName$::export_state_interfaces() +std::vector DummyClassName::export_state_interfaces() { std::vector state_interfaces; for (uint i = 0; i < info_.joints.size(); i++) { @@ -34,7 +46,7 @@ std::vector $ClassName$::export_state_interf return state_interfaces; } -std::vector $ClassName$::export_command_interfaces() +std::vector DummyClassName::export_command_interfaces() { std::vector command_interfaces; for (uint i = 0; i < info_.joints.size(); i++) { @@ -46,36 +58,37 @@ std::vector $ClassName$::export_command_in return command_interfaces; } -CallbackReturn $ClassName$::on_activate(const rclcpp_lifecycle::State & /*previous_state*/) +CallbackReturn DummyClassName::on_activate(const rclcpp_lifecycle::State & /*previous_state*/) { // TODO(anyone): prepare the robot to receive commands return CallbackReturn::SUCCESS; } -CallbackReturn $ClassName$::on_deactivate(const rclcpp_lifecycle::State & /*previous_state*/) +CallbackReturn DummyClassName::on_deactivate(const rclcpp_lifecycle::State & /*previous_state*/) { // TODO(anyone): prepare the robot to stop receiving commands return CallbackReturn::SUCCESS; } -hardware_interface::return_type $ClassName$::read() +hardware_interface::return_type DummyClassName::read() { // TODO(anyone): read robot states return hardware_interface::return_type::OK; } -hardware_interface::return_type $ClassName$::write() +hardware_interface::return_type DummyClassName::write() { // TODO(anyone): write robot's commands' return hardware_interface::return_type::OK; } -} // namespace $package_name$ +} // namespace dummy_package_namespace #include "pluginlib/class_list_macros.hpp" -PLUGINLIB_EXPORT_CLASS($package_name$::$ClassName$, hardware_interface::$Interface_Type$Interface) +PLUGINLIB_EXPORT_CLASS( + dummy_package_namespace::DummyClassName, hardware_interface::Dummy_Interface_TypeInterface) diff --git a/templates/ros2_control/hardware/robot_hardware_interface.hpp b/templates/ros2_control/hardware/robot_hardware_interface.hpp deleted file mode 100644 index 5f918c60..00000000 --- a/templates/ros2_control/hardware/robot_hardware_interface.hpp +++ /dev/null @@ -1,52 +0,0 @@ -$LICENSE$ - -#ifndef $PACKAGE_NAME$__$FILE_NAME$_HPP_ -#define $PACKAGE_NAME$__$FILE_NAME$_HPP_ - -#include -#include - -#include "$package_name$/visibility_control.h" -#include "hardware_interface/$interface_type$_interface.hpp" -#include "hardware_interface/handle.hpp" -#include "hardware_interface/hardware_info.hpp" -#include "hardware_interface/types/hardware_interface_return_values.hpp" -#include "rclcpp/macros.hpp" -#include "rclcpp_lifecycle/state.hpp" - -namespace $package_name$ -{ -class $ClassName$ : public hardware_interface::$Interface_Type$Interface -{ -public: - RCLCPP_SHARED_PTR_DEFINITIONS($ClassName$); - - $PACKAGE_NAME$_PUBLIC - CallbackReturn on_init(const hardware_interface::HardwareInfo & info) override; - - $PACKAGE_NAME$_PUBLIC - std::vector export_state_interfaces() override; - - $PACKAGE_NAME$_PUBLIC - std::vector export_command_interfaces() override; - - $PACKAGE_NAME$_PUBLIC - CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override; - - $PACKAGE_NAME$_PUBLIC - CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override; - - $PACKAGE_NAME$_PUBLIC - hardware_interface::return_type read() override; - - $PACKAGE_NAME$_PUBLIC - hardware_interface::return_type write() override; - -private: - std::vector hw_commands_; - std::vector hw_states_; -}; - -} // namespace $package_name$ - -#endif // $PACKAGE_NAME$__$FILE_NAME$_HPP_ diff --git a/templates/ros2_control/hardware/robot_pluginlib.xml b/templates/ros2_control/hardware/robot_pluginlib.xml index b11ef8d0..9e636223 100644 --- a/templates/ros2_control/hardware/robot_pluginlib.xml +++ b/templates/ros2_control/hardware/robot_pluginlib.xml @@ -1,7 +1,7 @@ - - + + ros2_control hardware interface. diff --git a/templates/ros2_control/hardware/test_robot_hardware_interface.cpp b/templates/ros2_control/hardware/test_robot_hardware_interface.cpp index 8be75fdb..0de6a3e4 100644 --- a/templates/ros2_control/hardware/test_robot_hardware_interface.cpp +++ b/templates/ros2_control/hardware/test_robot_hardware_interface.cpp @@ -1,4 +1,16 @@ -$LICENSE$ +// Copyright (c) 2022, Stogl Robotics Consulting UG (haftungsbeschränkt) (template) +// +// 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 @@ -8,17 +20,17 @@ #include "ros2_control_test_assets/components_urdfs.hpp" #include "ros2_control_test_assets/descriptions.hpp" -class Test$ClassName$ : public ::testing::Test +class TestDummyClassName : public ::testing::Test { protected: void SetUp() override { // TODO(anyone): Extend this description to your robot - $file_name$_2dof_ = + dummy_file_name_2dof_ = R"( - + - $package_name$/$ClassName$ + dummy_package_namespace/DummyClassName @@ -34,12 +46,12 @@ class Test$ClassName$ : public ::testing::Test )"; } - std::string $file_name$_2dof_; + std::string dummy_file_name_2dof_; }; -TEST_F(Test$ClassName$, load_$file_name$_2dof) +TEST_F(TestDummyClassName, load_dummy_file_name_2dof) { - auto urdf = - ros2_control_test_assets::urdf_head + $file_name$_2dof_ + ros2_control_test_assets::urdf_tail; + auto urdf = ros2_control_test_assets::urdf_head + dummy_file_name_2dof_ + + ros2_control_test_assets::urdf_tail; ASSERT_NO_THROW(hardware_interface::ResourceManager rm(urdf)); } diff --git a/templates/ros2_control/hardware/visibility_control.h b/templates/ros2_control/hardware/visibility_control.h index 9ba82d0b..1ad4efaf 100644 --- a/templates/ros2_control/hardware/visibility_control.h +++ b/templates/ros2_control/hardware/visibility_control.h @@ -1,37 +1,49 @@ -$LICENSE$ +// Copyright (c) 2022, Stogl Robotics Consulting UG (haftungsbeschränkt) (template) +// +// 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 $PACKAGE_NAME$__VISIBILITY_CONTROL_H_ -#define $PACKAGE_NAME$__VISIBILITY_CONTROL_H_ +#ifndef TEMPLATES__ROS2_CONTROL__HARDWARE__VISIBILITY_CONTROL_H_ +#define TEMPLATES__ROS2_CONTROL__HARDWARE__VISIBILITY_CONTROL_H_ // This logic was borrowed (then namespaced) from the examples on the gcc wiki: // https://gcc.gnu.org/wiki/Visibility #if defined _WIN32 || defined __CYGWIN__ #ifdef __GNUC__ -#define $PACKAGE_NAME$_EXPORT __attribute__((dllexport)) -#define $PACKAGE_NAME$_IMPORT __attribute__((dllimport)) +#define TEMPLATES__ROS2_CONTROL__HARDWARE_EXPORT __attribute__((dllexport)) +#define TEMPLATES__ROS2_CONTROL__HARDWARE_IMPORT __attribute__((dllimport)) #else -#define $PACKAGE_NAME$_EXPORT __declspec(dllexport) -#define $PACKAGE_NAME$_IMPORT __declspec(dllimport) +#define TEMPLATES__ROS2_CONTROL__HARDWARE_EXPORT __declspec(dllexport) +#define TEMPLATES__ROS2_CONTROL__HARDWARE_IMPORT __declspec(dllimport) #endif -#ifdef $PACKAGE_NAME$_BUILDING_DLL -#define $PACKAGE_NAME$_PUBLIC $PACKAGE_NAME$_EXPORT +#ifdef TEMPLATES__ROS2_CONTROL__HARDWARE_BUILDING_DLL +#define TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC TEMPLATES__ROS2_CONTROL__HARDWARE_EXPORT #else -#define $PACKAGE_NAME$_PUBLIC $PACKAGE_NAME$_IMPORT +#define TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC TEMPLATES__ROS2_CONTROL__HARDWARE_IMPORT #endif -#define $PACKAGE_NAME$_PUBLIC_TYPE $PACKAGE_NAME$_PUBLIC -#define $PACKAGE_NAME$_LOCAL +#define TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC_TYPE TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC +#define TEMPLATES__ROS2_CONTROL__HARDWARE_LOCAL #else -#define $PACKAGE_NAME$_EXPORT __attribute__((visibility("default"))) -#define $PACKAGE_NAME$_IMPORT +#define TEMPLATES__ROS2_CONTROL__HARDWARE_EXPORT __attribute__((visibility("default"))) +#define TEMPLATES__ROS2_CONTROL__HARDWARE_IMPORT #if __GNUC__ >= 4 -#define $PACKAGE_NAME$_PUBLIC __attribute__((visibility("default"))) -#define $PACKAGE_NAME$_LOCAL __attribute__((visibility("hidden"))) +#define TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC __attribute__((visibility("default"))) +#define TEMPLATES__ROS2_CONTROL__HARDWARE_LOCAL __attribute__((visibility("hidden"))) #else -#define $PACKAGE_NAME$_PUBLIC -#define $PACKAGE_NAME$_LOCAL +#define TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC +#define TEMPLATES__ROS2_CONTROL__HARDWARE_LOCAL #endif -#define $PACKAGE_NAME$_PUBLIC_TYPE +#define TEMPLATES__ROS2_CONTROL__HARDWARE_PUBLIC_TYPE #endif -#endif // $PACKAGE_NAME$__VISIBILITY_CONTROL_H_ +#endif // TEMPLATES__ROS2_CONTROL__HARDWARE__VISIBILITY_CONTROL_H_