recognizer_prediction_psm_client.cpp
Go to the documentation of this file.
1 
18 #include "ros/ros.h"
19 #include "asr_recognizer_prediction_psm/recognizer_prediction_psm.h"
20 #include <cstdlib>
21 #include <asr_msgs/AsrObject.h>
22 
23 #include <ros/package.h>
24 
25 
26 int main(int argc, char **argv)
27 {
28  ros::init(argc, argv, "recognizer_prediction_psm_client");
29  if (argc != 2)
30  {
31  ROS_INFO("usage: recognizer_prediction_psm_client integer");
32  return 1;
33  }
34 
36  ros::ServiceClient client = n.serviceClient<asr_recognizer_prediction_psm::recognizer_prediction_psm>("recognizer_prediction_psm");
37  asr_recognizer_prediction_psm::recognizer_prediction_psm srv;
38 
39 
43  std::string path = ros::package::getPath("asr_recognizer_prediction_psm") + "/models/dome_scene1.xml";
44  std::vector<std::string> scenes;
45  scenes.push_back("background");
46  scenes.push_back("marker_scene1");
47  scenes.push_back("marker_scene2");
48 
49  std::vector<float> probs;
50  probs.push_back(0.25f);
51  probs.push_back(0.5f);
52  probs.push_back(0.25);
53  std::vector<asr_msgs::AsrObject> objects;
54 
55  // Test object
56  {
57  geometry_msgs::Point point;
58  point.x = 0.31f;
59  point.y = 0.35f;
60  point.z = 1.37f;
61 
62  geometry_msgs::Quaternion q;
63  q.w = 1.0f;
64  q.x = 0.0f;
65  q.y = 0.0f;
66  q.z = 0.0f;
67 
68  //Quickfix for new AsrObject format
69  asr_msgs::AsrObject pObj;
70  geometry_msgs::PoseWithCovariance newPose;
71  pObj.type = "VitalisSchoko";
72  pObj.identifier = "/map";
73  pObj.header.frame_id = "/map";
74  newPose.pose.position = point;
75  newPose.pose.orientation = q;
76  pObj.sampledPoses.push_back(newPose);
77  objects.push_back(pObj);
78 
79 
80  pObj.sampledPoses.clear();
81  pObj.type = "Cup";
82  pObj.identifier = "/map";
83  pObj.header.frame_id = "/map";
84 
85  newPose.pose.position = point;
86  newPose.pose.orientation = q;
87 
88  //pObj.sampledPoses.push_back(newPose);
89  //objects.push_back(pObj);
90  }
91 
92 
96  srv.request.pathToXML = path;
97  srv.request.scenes = scenes;
98  srv.request.scene_probabilities = probs;
99  srv.request.num_votes = atoll(argv[1]);
100  srv.request.objects = objects;
101  srv.request.base_frame_id = "/map";
102 
106  if (client.call(srv))
107  {
108  for(auto e : srv.response.pose_hypothesis.elements)
109  {
110  ROS_INFO("Hypothesis type \"%s\" at position (%.2f, %.2f, %.2f), orientation (%.2f, %.2f, %.2f, %.2f), base_frame \"%s\"",
111  e.type.c_str(),
112  e.pose.position.x,
113  e.pose.position.y,
114  e.pose.position.z,
115  e.pose.orientation.w,
116  e.pose.orientation.x,
117  e.pose.orientation.y,
118  e.pose.orientation.z,
119  srv.request.base_frame_id.c_str());
120  }
121  }
122  else
123  {
124  ROS_ERROR("Failed to call service recognizer_prediction_psm");
125  return 1;
126  }
127 
128  return 0;
129 }
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
f
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
int main(int argc, char **argv)
#define ROS_INFO(...)
ROSLIB_DECL std::string getPath(const std::string &package_name)
#define ROS_ERROR(...)


asr_recognizer_prediction_psm
Author(s): Braun Kai, Meißner Pascal
autogenerated on Wed Feb 19 2020 03:31:30