35 #include <gtest/gtest.h> 37 #include <monocam_settler/ConfigGoal.h> 45 static const unsigned int N = 9;
46 static const unsigned int C = 2;
48 static const double data[
N][2*
C] = { { 0, 0, 0, 0 },
59 static const unsigned int times[
N][2] = { { 0, 0 },
82 vector<calibration_msgs::Interval> intervals;
84 for (
unsigned int i=0; i<
N; i++)
86 calibration_msgs::CalibrationPatternPtr msg(
new calibration_msgs::CalibrationPattern);
89 msg->image_points.resize(
C);
90 for (
unsigned int j=0; j<
C; j++)
92 msg->image_points[j].x =
data[i][2*j+0];
93 msg->image_points[j].y =
data[i][2*j+1];
95 msg->success = always_success ||
success[i];
97 calibration_msgs::Interval cur_interval;
98 bool result = settler.
add(msg, cur_interval);
100 intervals.push_back(cur_interval);
102 intervals.push_back(calibration_msgs::Interval());
108 void doEasyCheck(
const vector<calibration_msgs::Interval>& intervals)
110 ASSERT_EQ(intervals.size(),
N);
111 EXPECT_EQ(intervals[0].
start.sec, (
unsigned int) 0);
112 EXPECT_EQ(intervals[0].end.sec, (
unsigned int) 0);
114 EXPECT_EQ(intervals[1].
start.sec, (
unsigned int) 0);
115 EXPECT_EQ(intervals[1].end.sec, (
unsigned int) 1);
117 EXPECT_EQ(intervals[2].
start.sec, (
unsigned int) 1);
118 EXPECT_EQ(intervals[2].end.sec, (
unsigned int) 2);
120 EXPECT_EQ(intervals[3].
start.sec, (
unsigned int) 2);
121 EXPECT_EQ(intervals[3].end.sec, (
unsigned int) 3);
123 EXPECT_EQ(intervals[4].
start.sec, (
unsigned int) 3);
124 EXPECT_EQ(intervals[4].end.sec, (
unsigned int) 4);
126 EXPECT_EQ(intervals[5].
start.sec, (
unsigned int) 5);
127 EXPECT_EQ(intervals[5].end.sec, (
unsigned int) 5);
129 EXPECT_EQ(intervals[6].
start.sec, (
unsigned int) 6);
130 EXPECT_EQ(intervals[6].end.sec, (
unsigned int) 6);
132 EXPECT_EQ(intervals[7].
start.sec, (
unsigned int) 7);
133 EXPECT_EQ(intervals[7].end.sec, (
unsigned int) 7);
135 EXPECT_EQ(intervals[8].
start.sec, (
unsigned int) 8);
136 EXPECT_EQ(intervals[8].end.sec, (
unsigned int) 8);
141 ASSERT_EQ(intervals.size(),
N);
142 EXPECT_EQ(intervals[0].
start.sec, (
unsigned int) 0);
143 EXPECT_EQ(intervals[0].end.sec, (
unsigned int) 0);
145 EXPECT_EQ(intervals[1].
start.sec, (
unsigned int) 0);
146 EXPECT_EQ(intervals[1].end.sec, (
unsigned int) 1);
148 EXPECT_EQ(intervals[2].
start.sec, (
unsigned int) 0);
149 EXPECT_EQ(intervals[2].end.sec, (
unsigned int) 0);
151 EXPECT_EQ(intervals[3].
start.sec, (
unsigned int) 0);
152 EXPECT_EQ(intervals[3].end.sec, (
unsigned int) 3);
154 EXPECT_EQ(intervals[4].
start.sec, (
unsigned int) 0);
155 EXPECT_EQ(intervals[4].end.sec, (
unsigned int) 4);
157 EXPECT_EQ(intervals[5].
start.sec, (
unsigned int) 0);
158 EXPECT_EQ(intervals[5].end.sec, (
unsigned int) 5);
160 EXPECT_EQ(intervals[6].
start.sec, (
unsigned int) 0);
161 EXPECT_EQ(intervals[6].end.sec, (
unsigned int) 6);
163 EXPECT_EQ(intervals[7].
start.sec, (
unsigned int) 0);
164 EXPECT_EQ(intervals[7].end.sec, (
unsigned int) 7);
166 EXPECT_EQ(intervals[8].
start.sec, (
unsigned int) 0);
167 EXPECT_EQ(intervals[8].end.sec, (
unsigned int) 8);
172 ASSERT_EQ(intervals.size(),
N);
173 EXPECT_EQ(intervals[0].
start.sec, (
unsigned int) 0);
174 EXPECT_EQ(intervals[0].end.sec, (
unsigned int) 0);
176 EXPECT_EQ(intervals[1].
start.sec, (
unsigned int) 0);
177 EXPECT_EQ(intervals[1].end.sec, (
unsigned int) 1);
179 EXPECT_EQ(intervals[2].
start.sec, (
unsigned int) 0);
180 EXPECT_EQ(intervals[2].end.sec, (
unsigned int) 0);
182 EXPECT_EQ(intervals[3].
start.sec, (
unsigned int) 3);
183 EXPECT_EQ(intervals[3].end.sec, (
unsigned int) 3);
185 EXPECT_EQ(intervals[4].
start.sec, (
unsigned int) 3);
186 EXPECT_EQ(intervals[4].end.sec, (
unsigned int) 4);
188 EXPECT_EQ(intervals[5].
start.sec, (
unsigned int) 3);
189 EXPECT_EQ(intervals[5].end.sec, (
unsigned int) 5);
191 EXPECT_EQ(intervals[6].
start.sec, (
unsigned int) 3);
192 EXPECT_EQ(intervals[6].end.sec, (
unsigned int) 6);
194 EXPECT_EQ(intervals[7].
start.sec, (
unsigned int) 3);
195 EXPECT_EQ(intervals[7].end.sec, (
unsigned int) 7);
197 EXPECT_EQ(intervals[8].
start.sec, (
unsigned int) 3);
198 EXPECT_EQ(intervals[8].end.sec, (
unsigned int) 8);
205 config.tolerance = 2.5;
207 config.ignore_failures =
true;
211 config.cache_size = 100;
220 config.tolerance = 100.0;
222 config.ignore_failures = ignore_failures;
226 config.cache_size = 100;
236 ASSERT_TRUE(config_result);
238 vector<calibration_msgs::Interval> intervals =
addToSettler(settler, 0,
true);
248 ASSERT_TRUE(config_result);
250 vector<calibration_msgs::Interval> intervals =
addToSettler(settler, 0,
false);
260 ASSERT_TRUE(config_result);
262 vector<calibration_msgs::Interval> intervals =
addToSettler(settler, 0,
false);
272 ASSERT_TRUE(config_result);
274 vector<calibration_msgs::Interval> intervals =
addToSettler(settler, 0,
true);
279 ASSERT_TRUE(config_result);
286 int main(
int argc,
char **argv)
288 testing::InitGoogleTest(&argc, argv);
289 return RUN_ALL_TESTS();
static const bool success[N]
bool add(const calibration_msgs::CalibrationPatternConstPtr msg, calibration_msgs::Interval &interval)
ConfigGoal config2(bool ignore_failures)
void doCatchFailuresCheck(const vector< calibration_msgs::Interval > &intervals)
static const unsigned int N
void doEasyCheck(const vector< calibration_msgs::Interval > &intervals)
static const unsigned int times[N][2]
bool configure(const monocam_settler::ConfigGoal &goal)
void doIgnoreFailuresCheck(const vector< calibration_msgs::Interval > &intervals)
static const unsigned int C
int main(int argc, char **argv)
TEST(MonocamSettler, easyCheck)
vector< calibration_msgs::Interval > addToSettler(MonocamSettler &settler, unsigned int time_channel, bool always_success)
static const double data[N][2 *C]