RMonica / ros_kinfu

30 stars 18 forks source link

compile ros_kinfu #9

Open QinZiwen opened 7 years ago

QinZiwen commented 7 years ago

I find that there has /pcl/gpu/kinfu_large_scale in pcl repository (https://github.com/PointCloudLibrary/pcl/tree/master/gpu/kinfu_large_scale). I don't known whether compile pcl repository before ros_kinfu. Using ccmake can turn on or turn off kinfu_large_scale in pcl.

But if turning off kinfu_large_scale, compiling nice, there will show some errors when type "roslaunch kinfu kinfu2.launch", as follow:

Error: invalid device function  /home/turtlebot/catkin_ws_gpu/src/ros_kinfu/kinfu/pcl_kinfu_large_scale/kinfu_large_scale/src/cuda/tsdf_volume.cu:239

When I turn on kinfu_largescale, compiling nice. when running, KinfuTracker has been created using pcl's, but "kinfu->icpIsLost()" function using kinfu's kinfu_large_scale.

help me! Thank you very much!

RMonica commented 7 years ago

Hi QinZiwen.

You do not need to link this package against a custom-compiled PCL. Above all, do not enable the gpu module: it will interfere with this package.

As for your other problem, try adding your GPU compute capability:

diff --git a/kinfu/pcl_kinfu_large_scale/CMakeLists.txt b/kinfu/pcl_kinfu_large_scale/CMakeLists.txt
index 8de20d0..5ec0df3 100644
--- a/kinfu/pcl_kinfu_large_scale/CMakeLists.txt
+++ b/kinfu/pcl_kinfu_large_scale/CMakeLists.txt
@@ -51,7 +51,7 @@ target_link_libraries(KinfuLargeScaleCPP
   ${CUDA_LIBRARIES}
   )

-set(CUDA_NVCC_FLAGS "-D_FORCE_INLINES -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52")
+set(CUDA_NVCC_FLAGS "-D_FORCE_INLINES -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_62,code=sm_62")
 set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "--ftz=true --prec-div=false --prec-sqrt=false")        
 set(CUDA_VERBOSE_BUILD OFF)
 cuda_add_library(KinfuLargeScaleCUDA
QinZiwen commented 7 years ago

Thank you!@RMonica. compiling ros_kinfu is very nice! But when I type "roslaunch kinfu kinfu2.launch", some errors turn up as follow:

kinfu: /usr/local/include/eigen3/Eigen/src/SVD/SVDBase.h:101: const MatrixVType& Eigen::SVDBase<Derived>::matrixV() const [with Derived = Eigen::JacobiSVD<Eigen::Matrix<float, 3, 3>, 2>; Eigen::SVDBase<Derived>::MatrixVType = Eigen::Matrix<float, 3, 3>; typename Eigen::internal::traits<T>::MatrixType::Scalar = float]: Assertion `m_isInitialized && "SVD is not initialized."' failed.

I find errors location in "kinfu_->setInitialCameraPose(pose);"

void
pcl::gpu::kinfuLS::KinfuTracker::setInitialCameraPose (const Eigen::Affine3f& pose)
{
  cout << "initial camera pose = " << endl << pose.matrix() << endl;

  init_Rcam_ = pose.rotation ();
  init_tcam_ = pose.translation ();
  //reset (); // (already called in constructor)
}

I could show "pose.matrix()" , but when show "pose.translation()", a new error appear:

kinfu: /usr/include/eigen3/Eigen/src/Core/util/XprHelper.h:53: Eigen::internal::variable_if_dynamic<T, Value>::variable_if_dynamic(T) [with T = long int; int Value = 4]: Assertion `v == T(Value)' failed.

I don't know how to fix this problem.

RMonica commented 7 years ago

Hi QinZiwen.

I don't know either.

A corrupted Eigen installation, maybe?

QinZiwen commented 7 years ago

I reinstall eigen with version 3.3.3 and clone new code, rename KinfuTrigger.cmake.readme to KinfuTrigger.cmake. Compiling ros_kinfu has no problems, but when I type "roslaunch kinfu kinfu2.launch", there has some errors:

kinfu: /usr/local/include/eigen3/Eigen/src/SVD/SVDBase.h:101: const MatrixVType& Eigen::SVDBase<Derived>::matrixV() const [with Derived = Eigen::JacobiSVD<Eigen::Matrix<float, 3, 3>, 2>; Eigen::SVDBase<Derived>::MatrixVType = Eigen::Matrix<float, 3, 3>; typename Eigen::internal::traits<T>::MatrixType::Scalar = float]: Assertion `m_isInitialized && "SVD is not initialized."' failed.

The full log are as follow:

turtlebot@turtlebot-OMEN-by-HP-Laptop:~/catkin_ws_gpu$ roslaunch kinfu kinfu2.launch 
... logging to /home/turtlebot/.ros/log/40657f64-19ce-11e7-94bd-d0577bf4a92a/roslaunch-turtlebot-OMEN-by-HP-Laptop-12497.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://192.168.1.102:52364/

SUMMARY
========

PARAMETERS
 * /kinect2_bridge/base_name: kinect2
 * /kinect2_bridge/base_name_tf: kinect2
 * /kinect2_bridge/bilateral_filter: True
 * /kinect2_bridge/calib_path: /home/turtlebot/c...
 * /kinect2_bridge/depth_device: -1
 * /kinect2_bridge/depth_method: default
 * /kinect2_bridge/edge_aware_filter: True
 * /kinect2_bridge/fps_limit: -1.0
 * /kinect2_bridge/jpeg_quality: 90
 * /kinect2_bridge/max_depth: 12.0
 * /kinect2_bridge/min_depth: 0.1
 * /kinect2_bridge/png_level: 1
 * /kinect2_bridge/publish_tf: False
 * /kinect2_bridge/queue_size: 5
 * /kinect2_bridge/reg_device: -1
 * /kinect2_bridge/reg_method: default
 * /kinect2_bridge/sensor: 
 * /kinect2_bridge/use_png: False
 * /kinect2_bridge/worker_threads: 4
 * /kinect2_points_xyzrgb_hd/queue_size: 5
 * /kinect2_points_xyzrgb_qhd/queue_size: 5
 * /kinect2_points_xyzrgb_sd/queue_size: 5
 * /kinect_kinfu1/autostart: True
 * /kinect_kinfu1/camera_info_topic: /kinect2/sd/camer...
 * /kinect_kinfu1/depth_height: 424
 * /kinect_kinfu1/depth_image_topic: /kinect2/sd/image...
 * /kinect_kinfu1/depth_width: 512
 * /kinect_kinfu1/extract_known_points: False
 * /kinect_kinfu1/prefix_topic: /kinect2
 * /kinect_kinfu1/request_topic: /kinfu_request_topic
 * /kinect_kinfu1/response_topic: /kinfu_response_t...
 * /rosdistro: indigo
 * /rosversion: 1.11.21

NODES
  /
    kinect2 (nodelet/nodelet)
    kinect2_bridge (nodelet/nodelet)
    kinect2_points_xyzrgb_hd (nodelet/nodelet)
    kinect2_points_xyzrgb_qhd (nodelet/nodelet)
    kinect2_points_xyzrgb_sd (nodelet/nodelet)
    kinect_kinfu1 (kinfu/kinfu)

auto-starting new master
process[master]: started with pid [12509]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 40657f64-19ce-11e7-94bd-d0577bf4a92a
process[rosout-1]: started with pid [12522]
started core service [/rosout]
process[kinect2-2]: started with pid [12535]
process[kinect2_bridge-3]: started with pid [12540]
process[kinect2_points_xyzrgb_sd-4]: started with pid [12541]
process[kinect2_points_xyzrgb_qhd-5]: started with pid [12542]
[ INFO] [1491375929.752636168]: Loading nodelet /kinect2_bridge of type kinect2_bridge/kinect2_bridge_nodelet to manager kinect2 with the following remappings:
process[kinect2_points_xyzrgb_hd-6]: started with pid [12552]
[ INFO] [1491375929.755505382]: waitForService: Service [/kinect2/load_nodelet] has not been advertised, waiting...
process[kinect_kinfu1-7]: started with pid [12569]
[ INFO] [1491375929.781807179]: Initializing nodelet with 8 worker threads.
[ INFO] [1491375929.797251963]: waitForService: Service [/kinect2/load_nodelet] is now available.
[ INFO] [1491375929.877471385]: [Kinect2Bridge::initialize] parameter:
        base_name: kinect2
           sensor: default
        fps_limit: -1
       calib_path: /home/turtlebot/catkin_ws/src/iai_kinect2/kinect2_bridge/data/
          use_png: false
     jpeg_quality: 90
        png_level: 1
     depth_method: default
     depth_device: -1
       reg_method: default
       reg_device: -1
        max_depth: 12
        min_depth: 0.1
       queue_size: 5
 bilateral_filter: true
edge_aware_filter: true
       publish_tf: false
     base_name_tf: kinect2
   worker_threads: 4
[pcl::gpu::printShortCudaDeviceInfo] : Device 0:  "GeForce GTX 1070"  8105Mb, sm_61, 2048 cores, Driver/Runtime ver.8.0/8.0
[Info] [CudaDepthPacketProcessorImpl] device 0: GeForce GTX 1070 @ 1645MHz Memory 8105MB
[Info] [CudaDepthPacketProcessorImpl] selected device 0
[ INFO] [1491375929.989955351]: Running KinFu without texture extraction
[Info] [Freenect2Impl] enumerating devices...
[Info] [Freenect2Impl] 8 usb devices connected
[Info] [Freenect2Impl] found valid Kinect v2 @2:7 with serial 021468743547
[Info] [Freenect2Impl] found 1 devices
[ INFO] [1491375930.106671253]: [Kinect2Bridge::initDevice] Kinect2 devices found: 
[ INFO] [1491375930.106721251]: [Kinect2Bridge::initDevice]   0: 021468743547 (selected)
[Info] [Freenect2DeviceImpl] opening...
[Info] [Freenect2DeviceImpl] transfer pool sizes rgb: 20*16384 ir: 60*8*33792
[Info] [Freenect2DeviceImpl] opened
[ INFO] [1491375930.204922091]: [Kinect2Bridge::initDevice] starting kinect2
[Info] [Freenect2DeviceImpl] starting...
[ INFO] [1491375930.319792455]: kinfu_output: main thread started.
[ INFO] [1491375930.326079874]: --- CURRENT SETTINGS ---

[ INFO] [1491375930.326131654]: Volume size is set to 3.00 meters

[ INFO] [1491375930.326157230]: Volume will shift when the camera target point is farther than 1.50 meters from the volume center

[ INFO] [1491375930.326182437]: The target point is located at [0, 0, 1.80] in camera coordinates

[ INFO] [1491375930.326219110]: ------------------------

in reset function!
kinfu: /usr/local/include/eigen3/Eigen/src/SVD/SVDBase.h:101: const MatrixVType& Eigen::SVDBase<Derived>::matrixV() const [with Derived = Eigen::JacobiSVD<Eigen::Matrix<float, 3, 3>, 2>; Eigen::SVDBase<Derived>::MatrixVType = Eigen::Matrix<float, 3, 3>; typename Eigen::internal::traits<T>::MatrixType::Scalar = float]: Assertion `m_isInitialized && "SVD is not initialized."' failed.
[Info] [Freenect2DeviceImpl] submitting rgb transfers...
[Info] [Freenect2DeviceImpl] submitting depth transfers...
[Info] [Freenect2DeviceImpl] started
[ INFO] [1491375930.552732686]: [Kinect2Bridge::initDevice] device serial: 021468743547
[ INFO] [1491375930.552791436]: [Kinect2Bridge::initDevice] device firmware: 4.0.3911.0
[Info] [Freenect2DeviceImpl] stopping...
[Info] [Freenect2DeviceImpl] canceling rgb transfers...
[kinect_kinfu1-7] process has died [pid 12569, exit code -6, cmd /home/turtlebot/catkin_ws_gpu/devel/lib/kinfu/kinfu __name:=kinect_kinfu1 __log:=/home/turtlebot/.ros/log/40657f64-19ce-11e7-94bd-d0577bf4a92a/kinect_kinfu1-7.log].
log file: /home/turtlebot/.ros/log/40657f64-19ce-11e7-94bd-d0577bf4a92a/kinect_kinfu1-7*.log
[Info] [Freenect2DeviceImpl] canceling depth transfers...
[Info] [Freenect2DeviceImpl] stopped
[ INFO] [1491375930.846257704]: [DepthRegistration::New] Using CPU registration method!
[ INFO] [1491375930.846408499]: [DepthRegistration::New] Using CPU registration method!
[ INFO] [1491375930.918682145]: [Kinect2Bridge::main] waiting for clients to connect
QinZiwen commented 7 years ago

I download new eigen(version 3.3.3), unpacking tar.bz2, typing "mkdir build; cd build; cmake ..; make check", but 4 test failed, which include svd error:

99% tests passed, 4 tests failed out of 787

Label Time Summary:
Official       = 273.43 sec
Unsupported    =  68.84 sec

Total Test time (real) = 434.77 sec

The following tests FAILED:
    479 - bdcsvd_9 (OTHER_FAULT)
    731 - sparse_extra_3 (OTHER_FAULT)
    732 - openglsupport (OTHER_FAULT)
    781 - cxx11_tensor_io (SEGFAULT)
Errors while running CTest
make[3]: *** [CMakeFiles/check] Error 8
make[2]: *** [CMakeFiles/check.dir/all] Error 2
make[1]: *** [CMakeFiles/check.dir/rule] Error 2
make: *** [check] Error 2
RMonica commented 7 years ago

I don't think bdcsvd_9 is related to your issue. The rotation() method should use standard JacobiSVD.

Try isolated compilation (catkin build) if you aren't already doing so.

Try replacing find_package(Eigen REQUIRED) in CMakeLists.txt with find_package(Eigen3 REQUIRED), as suggested by the cmake warning. You also need to replace all the ${Eigen_*} with ${Eigen3_*}.

What Ubuntu version and ROS version are you using?

QinZiwen commented 7 years ago

I try to use " find_package(Eigen3 REQUIRED) " and nothing to change. I use ros-indigo @RMonica