diff --git a/consai2r2_description/CMakeLists.txt b/consai2r2_description/CMakeLists.txt index 0e51968..d388479 100644 --- a/consai2r2_description/CMakeLists.txt +++ b/consai2r2_description/CMakeLists.txt @@ -46,6 +46,15 @@ install(DIRECTORY DESTINATION share/${PROJECT_NAME}/ ) +install(DIRECTORY + include + DESTINATION . +) + +ament_export_include_directories(include) +ament_export_dependencies(ament_cmake) +ament_export_dependencies(python_cmake_module) + if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) # the following line skips the linter which checks for copyrights diff --git a/consai2r2_description/include/consai2r2_description/parameters.hpp b/consai2r2_description/include/consai2r2_description/parameters.hpp new file mode 100644 index 0000000..a115c6a --- /dev/null +++ b/consai2r2_description/include/consai2r2_description/parameters.hpp @@ -0,0 +1,84 @@ +// Copyright (c) 2019 SSL-Roots +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#ifndef CONSAI2R2_DESCRIPTION__PARAMETERS_HPP_ +#define CONSAI2R2_DESCRIPTION__PARAMETERS_HPP_ + +#include + +#include +#include +#include +#include + +using std::placeholders::_1; + + +namespace consai2r2 +{ + +namespace description +{ + +struct Parameters +{ +public: + int max_id; + std::string our_side; + std::string our_color; + + Parameters() + { + max_id = 15; + our_side = "left"; + our_color = "blue"; + } +}; + +class ParametersClient +{ +public: + explicit ParametersClient(rclcpp::Node * node) + : client(node, "consai2r2_description") + { + } + + void get_parameters(consai2r2::description::Parameters * consai2r2_parameters) + { + if (!client.wait_for_service(std::chrono::seconds(5))) { + throw std::runtime_error("Wait for service timed out"); + } + auto parameters = client.get_parameters( + {"max_id", "our_side", "our_color"}); + + consai2r2_parameters->max_id = parameters[0].as_int(); + consai2r2_parameters->our_side = parameters[1].as_string(); + consai2r2_parameters->our_color = parameters[2].as_string(); + } + +private: + rclcpp::SyncParametersClient client; +}; + +} // namespace description + +} // namespace consai2r2 + +#endif // CONSAI2R2_DESCRIPTION__PARAMETERS_HPP_