1 #include <gtest/gtest.h> 5 #include <sensor_msgs/CameraInfo.h> 6 #include <opencv2/highgui/highgui.hpp> 9 #include <fiducial_msgs/FiducialArray.h> 10 #include <fiducial_msgs/FiducialTransformArray.h> 22 c_info.distortion_model =
"plumb_bob";
24 double data_D[] = {0.1349735087283542, -0.2335869827451621, 0.0006697030315075139, 0.004846737465872353, 0.0};
25 c_info.D = std::vector<double> (data_D, data_D +
sizeof(data_D)/
sizeof(
double));
27 c_info.K = {1006.126285753055, 0.0, 655.8639244150409, 0.0, 1004.015433012594, 490.6140221242933, 0.0, 0.0, 1.0};
28 c_info.R = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
29 c_info.P = {1021.54345703125, 0.0, 661.9091982335958, 0.0, 0.0, 1025.251953125, 490.6380671707448, 0.0, 0.0, 0.0, 1.0, 0.0};
91 if (loop_count > 10) {
92 FAIL() <<
"Did not receive estimate within 10 frames";
99 const fiducial_msgs::Fiducial& vertices =
fiducials.fiducials[0];
100 ASSERT_EQ(1, vertices.fiducial_id);
102 ASSERT_FLOAT_EQ(569.89917, vertices.x0);
103 ASSERT_FLOAT_EQ(201.55890, vertices.y0);
104 ASSERT_FLOAT_EQ(777.42560, vertices.x1);
105 ASSERT_FLOAT_EQ(206.85025, vertices.y1);
106 ASSERT_FLOAT_EQ(767.95856, vertices.x2);
107 ASSERT_FLOAT_EQ(415.37830, vertices.y2);
108 ASSERT_FLOAT_EQ(565.75311, vertices.x3);
109 ASSERT_FLOAT_EQ(409.24496, vertices.y3);
120 if (loop_count > 10) {
121 FAIL() <<
"Did not receive estimate within 10 frames";
125 ASSERT_EQ(2,
fiducials.fiducials.size());
128 for (
auto& vertices:
fiducials.fiducials) {
129 if (vertices.fiducial_id == 245) {
130 ASSERT_FLOAT_EQ(307.68246, vertices.x0);
131 ASSERT_FLOAT_EQ(157.38346, vertices.y0);
132 ASSERT_FLOAT_EQ(545.10131, vertices.x1);
133 ASSERT_FLOAT_EQ(167.04420, vertices.y1);
134 ASSERT_FLOAT_EQ(540.11614, vertices.x2);
135 ASSERT_FLOAT_EQ(403.27578, vertices.y2);
136 ASSERT_FLOAT_EQ(305.64746, vertices.x3);
137 ASSERT_FLOAT_EQ(395.01422, vertices.y3);
139 else if (vertices.fiducial_id == 246) {
140 ASSERT_FLOAT_EQ(671.51892, vertices.x0);
141 ASSERT_FLOAT_EQ(173.46070, vertices.y0);
142 ASSERT_FLOAT_EQ(900.29650, vertices.x1);
143 ASSERT_FLOAT_EQ(178.44973, vertices.y1);
144 ASSERT_FLOAT_EQ(895.06933, vertices.x2);
145 ASSERT_FLOAT_EQ(407.39855, vertices.y2);
146 ASSERT_FLOAT_EQ(666.39910, vertices.x3);
147 ASSERT_FLOAT_EQ(403.12911, vertices.y3);
155 int main(
int argc,
char** argv)
158 testing::InitGoogleTest(&argc, argv);
159 ros::init(argc, argv,
"ArucoImagesTest");
160 return RUN_ALL_TESTS();
ros::Publisher CameraInfoPub
image_transport::Publisher image_pub
fiducial_msgs::FiducialArray fiducials
void transforms_callback(const fiducial_msgs::FiducialTransformArray f)
void publish(const boost::shared_ptr< M > &message) const
sensor_msgs::CameraInfo c_info
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
std::string image_directory
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
Publisher advertise(const std::string &base_topic, uint32_t queue_size, bool latch=false)
fiducial_msgs::FiducialTransformArray fiducial_tfs
TEST_F(ArucoImagesTest, tag_01_d7_14cm)
ros::Subscriber vertices_sub
void vertices_callback(const fiducial_msgs::FiducialArray f)
int main(int argc, char **argv)
void publish_image(std::string file)
void publish(const sensor_msgs::Image &message) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
bool getParam(const std::string &key, std::string &s) const
image_transport::ImageTransport * it
ROSCPP_DECL void spinOnce()
ros::Subscriber transforms_sub
sensor_msgs::ImagePtr toImageMsg() const