marker_manager.cpp
Go to the documentation of this file.
1 
19 #include <QMetaType>
20 
21 Marker_Manager::Marker_Manager(double timeout, double earlyabort_timeout, QObject *parent) :
22  QThread(parent)
23 {
24  qRegisterMetaType<Eigen::Matrix4d>("Eigen::Matrix4d");
25  qRegisterMetaType<std::string>("std::string");
27 
28  client_GetRecognizer = nh.serviceClient<asr_aruco_marker_recognition::GetRecognizer>("/asr_aruco_marker_recognition/get_recognizer");
29  client_ReleaseRecognizer = nh.serviceClient<asr_aruco_marker_recognition::ReleaseRecognizer>("/asr_aruco_marker_recognition/release_recognizer");
30 
31  this->timeout = timeout;
32  this->earlyabort_timeout = earlyabort_timeout;
33  ROS_INFO_STREAM("Marker Recognition: Timeout = " << timeout);
34  ROS_INFO_STREAM("Marker Recognition: Early Abort = " << earlyabort_timeout);
35  if (timeout-earlyabort_timeout <= 0.0)
36  {
37  ROS_ERROR("Marker Recognition: Early Abort was invalid");
38  earlyabort_timeout = 0.0;
39  }
40 }
41 
43 {
44  if (getRecognizer())
45  {
46  //Start recognition
47  recognizedMarker = false;
48 
50  d.sleep();
51 
52  //Early abort
53  if (!recognizedMarker)
54  {
55  ROS_INFO("No Marker found -> Early abort.");
56  markerFound("", Eigen::Matrix4d::Identity());
58 
59  }
60  else
61  {
63  d.sleep();
64 
65  markerFound("", Eigen::Matrix4d::Identity());
67  }
68  }
69  else
70  {
71  ROS_ERROR("Could not start recognition.");
72  }
73 }
74 
75 void Marker_Manager::markerRecognitionCallback(const asr_msgs::AsrObject::ConstPtr object)
76 {
77  asr_msgs::AsrObject o = *object;
78  recognizedMarker = true;
79  std::string ID = o.type;
80  Eigen::Affine3d transform;
81  if(o.sampledPoses.size() > 0)
82  {
83  tf::poseMsgToEigen(o.sampledPoses.at(0).pose, transform);
84  markerFound(ID, transform.matrix());
85  }
86 }
87 
89 {
90  a.shutdown();
91  asr_aruco_marker_recognition::ReleaseRecognizer release;
92  return client_ReleaseRecognizer.call(release);
93 }
94 
96 {
97  a = nh.subscribe("/stereo/objects", 1000, &Marker_Manager::markerRecognitionCallback, this);
98  asr_aruco_marker_recognition::GetRecognizer get;
99  return client_GetRecognizer.call(get);
100 }
101 
102 
bool releaseRecognizer()
d
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
bool sleep() const
bool call(MReq &req, MRes &res)
ROSCPP_DECL const std::string & getName()
void markerRecognitionCallback(const asr_msgs::AsrObject::ConstPtr object)
Marker_Manager(double timeout, double earlyabort_timeout, QObject *parent=0)
#define ROS_INFO(...)
ros::ServiceClient client_ReleaseRecognizer
double earlyabort_timeout
ros::NodeHandle nh
ros::Subscriber a
void markerFound(std::string markerNumber, const Eigen::Matrix4d &transformation)
#define ROS_INFO_STREAM(args)
ros::ServiceClient client_GetRecognizer
#define ROS_ERROR(...)


asr_mild_calibration_tool
Author(s): Aumann Florian, Heller Florian, Meißner Pascal
autogenerated on Mon Dec 2 2019 03:11:43