scenario_simulator_v2 C++ API
node_parameters.hpp
Go to the documentation of this file.
1 // Copyright 2015 TIER IV, Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef TRAFFIC_SIMULATOR__UTILS__NODE_PARAMETERS_HPP_
16 #define TRAFFIC_SIMULATOR__UTILS__NODE_PARAMETERS_HPP_
17 
18 #include <rclcpp/rclcpp.hpp>
20 
21 namespace traffic_simulator
22 {
30 template <typename ParameterT>
32  rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_parameters,
33  const std::string & name, const ParameterT & default_value = {}) -> ParameterT
34 {
35  if (not node_parameters->has_parameter(name)) {
36  node_parameters->declare_parameter(name, rclcpp::ParameterValue(default_value));
37  }
38  return node_parameters->get_parameter(name).get_value<ParameterT>();
39 }
40 } // namespace traffic_simulator
41 
42 #endif //TRAFFIC_SIMULATOR__UTILS__NODE_PARAMETERS_HPP_
Definition: api.hpp:48
auto getParameter(rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_parameters, const std::string &name, const ParameterT &default_value={}) -> ParameterT
Definition: node_parameters.hpp:31
std::string string
Definition: junit5.hpp:26