35 #include <gtest/gtest.h> 41 static const float eps = 1e-6;
52 names.push_back(
"JointA");
53 names.push_back(
"JointB");
54 processor_.setJointNames(names);
55 processor_.setCacheSize(1000);
58 for (
unsigned int i=0; i<20; i++)
60 sensor_msgs::JointStatePtr joint_state(
new sensor_msgs::JointState);
61 joint_state->header.stamp =
ros::Time(100+i, 0);
62 joint_state->name.push_back(
"JointA");
63 joint_state->name.push_back(
"JointB");
64 joint_state->name.push_back(
"JointC");
65 joint_state->position.push_back(i*1.0);
66 joint_state->position.push_back(i*10.0);
67 joint_state->position.push_back(i*20.0);
68 joint_state->velocity.resize(3);
69 joint_state->effort.resize(3);
71 success = processor_.addJointState(joint_state);
76 snapshot_.angle_min = 10.0;
77 snapshot_.angle_increment = 1.0;
78 snapshot_.time_increment = .5;
79 snapshot_.readings_per_scan = 4;
80 snapshot_.num_scans = 3;
81 snapshot_.ranges.resize(12);
82 for (
unsigned int i=0; i<snapshot_.ranges.size(); i++)
83 snapshot_.ranges[i] = i*100;
84 snapshot_.scan_start.resize(snapshot_.num_scans);
87 snapshot_.scan_start[2] =
ros::Time(115.1);
90 features_.image_points.resize(P);
93 features_.image_points[0] = Point(0,0);
94 features_.image_points[1] = Point(3,0);
95 features_.image_points[2] = Point(0,2);
96 features_.image_points[3] = Point(3,2);
98 features_.image_points[4] = Point(2.5, .5);
99 features_.image_points[5] = Point(2, 1);
100 features_.image_points[6] = Point(1.25, 1.5);
107 success = processor_.processLaserData(snapshot_, features_, result_,
ros::Duration(2,0));
108 EXPECT_TRUE(success);
111 geometry_msgs::Point
Point(
float x,
float y)
113 geometry_msgs::Point point;
119 static const unsigned int P = 7;
120 calibration_msgs::JointStateCalibrationPattern
result_;
128 EXPECT_FALSE(processor_.isSnapshotEarly(snapshot_));
129 EXPECT_FALSE(processor_.isSnapshotLate(snapshot_));
130 snapshot_.scan_start[2] =
ros::Time(300);
131 EXPECT_TRUE(processor_.isSnapshotEarly(snapshot_));
132 EXPECT_FALSE(processor_.isSnapshotLate(snapshot_));
137 EXPECT_FALSE(processor_.isSnapshotLate(snapshot_));
138 EXPECT_FALSE(processor_.isSnapshotEarly(snapshot_));
140 EXPECT_TRUE(processor_.isSnapshotLate(snapshot_));
141 EXPECT_FALSE(processor_.isSnapshotEarly(snapshot_));
160 ASSERT_EQ(result_.joint_points.size(), (
unsigned int) P);
161 for (
unsigned int i=0; i<result_.joint_points.size(); i++)
163 ASSERT_EQ(result_.joint_points[i].name.size(), (
unsigned int) 4);
164 ASSERT_EQ(result_.joint_points[i].position.size(), (
unsigned int) 4);
165 EXPECT_EQ(result_.joint_points[i].name[0],
"JointA");
166 EXPECT_EQ(result_.joint_points[i].name[1],
"JointB");
171 EXPECT_NEAR(result_.joint_points[0].position[0], 5.0,
eps);
172 EXPECT_NEAR(result_.joint_points[0].position[1], 50.0,
eps);
176 EXPECT_NEAR(result_.joint_points[1].position[0], 6.5,
eps);
177 EXPECT_NEAR(result_.joint_points[1].position[1], 65,
eps);
181 EXPECT_NEAR(result_.joint_points[2].position[0], 15.1,
eps);
182 EXPECT_NEAR(result_.joint_points[2].position[1], 151,
eps);
186 EXPECT_NEAR(result_.joint_points[3].position[0], 16.6,
eps);
187 EXPECT_NEAR(result_.joint_points[3].position[1], 166,
eps);
190 EXPECT_NEAR(result_.joint_points[4].position[0], 8.75,
eps);
191 EXPECT_NEAR(result_.joint_points[4].position[1], 87.5,
eps);
194 EXPECT_NEAR(result_.joint_points[5].position[0], 11,
eps);
195 EXPECT_NEAR(result_.joint_points[5].position[1], 110,
eps);
198 EXPECT_NEAR(result_.joint_points[6].position[0], 13.175,
eps);
199 EXPECT_NEAR(result_.joint_points[6].position[1], 131.75,
eps);
206 ASSERT_EQ(result_.joint_points.size(), (
unsigned int) P);
207 for (
unsigned int i=0; i<P; i++)
209 ASSERT_EQ(result_.joint_points[i].name.size(), (
unsigned int) 4);
210 ASSERT_EQ(result_.joint_points[i].position.size(), (
unsigned int) 4);
211 EXPECT_EQ(result_.joint_points[i].name[2],
"laser_angle_joint");
214 EXPECT_NEAR(result_.joint_points[0].position[2], 10.0,
eps);
215 EXPECT_NEAR(result_.joint_points[1].position[2], 13.0,
eps);
216 EXPECT_NEAR(result_.joint_points[2].position[2], 10.0,
eps);
217 EXPECT_NEAR(result_.joint_points[3].position[2], 13.0,
eps);
218 EXPECT_NEAR(result_.joint_points[4].position[2], 12.5,
eps);
219 EXPECT_NEAR(result_.joint_points[5].position[2], 12.0,
eps);
220 EXPECT_NEAR(result_.joint_points[6].position[2], 11.25,
eps);
227 ASSERT_EQ(result_.joint_points.size(), (
unsigned int) P);
228 for (
unsigned int i=0; i<P; i++)
230 ASSERT_EQ(result_.joint_points[i].name.size(), (
unsigned int) 4);
231 ASSERT_EQ(result_.joint_points[i].position.size(), (
unsigned int) 4);
232 EXPECT_EQ(result_.joint_points[i].name[3],
"laser_range_joint");
235 EXPECT_NEAR(result_.joint_points[0].position[3], 0.0,
eps);
236 EXPECT_NEAR(result_.joint_points[1].position[3], 300.0,
eps);
237 EXPECT_NEAR(result_.joint_points[2].position[3], 800.0,
eps);
238 EXPECT_NEAR(result_.joint_points[3].position[3], 1100.0,
eps);
239 EXPECT_NEAR(result_.joint_points[4].position[3], 450.0,
eps);
240 EXPECT_NEAR(result_.joint_points[5].position[3], 600.0,
eps);
241 EXPECT_NEAR(result_.joint_points[6].position[3], 725.0,
eps);
244 int main(
int argc,
char **argv){
245 testing::InitGoogleTest(&argc, argv);
246 return RUN_ALL_TESTS();
calibration_msgs::DenseLaserSnapshot snapshot_
calibration_msgs::JointStateCalibrationPattern result_
TEST_F(LaserJointProcessor_EasyTests, earlyTest)
LaserJointProcessor processor_
geometry_msgs::Point Point(float x, float y)
int main(int argc, char **argv)
calibration_msgs::CalibrationPattern features_