led_finder.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Fetch Robotics Inc.
3  * Copyright (C) 2013-2014 Unbounded Robotics Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 // Author: Michael Ferguson
19 
20 #ifndef ROBOT_CALIBRATION_CAPTURE_LED_FINDER_H
21 #define ROBOT_CALIBRATION_CAPTURE_LED_FINDER_H
22 
23 #include <ros/ros.h>
26 
27 #include <tf/transform_listener.h>
28 #include <sensor_msgs/Image.h>
29 #include <sensor_msgs/PointCloud2.h>
30 #include <geometry_msgs/PointStamped.h>
31 #include <robot_calibration_msgs/CalibrationData.h>
32 #include <robot_calibration_msgs/GripperLedCommandAction.h>
34 
35 namespace robot_calibration
36 {
37 
39 class LedFinder : public FeatureFinder
40 {
43  {
44 
45  CloudDifferenceTracker(std::string frame, double x, double y, double z);
46 
57  bool process(sensor_msgs::PointCloud2& cloud,
58  sensor_msgs::PointCloud2& prev,
59  geometry_msgs::Point& led_point,
60  double max_distance,
61  double weight);
62 
63  // Have we found the LED?
64  bool isFound(const sensor_msgs::PointCloud2& cloud,
65  double threshold);
66 
67  // Gives a refined centroid using multiple points
68  bool getRefinedCentroid(const sensor_msgs::PointCloud2& cloud,
69  geometry_msgs::PointStamped& centroid);
70 
71  // Reset the tracker
72  void reset(size_t height, size_t width);
73 
74  // Get an image of tracker status
75  sensor_msgs::Image getImage();
76 
77  std::vector<double> diff_;
78  double max_;
79  int max_idx_;
80  int count_;
81  size_t height_, width_;
82  std::string frame_; // frame of led coordinates
83  geometry_msgs::Point point_; //coordinates of led this is tracking
84  };
85 
87 
88 public:
89  LedFinder();
90  bool init(const std::string& name, ros::NodeHandle & n);
91  bool find(robot_calibration_msgs::CalibrationData * msg);
92 
93 private:
94  void cameraCallback(const sensor_msgs::PointCloud2::ConstPtr& cloud);
95  bool waitForCloud();
96 
99  boost::scoped_ptr<LedClient> client_;
100 
101  bool waiting_;
102  sensor_msgs::PointCloud2 cloud_;
103 
104  std::vector<boost::shared_ptr<ros::Publisher> > tracker_publishers_;
105  std::vector<CloudDifferenceTracker> trackers_;
106  std::vector<uint8_t> codes_;
107 
110 
111  /*
112  * ROS Parameters
113  */
114  double max_error_;
116 
117  double threshold_;
119 
121 
122  std::string camera_sensor_name_;
123  std::string chain_sensor_name_;
124 };
125 
126 } // namespace robot_calibration
127 
128 #endif // ROBOT_CALIBRATION_CAPTURE_LED_FINDER_H
bool getRefinedCentroid(const sensor_msgs::PointCloud2 &cloud, geometry_msgs::PointStamped &centroid)
Definition: led_finder.cpp:480
This class processes the point cloud input to find the LED.
Definition: led_finder.h:39
Base class for a feature finder.
DepthCameraInfoManager depth_camera_manager_
Definition: led_finder.h:109
std::string camera_sensor_name_
Should we output debug image/cloud?
Definition: led_finder.h:122
int max_iterations_
Minimum value of diffs in order to trigger that this is an LED.
Definition: led_finder.h:118
CloudDifferenceTracker(std::string frame, double x, double y, double z)
Definition: led_finder.cpp:348
tf::TransformListener listener_
Definition: led_finder.h:108
TFSIMD_FORCE_INLINE const tfScalar & y() const
std::vector< CloudDifferenceTracker > trackers_
Definition: led_finder.h:105
bool process(sensor_msgs::PointCloud2 &cloud, sensor_msgs::PointCloud2 &prev, geometry_msgs::Point &led_point, double max_distance, double weight)
Update the tracker based on new cloud compared to previous.
Definition: led_finder.cpp:379
bool init(const std::string &name, ros::NodeHandle &n)
Initialize the feature finder.
Definition: led_finder.cpp:53
void cameraCallback(const sensor_msgs::PointCloud2::ConstPtr &cloud)
Definition: led_finder.cpp:126
TFSIMD_FORCE_INLINE const tfScalar & x() const
std::vector< uint8_t > codes_
Definition: led_finder.h:106
bool output_debug_
Maximum number of cycles before we abort finding the LED.
Definition: led_finder.h:120
Calibration code lives under this namespace.
sensor_msgs::PointCloud2 cloud_
Definition: led_finder.h:102
TFSIMD_FORCE_INLINE const tfScalar & z() const
Base class for a feature finder.
Definition: depth_camera.h:32
bool find(robot_calibration_msgs::CalibrationData *msg)
Once the robot has been moved into the proper position and settled, this function will be called...
Definition: led_finder.cpp:157
Internally used within LED finder to track each of several LEDs.
Definition: led_finder.h:42
boost::scoped_ptr< LedClient > client_
Outgoing sensor_msgs::PointCloud2.
Definition: led_finder.h:99
std::vector< boost::shared_ptr< ros::Publisher > > tracker_publishers_
Definition: led_finder.h:104
ros::Publisher publisher_
Incoming sensor_msgs::PointCloud2.
Definition: led_finder.h:98
bool isFound(const sensor_msgs::PointCloud2 &cloud, double threshold)
Definition: led_finder.cpp:455
actionlib::SimpleActionClient< robot_calibration_msgs::GripperLedCommandAction > LedClient
Definition: led_finder.h:86
double max_inconsistency_
Maximum distance led can be from expected pose.
Definition: led_finder.h:115
ros::Subscriber subscriber_
Definition: led_finder.h:97


robot_calibration
Author(s): Michael Ferguson
autogenerated on Tue Nov 3 2020 17:30:30