aruco_mapping.h
Go to the documentation of this file.
1 /*********************************************************************************************/
32 /* Author: Jan Bacik */
33 
34 #ifndef ARUCO_MAPPING_H
35 #define ARUCO_MAPPING_H
36 
37 #include <fstream>
38 
39 // Standard ROS libraries
40 #include <ros/ros.h>
41 #include <ros/package.h>
45 #include <tf/transform_listener.h>
46 #include <visualization_msgs/Marker.h>
48 #include <cv_bridge/cv_bridge.h>
49 
50 // Aruco libraries
51 #include <aruco/aruco.h>
52 #include <aruco/cameraparameters.h>
53 #include <aruco/cvdrawingutils.h>
54 #include <aruco/arucofidmarkers.h>
55 
56 // OpenCV libraries
57 #include <opencv2/opencv.hpp>
58 #include <opencv2/core/core.hpp>
59 #include <opencv2/calib3d/calib3d.hpp>
60 #include <opencv2/highgui/highgui.hpp>
61 
62 // Custom message
63 #include <aruco_mapping/ArucoMarker.h>
64 
66 namespace aruco_mapping
67 {
68 
71 {
72 public:
73 
75  struct MarkerInfo
76  {
77 
78  bool visible; // Marker visibile in actual image?
79  int marker_id; // Marker ID
80  int previous_marker_id; // Used for chaining markers
81  geometry_msgs::Pose geometry_msg_to_previous; // Position with respect to previous marker
82  geometry_msgs::Pose geometry_msg_to_world; // Position with respect to world's origin
83  tf::StampedTransform tf_to_previous; // TF with respect to previous marker
84  tf::StampedTransform tf_to_world; // TF with respect to world's origin
85  geometry_msgs::Pose current_camera_pose; // Position of camera with respect to the marker
86  tf::Transform current_camera_tf; // TF of camera with respect to the marker
87  };
88 
89 public:
90 
93 
94  ~ArucoMapping();
95 
97  void imageCallback(const sensor_msgs::ImageConstPtr &original_image);
98 
99 private:
100 
102  bool parseCalibrationFile(std::string filename);
103 
105  void publishTfs(bool world_option);
106 
108  void publishMarker(geometry_msgs::Pose markerPose, int MarkerID, int rank);
109 
112 
115 
118 
121 
123  bool processImage(cv::Mat input_image,cv::Mat output_image);
124 
125  //Launch file params
126  std::string calib_filename_;
127  std::string space_type_;
131  int roi_x_;
132  int roi_y_;
133  int roi_w_;
134  int roi_h_;
135 
137  std::vector<MarkerInfo> markers_;
138 
141 
143  geometry_msgs::Pose world_position_geometry_msg_;
144 
146 
152 
155 
156  //Consts
157  static const int CV_WAIT_KEY = 10;
158  static const int CV_WINDOW_MARKER_LINE_WIDTH = 2;
159 
160  static constexpr double WAIT_FOR_TRANSFORM_INTERVAL = 2.0;
161  static constexpr double BROADCAST_WAIT_INTERVAL = 0.0001;
162  static constexpr double INIT_MIN_SIZE_VALUE = 1000000;
163 
164  static constexpr double RVIZ_MARKER_HEIGHT = 0.01;
165  static constexpr double RVIZ_MARKER_LIFETIME = 0.2;
166  static constexpr double RVIZ_MARKER_COLOR_R = 1.0;
167  static constexpr double RVIZ_MARKER_COLOR_G = 1.0;
168  static constexpr double RVIZ_MARKER_COLOR_B = 1.0;
169  static constexpr double RVIZ_MARKER_COLOR_A = 1.0;
170 
171  static constexpr double THIS_IS_FIRST_MARKER = -2;
172 
173 }; //ArucoMapping class
174 } //aruco_mapping namespace
175 
176 #endif //ARUCO_MAPPING_H
static constexpr double RVIZ_MARKER_COLOR_A
ros::Publisher marker_visualization_pub_
Publisher of visualization_msgs::Marker message to "aruco_markers" topic.
ros::Publisher marker_msg_pub_
Publisher of aruco_mapping::ArucoMarker custom message.
static constexpr double WAIT_FOR_TRANSFORM_INTERVAL
Struct to keep marker information.
Definition: aruco_mapping.h:75
tf::TransformListener * listener_
static constexpr double THIS_IS_FIRST_MARKER
static constexpr double INIT_MIN_SIZE_VALUE
void publishMarker(geometry_msgs::Pose markerPose, int MarkerID, int rank)
Function to publish all known markers for visualization purposes.
static constexpr double RVIZ_MARKER_COLOR_G
tf::Transform arucoMarker2Tf(const aruco::Marker &marker)
Compute TF from marker detector result.
tf::TransformBroadcaster broadcaster_
Client class for Aruco mapping.
Definition: aruco_mapping.h:70
ArucoMapping(ros::NodeHandle *nh)
Construct a client for EZN64 USB control.
ros::Publisher lidar_camera_calibration_rt
Publisher of std::vector<double> message for tvec and rvec for lidar_camera_calibration.
tf::StampedTransform world_position_transform_
Actual TF of camera with respect to world&#39;s origin.
static const int CV_WINDOW_MARKER_LINE_WIDTH
This class represents a marker. It is a vector of the fours corners ot the marker.
bool parseCalibrationFile(std::string filename)
Function to parse data from calibration file.
aruco::CameraParameters aruco_calib_params_
static constexpr double RVIZ_MARKER_COLOR_B
geometry_msgs::Pose geometry_msg_to_previous
Definition: aruco_mapping.h:81
std::vector< MarkerInfo > markers_
Container holding MarkerInfo data about all detected markers.
static constexpr double RVIZ_MARKER_HEIGHT
geometry_msgs::Pose world_position_geometry_msg_
Actual Pose of camera with respect to world&#39;s origin.
static const int CV_WAIT_KEY
static constexpr double RVIZ_MARKER_LIFETIME
static constexpr double RVIZ_MARKER_COLOR_R
Aruco mapping namespace.
Definition: aruco_mapping.h:66
void imageCallback(const sensor_msgs::ImageConstPtr &original_image)
Callback function to handle image processing.
bool processImage(cv::Mat input_image, cv::Mat output_image)
Process actual image, detect markers and compute poses.
void publishTfs(bool world_option)
Function to publish all known TFs.
static constexpr double BROADCAST_WAIT_INTERVAL


lidar_camera_calibration
Author(s):
autogenerated on Sat Feb 6 2021 03:39:37