40 : nh_(nh), rest_helper_(host, node_name, 10000), visualizer_(nh)
53 catch (
const std::exception& ex)
55 ROS_FATAL(
"Exception during destruction of PickClient: %s", ex.what());
59 ROS_FATAL(
"Exception during destruction of PickClient");
74 rc_pick_client::SetLoadCarrierResponse& response)
81 rc_pick_client::GetLoadCarriersResponse& response)
83 callService(
"get_load_carriers", request, response);
88 rc_pick_client::DeleteLoadCarriersResponse& response)
90 callService(
"delete_load_carriers", request, response);
95 rc_pick_client::DetectLoadCarriersResponse& response)
97 callService(
"detect_load_carriers", request, response);
103 rc_pick_client::DetectFillingLevelResponse& response)
105 callService(
"detect_filling_level", request, response);
111 rc_pick_client::SetRegionOfInterestResponse& response)
113 callService(
"set_region_of_interest", request, response);
118 rc_pick_client::GetRegionsOfInterestResponse& response)
120 callService(
"get_regions_of_interest", request, response);
125 rc_pick_client::DeleteRegionsOfInterestResponse& response)
127 callService(
"delete_regions_of_interest", request, response);
145 for (
const auto&
param : params)
147 const auto& name =
param[
"name"];
148 if (name ==
"cluster_max_curvature")
150 cfg.cluster_max_curvature =
param[
"value"];
152 else if (name ==
"cluster_max_dimension")
154 cfg.cluster_max_dimension =
param[
"value"];
156 else if (name ==
"clustering_discontinuity_factor")
158 cfg.clustering_discontinuity_factor =
param[
"value"];
160 else if (name ==
"clustering_max_surface_rmse")
162 cfg.clustering_max_surface_rmse =
param[
"value"];
164 else if (name ==
"clustering_patch_size")
166 cfg.clustering_patch_size =
param[
"value"];
168 else if (name ==
"load_carrier_crop_distance")
170 cfg.load_carrier_crop_distance =
param[
"value"];
172 else if (name ==
"load_carrier_model_tolerance")
174 cfg.load_carrier_model_tolerance =
param[
"value"];
181 rc_pick_client::pickModuleConfig cfg;
190 nh_.
param(
"cluster_max_curvature", cfg.cluster_max_curvature, cfg.cluster_max_curvature);
191 nh_.
param(
"cluster_max_dimension", cfg.cluster_max_dimension, cfg.cluster_max_dimension);
192 nh_.
param(
"clustering_discontinuity_factor", cfg.clustering_discontinuity_factor,
193 cfg.clustering_discontinuity_factor);
194 nh_.
param(
"clustering_max_surface_rmse", cfg.clustering_max_surface_rmse, cfg.clustering_max_surface_rmse);
195 nh_.
param(
"clustering_patch_size", cfg.clustering_patch_size, cfg.clustering_patch_size);
196 nh_.
param(
"load_carrier_crop_distance", cfg.load_carrier_crop_distance, cfg.load_carrier_crop_distance);
197 nh_.
param(
"load_carrier_model_tolerance", cfg.load_carrier_model_tolerance, cfg.load_carrier_model_tolerance);
200 nh_.
setParam(
"cluster_max_curvature", cfg.cluster_max_curvature);
201 nh_.
setParam(
"cluster_max_dimension", cfg.cluster_max_dimension);
202 nh_.
setParam(
"clustering_discontinuity_factor", cfg.clustering_discontinuity_factor);
203 nh_.
setParam(
"clustering_max_surface_rmse", cfg.clustering_max_surface_rmse);
204 nh_.
setParam(
"clustering_patch_size", cfg.clustering_patch_size);
205 nh_.
setParam(
"load_carrier_crop_distance", cfg.load_carrier_crop_distance);
206 nh_.
setParam(
"load_carrier_model_tolerance", cfg.load_carrier_model_tolerance);
209 using ReconfServer = dynamic_reconfigure::Server<rc_pick_client::pickModuleConfig>;
210 server_ = std::unique_ptr<ReconfServer>(
new ReconfServer(
nh_));
216 json js_params, js_param;
217 js_param[
"name"] =
"cluster_max_curvature";
218 js_param[
"value"] = config.cluster_max_curvature;
219 js_params.push_back(js_param);
220 js_param[
"name"] =
"clustering_discontinuity_factor";
221 js_param[
"value"] = config.clustering_discontinuity_factor;
222 js_param[
"name"] =
"clustering_max_surface_rmse";
223 js_param[
"value"] = config.clustering_max_surface_rmse;
224 js_params.push_back(js_param);
225 js_param[
"name"] =
"load_carrier_crop_distance";
226 js_param[
"value"] = config.load_carrier_crop_distance;
227 js_params.push_back(js_param);
228 js_param[
"name"] =
"load_carrier_model_tolerance";
229 js_param[
"value"] = config.load_carrier_model_tolerance;
230 js_params.push_back(js_param);
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val)
PickClient(const std::string &host, const std::string &node_name, const ros::NodeHandle &nh)
bool detectLoadCarriersSrv(rc_pick_client::DetectLoadCarriersRequest &request, rc_pick_client::DetectLoadCarriersResponse &response)
ros::ServiceServer srv_detect_filling_level_
ros::ServiceServer srv_set_lc_
bool deleteROISrv(rc_pick_client::DeleteRegionsOfInterestRequest &request, rc_pick_client::DeleteRegionsOfInterestResponse &response)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
bool setROI(rc_pick_client::SetRegionOfInterestRequest &request, rc_pick_client::SetRegionOfInterestResponse &response)
ros::ServiceServer srv_detect_lc_
ros::ServiceServer srv_get_lcs_
ros::ServiceServer srv_get_rois_
ros::ServiceServer srv_set_roi_
std::unique_ptr< dynamic_reconfigure::Server< rc_pick_client::pickModuleConfig > > server_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
json createSharedParameters(rc_pick_client::pickModuleConfig &config)
ros::ServiceServer srv_delete_rois_
ros::ServiceServer srv_delete_lcs_
bool setLoadCarrier(rc_pick_client::SetLoadCarrierRequest &request, rc_pick_client::SetLoadCarrierResponse &response)
bool detectFillingLevelSrv(rc_pick_client::DetectFillingLevelRequest &request, rc_pick_client::DetectFillingLevelResponse &response)
bool getLoadCarriers(rc_pick_client::GetLoadCarriersRequest &request, rc_pick_client::GetLoadCarriersResponse &response)
bool getROIs(rc_pick_client::GetRegionsOfInterestRequest &request, rc_pick_client::GetRegionsOfInterestResponse &response)
bool callService(const std::string &name, const Request &req, Response &res)
void visualizeLoadCarriers(const std::vector< rc_pick_client::LoadCarrier > &ros_lcs)
void paramsToCfg(const json ¶ms, rc_pick_client::pickModuleConfig &cfg)
bool deleteLoadCarriersSrv(rc_pick_client::DeleteLoadCarriersRequest &request, rc_pick_client::DeleteLoadCarriersResponse &response)
pick_visualization::Visualization visualizer_
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
rc_rest_api::RestHelper rest_helper_
json servicePutRequest(const std::string &service_name)