35 #include <hector_nav_msgs/GetDistanceToObstacle.h> 36 #include <hector_nav_msgs/GetNormal.h> 60 namespace Parameters {
62 void load(
const std::string &class_id )
64 static std::set<std::string> _per_class_parameters_loaded;
66 if (_per_class_parameters_loaded.count(class_id))
return;
69 std::string prefix = class_id +
"/";
70 if (prefix ==
"/") prefix.clear();
72 if (priv_nh.
hasParam(prefix +
"project_objects"))
73 priv_nh.
getParam(prefix +
"project_objects", _project_objects[class_id]);
74 if (priv_nh.
hasParam(prefix +
"with_orientation"))
75 priv_nh.
getParam(prefix +
"with_orientation", _with_orientation[class_id]);
76 if (priv_nh.
hasParam(prefix +
"default_distance"))
77 priv_nh.
getParam(prefix +
"default_distance", _default_distance[class_id]);
78 if (priv_nh.
hasParam(prefix +
"distance_variance"))
79 priv_nh.
getParam(prefix +
"distance_variance", _distance_variance[class_id]);
80 if (priv_nh.
hasParam(prefix +
"angle_variance"))
81 priv_nh.
getParam(prefix +
"angle_variance", _angle_variance[class_id]);
82 if (priv_nh.
hasParam(prefix +
"min_height"))
83 priv_nh.
getParam(prefix +
"min_height", _min_height[class_id]);
84 if (priv_nh.
hasParam(prefix +
"max_height"))
85 priv_nh.
getParam(prefix +
"max_height", _max_height[class_id]);
86 if (priv_nh.
hasParam(prefix +
"pending_support"))
87 priv_nh.
getParam(prefix +
"pending_support", _pending_support[class_id]);
88 if (priv_nh.
hasParam(prefix +
"pending_time"))
89 priv_nh.
getParam(prefix +
"pending_time", _pending_time[class_id]);
90 if (priv_nh.
hasParam(prefix +
"active_support"))
91 priv_nh.
getParam(prefix +
"active_support", _active_support[class_id]);
92 if (priv_nh.
hasParam(prefix +
"active_time"))
93 priv_nh.
getParam(prefix +
"active_time", _active_time[class_id]);
94 if (priv_nh.
hasParam(prefix +
"inactive_support"))
95 priv_nh.
getParam(prefix +
"inactive_support", _inactive_support[class_id]);
96 if (priv_nh.
hasParam(prefix +
"inactive_time"))
97 priv_nh.
getParam(prefix +
"inactive_time", _inactive_time[class_id]);
98 if (priv_nh.
hasParam(prefix +
"min_distance_between_objects"))
99 priv_nh.
getParam(prefix +
"min_distance_between_objects", _min_distance_between_objects[class_id]);
101 if (priv_nh.
hasParam(prefix +
"marker_color")) {
103 priv_nh.
getParam(prefix +
"marker_color", color);
105 _marker_color[class_id].r = (double) color[0];
106 _marker_color[class_id].g = (double) color[1];
107 _marker_color[class_id].b = (double) color[2];
108 if (color.
size() > 3)
109 _marker_color[class_id].a = (
double) color[3];
111 _marker_color[class_id].a = 1.0;
113 ROS_ERROR_STREAM(
"Illegal value for param marker_color: " << color <<
". Must be an array of size 3 or 4.");
117 std::string distance_to_obstacle_service;
118 if (priv_nh.
hasParam(prefix +
"distance_to_obstacle_service")) {
119 priv_nh.
getParam(prefix +
"distance_to_obstacle_service", distance_to_obstacle_service);
120 }
else if (class_id.empty()) {
121 distance_to_obstacle_service =
"get_distance_to_obstacle";
124 if (!distance_to_obstacle_service.empty()) {
125 _distance_to_obstacle_service[class_id].reset(
new ros::ServiceClient(
ros::NodeHandle().serviceClient<hector_nav_msgs::GetDistanceToObstacle>(distance_to_obstacle_service)));
126 bool project_objects = _project_objects.count(class_id) ? _project_objects.at(class_id) : _project_objects.at(std::string());
127 if (project_objects && !_distance_to_obstacle_service[class_id]->waitForExistence(
ros::Duration(5.0))) {
128 ROS_WARN_STREAM(
"project_objects is true, but GetDistanceToObstacle service is not (yet) available" << (!class_id.empty() ?
"for class " + class_id :
""));
132 if (priv_nh.
hasParam(prefix +
"get_normal_service")) {
133 std::string get_normal_service;
134 priv_nh.
getParam(prefix +
"get_normal_service", get_normal_service);
138 _per_class_parameters_loaded.insert(class_id);
std::map< std::string, double > _inactive_support
std::map< std::string, double > _pending_support
std::map< std::string, ros::ServiceClientPtr > _distance_to_obstacle_service
std::map< std::string, double > _inactive_time
std::map< std::string, double > _min_height
std::map< std::string, double > _active_time
std::map< std::string, double > _pending_time
std::map< std::string, double > _min_distance_between_objects
std::map< std::string, ros::ServiceClientPtr > _get_normal_service
std::map< std::string, std_msgs::ColorRGBA > _marker_color
std::map< std::string, bool > _with_orientation
std::map< std::string, double > _max_height
Type const & getType() const
void load(const std::string &class_id)
std::map< std::string, bool > _project_objects
std::map< std::string, double > _default_distance
std::map< std::string, ServiceClientsWithProperties > _percept_verification_services
std::map< std::string, double > _active_support
std::map< std::string, double > _angle_variance
#define ROS_WARN_STREAM(args)
bool getParam(const std::string &key, std::string &s) const
std::map< std::string, double > _distance_variance
bool hasParam(const std::string &key) const
#define ROS_ERROR_STREAM(args)
std::map< std::string, ServiceClientsWithProperties > _object_verification_services