Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef GPUGLTRACKER_H
00044 #define GPUGLTRACKER_H
00045
00046 #include <blort_ros/trackerinterface.hpp>
00047 #include <blort_msgs/TrackerConfidences.h>
00048 #include <blort_msgs/TrackerCommand.h>
00049 #include <blort_ros/TrackerConfig.h>
00050 #include <geometry_msgs/Pose.h>
00051 #include <string>
00052
00053 #include <blort/Tracker/TextureTracker.h>
00054 #include <blort/TomGine/tgModel.h>
00055 #include <blort/TomGine/tgTimer.h>
00056
00057 #include <blort/ObjectEntry.h>
00058
00059 namespace blort_ros
00060 {
00061 enum TrackerPublishMode
00062 {
00063 TRACKER_PUBLISH_GOOD = 0,
00064 TRACKER_PUBLISH_GOOD_AND_FAIR = 1,
00065 TRACKER_PUBLISH_ALL = 2
00066 };
00067
00068 class GLTracker : public TrackerInterface
00069 {
00070 private:
00071
00072 double conf_threshold;
00073 bool visualize_obj_pose;
00074 int publish_mode;
00075
00076 float recovery_conf_threshold;
00077
00078
00079 TomGine::tgCamera::Parameter tgcam_params;
00080 TomGine::tgTimer timer;
00081 TomGine::tgPose cam_pose;
00082 Tracking::Tracker::Parameter track_params;
00083
00084 Tracking::TextureTracker tracker;
00085
00086
00087 std::string config_root_;
00088 std::string pose_cal;
00089
00090
00091 std::vector<blort::ObjectEntry> objects_;
00092 std::map<std::string, int> model_ids;
00093
00094
00095 boost::mutex models_mutex;
00096
00097
00098 IplImage *image;
00099
00100
00101
00102 geometry_msgs::Pose fixed_cam_pose;
00103 std::map<std::string, geometry_msgs::Pose> result;
00104
00105
00106 bool last_reset;
00107
00108 public:
00109 GLTracker(const sensor_msgs::CameraInfo camera_info,
00110 const std::string& config_root,
00111 bool visualize_obj_pose = false);
00112
00114 virtual void recovery() {}
00115
00117 virtual void track();
00118
00119 void reset(const std::vector<std::string> & params = std::vector<std::string>());
00120
00123 void reconfigure(blort_ros::TrackerConfig config);
00124
00129 void trackerControl(uint8_t code, const std::vector<std::string> & params);
00130
00131 void resetWithPose(std::string obj_id, const geometry_msgs::Pose& new_pose);
00132
00134
00135
00137 std::map<std::string, geometry_msgs::Pose>& getDetections(){ return result; }
00138
00140 const geometry_msgs::Pose getCameraReferencePose(){ return fixed_cam_pose; }
00141
00143 cv::Mat getImage();
00144
00146 const std::string & getModelName(size_t i) { return objects_[i].name; }
00147
00148 void setVisualizeObjPose(bool enable){ visualize_obj_pose = enable; }
00149
00150 void setPublishMode(TrackerPublishMode mode){ publish_mode = mode; }
00151
00152 TrackerPublishMode getPublishMode() { return (TrackerPublishMode)publish_mode; }
00153
00154 virtual void switchToTracking(const std::string& id);
00155
00156 virtual void switchToRecovery(const std::string& id);
00157
00158 virtual void switchTracking(const std::vector<std::string> & params);
00159
00160 bool isTracked(const std::string& id);
00161 void setTracked(const std::string& id, bool tracked);
00162
00163 const std::vector<blort::ObjectEntry>& getObjects() const;
00164
00165 void enableAllTracking(bool enable);
00166
00167 ~GLTracker();
00168
00169 private:
00172 void update();
00173
00176 void updatePoseResult(std::string i);
00177
00178 void resetParticleFilter(std::string id);
00179
00180 blort::ObjectEntry& getObjEntryByName(const std::string& name);
00181 };
00182 }
00183
00184 #endif // GPUGLTRACKER_H