1 #include <gtest/gtest.h>
4 #include <opencv2/highgui/highgui.hpp>
7 #include <image_geometry/pinhole_camera_model.h>
8 #include <ros/console.h>
9 #include <ros/package.h>
10 #include <sensor_msgs/CameraInfo.h>
11 #include <sensor_msgs/distortion_models.h>
58 double sinr_cosp = 2 * (q.
w * q.
x + q.
y * q.
z);
59 double cosr_cosp = 1 - 2 * (q.
x * q.
x + q.
y * q.
y);
63 double sinp = 2 * (q.
w * q.
y - q.
z * q.
x);
64 if (std::abs(sinp) >= 1)
70 double siny_cosp = 2 * (q.
w * q.
z + q.
x * q.
y);
71 double cosy_cosp = 1 - 2 * (q.
y * q.
y + q.
z * q.
z);
86 quaternion.
x = geo_quaternion.
getX();
87 quaternion.
y = geo_quaternion.
getY();
88 quaternion.
z = geo_quaternion.
getZ();
89 quaternion.
w = geo_quaternion.
getW();
93 ROS_DEBUG_STREAM(
"Matrix: " << rotation <<
" --> yaw: " << angles.
yaw);
105 return input * M_PI / 180.0;
117 sensor_msgs::CameraInfo cam_info;
118 cam_info.K = sensor_msgs::CameraInfo::_K_type({554.2559327880068, 0.0, 320.5,
119 0.0, 554.2559327880068, 240.5,
121 cam_info.P = sensor_msgs::CameraInfo::_P_type({554.2559327880068, 0.0, 320.5, 0.0,
122 0.0, 554.2559327880068, 240.5, 0.0,
123 0.0, 0.0, 1.0, 0.0});
124 cam_info.distortion_model = sensor_msgs::distortion_models::PLUMB_BOB;
125 cam_info.width = resolution.
width;
126 cam_info.height = resolution.
height;
157 ROS_DEBUG_STREAM(
"Fitting: Processing sensor data");
160 ROS_DEBUG_STREAM(
"Fitting: getting entity");
164 ROS_DEBUG_STREAM(
"Fitting: estimating entity pose");
165 return fitter.
estimateEntityPose(fitterdata, wm, entity_id, e->pose(), new_pose, max_yaw_change);
173 ROS_DEBUG_STREAM(
"Setting up... ");
181 if (
const char* original_path = ::getenv(name.
c_str()))
185 std::string package_path = ros::package::getPath(
"ed_sensor_integration");
192 ROS_INFO_STREAM(
"New " << name <<
": " << new_path);
193 ::setenv(name.c_str(), new_path.
c_str(), 1);
198 ROS_DEBUG_STREAM(
"Tearing down... ");
202 ::setenv(it->first.c_str(), it->second, 1);
204 ::unsetenv(it->first.c_str());
245 ROS_DEBUG_STREAM(
"Creating RGBD image");
251 ROS_DEBUG_STREAM(
"Instantiating 'new pose' ");
253 ROS_DEBUG_STREAM(
"Fitting supporting entity");
258 ROS_DEBUG_STREAM(
"Fit result: " << fit_result <<
259 "\nExpected pose: " << new_pose <<
260 "\nComputed pose: " << fitted_pose
273 for (
double x = -0.5; x <= 0.5; x += 0.1)
275 for (
double y = -0.5; y <= 0.5; y += 0.1)
277 for (
double yaw_deg = -40.0; yaw_deg <= 40.0; yaw_deg += 10.0)
294 std::string path = ros::package::getPath(
"ed_sensor_integration");
295 path +=
"/test/test_model.sdf";
321 if (pos_diff.
length() > 0.001)
323 ROS_DEBUG_STREAM(
"Pose of the table in the original WM: " << table_entity->pose());
331 ROS_DEBUG_STREAM(
"\nRender result: " << result <<
"\n");
335 cv::namedWindow(
"Colored image", 1);
336 cv::imshow(
"Colored image",
image);
339 cv::namedWindow(
"Depth image", 1);
343 cv::destroyAllWindows();
353 ROS_DEBUG_STREAM(
"Fitting: Processing sensor data");
356 ROS_DEBUG_STREAM(
"Fitting: getting entity");
360 ROS_DEBUG_STREAM(
"Fitting: estimating entity pose");
376 uint nr_succeeded_poses = succeeded_poses.
size();
377 uint nr_failed_poses = failed_poses.
size();
378 uint nr_poses_total = nr_succeeded_poses + nr_failed_poses;
379 ROS_INFO_STREAM(
"Tested " << nr_poses_total <<
" table poses, succeeded: "
380 << nr_succeeded_poses <<
", failed: " << failed_poses.
size());
381 for (
auto& failed_pose: failed_poses)
383 ROS_DEBUG_STREAM(
"\n" << failed_pose);
392 ROS_INFO_STREAM(
"Starting testsuite");
407 int main(
int argc,
char **argv)
409 testing::InitGoogleTest(&argc, argv);
417 return RUN_ALL_TESTS();