Files
Tangent_Planner/include/parameters_helper.h
T
2023-01-21 11:33:15 +01:00

51 lines
1.2 KiB
C++
Executable File

#ifndef TANGENT_PLANNER_PARAMETERS_HELPER_H
#define TANGENT_PLANNER_PARAMETERS_HELPER_H
#include <string>
#include <ros/ros.h>
#include <chrono>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <string>
namespace Planner {
inline
bool hasParam(const std::string& name)
{
return ros::param::has(name);
}
template<typename T>
T getParam(const std::string& name, const T& defaultValue)
{
T v;
if(ros::param::get(name, v))
{
ROS_INFO_STREAM("Found parameter: " << name << ", value: " << v);
return v;
}
else
ROS_WARN_STREAM("Cannot find value for parameter: " << name << ", assigning default: " << defaultValue);
return defaultValue;
}
template<typename T>
T getParam(const std::string& name)
{
T v;
if(ros::param::get(name, v))
{
ROS_INFO_STREAM("Found parameter: " << name << ", value: " << v);
return v;
}
else
ROS_ERROR_STREAM("Cannot find value for parameter: " << name);
return T();
}
} // namespace planner
#endif //TANGENT_PLANNER_PARAMETERS_HELPER_H