MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / simulate_callback

Function simulate_callback

simulation/tools/sim_viewer.cpp:328–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326}
327
328void
329simulate_callback(const pcl::visualization::KeyboardEvent& event, void* viewer_void)
330{
331 pcl::visualization::PCLVisualizer::Ptr viewer =
332 *static_cast<pcl::visualization::PCLVisualizer::Ptr*>(viewer_void);
333 // I choose v for virtual as s for simulate is takwen
334 if (event.getKeySym() == "v" && event.keyDown()) {
335 std::cout << "v was pressed => simulate cloud" << std::endl;
336
337 std::vector<pcl::visualization::Camera> cams;
338 viewer->getCameras(cams);
339
340 if (cams.size() != 1) {
341 std::cout << "n cams not 1 exiting\n"; // for now in case ...
342 return;
343 }
344 // std::cout << "n cams: " << cams.size() << "\n";
345 pcl::visualization::Camera cam = cams[0];
346
347 Eigen::Affine3f pose;
348 pose = viewer->getViewerPose();
349
350 std::cout << cam.pos[0] << " " << cam.pos[1] << " " << cam.pos[2] << " p\n";
351
352 Eigen::Matrix3f m;
353 m = pose.rotation();
354 // All axies use right hand rule. x=red axis, y=green axis, z=blue axis z direction
355 // is point into the screen. z \ \ \ -----------> x | | | | | | y
356
357 std::cout << pose(0, 0) << " " << pose(0, 1) << " " << pose(0, 2) << " "
358 << pose(0, 3) << " x0\n";
359 std::cout << pose(1, 0) << " " << pose(1, 1) << " " << pose(1, 2) << " "
360 << pose(1, 3) << " x1\n";
361 std::cout << pose(2, 0) << " " << pose(2, 1) << " " << pose(2, 2) << " "
362 << pose(2, 3) << "x2\n";
363
364 double yaw, pitch, roll;
365 wRo_to_euler(m, yaw, pitch, roll);
366
367 printf("RPY: %f %f %f\n", roll * 180 / M_PI, pitch * 180 / M_PI, yaw * 180 / M_PI);
368
369 // matrix->GetElement(1,0);
370
371 std::cout << m(0, 0) << " " << m(0, 1) << " " << m(0, 2) << " "
372 << " x0\n";
373 std::cout << m(1, 0) << " " << m(1, 1) << " " << m(1, 2) << " "
374 << " x1\n";
375 std::cout << m(2, 0) << " " << m(2, 1) << " " << m(2, 2) << " "
376 << "x2\n\n";
377
378 Eigen::Quaternionf rf;
379 rf = Eigen::Quaternionf(m);
380
381 Eigen::Quaterniond r(rf.w(), rf.x(), rf.y(), rf.z());
382
383 Eigen::Isometry3d init_pose;
384 init_pose.setIdentity();
385 init_pose.translation() << cam.pos[0], cam.pos[1], cam.pos[2];

Callers

nothing calls this directly

Calls 11

wRo_to_eulerFunction · 0.85
print_Isometry3dFunction · 0.85
getTimeFunction · 0.85
keyDownMethod · 0.80
getViewerPoseMethod · 0.80
strMethod · 0.80
addCoordinateSystemMethod · 0.80
captureFunction · 0.70
getCamerasMethod · 0.45
sizeMethod · 0.45
xMethod · 0.45

Tested by

no test coverage detected