Monday, October 20, 2014

RGBDSLAM quick sources

Assembler messages: Error: no such instruction: `vfmadd312ss (%r15),%xmm0,%xmm1'

I got the following errors while building RGBDSLAMv2 in ROS in my ubuntu 12.04 system. 

[ 62%] Building CXX object rgbdslam_v2-hydro/CMakeFiles/rgbdslam.dir/src/qt_gui.o
[ 64%] Building CXX object rgbdslam_v2-hydro/CMakeFiles/rgbdslam.dir/src/node.o
[ 66%] Building CXX object rgbdslam_v2-hydro/CMakeFiles/rgbdslam.dir/src/glviewer.o
/tmp/ccgvJzxG.s: Assembler messages:
/tmp/ccgvJzxG.s:11194: Error: no such instruction: `vfmadd312ss (%r15),%xmm0,%xmm1'
/tmp/ccgvJzxG.s:12560: Error: no such instruction: `vfmadd312ss (%r15),%xmm0,%xmm1'
make[2]: *** [rgbdslam_v2-hydro/CMakeFiles/rgbdslam.dir/src/moc_graph_manager.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/tmp/cct3JxmG.s: Assembler messages:
/tmp/cct3JxmG.s:10798: Error: no such instruction: `vfmadd312ss (%r15),%xmm0,%xmm1'
/tmp/cct3JxmG.s:12164: Error: no such instruction: `vfmadd312ss (%r15),%xmm0,%xmm1'
make[2]: *** [rgbdslam_v2-hydro/CMakeFiles/rgbdslam.dir/src/moc_openni_listener.o] Error 1
Linking CXX executable /home/swagatika/catkin_ws/devel/lib/my_pcl_tutorial/example
[ 66%] Built target example
/tmp/ccELf8iw.s: Assembler messages:
/tmp/ccELf8iw.s:16630: Error: no such instruction: `vfmadd312ss 88(%rsp),%xmm1,%xmm2'
/tmp/ccELf8iw.s:16640: Error: no such instruction: `vfmadd312ss 96(%rsp),%xmm3,%xmm1'
/tmp/ccELf8iw.s:16641: Error: no such instruction: `vfmadd312ss 100(%rsp),%xmm3,%xmm0'
make[2]: *** [rgbdslam_v2-hydro/CMakeFiles/rgbdslam.dir/src/glviewer.o] Error 1
/tmp/ccslUlsc.s: Assembler messages:
/tmp/ccslUlsc.s:15733: Error: no such instruction: `vfmadd312ss (%r15),%xmm0,%xmm1'
/tmp/ccslUlsc.s:17099: Error: no such instruction: `vfmadd312ss (%r15),%xmm0,%xmm1'
make[2]: *** [rgbdslam_v2-hydro/CMakeFiles/rgbdslam.dir/src/main.o] Error 1
/tmp/ccAmx5la.s: Assembler messages:
/tmp/ccAmx5la.s:439309: Error: no such instruction: `vfmadd312ss (%r15),%xmm0,%xmm1'
/tmp/ccAmx5la.s:440675: Error: no such instruction: `vfmadd312ss (%r15),%xmm0,%xmm1'
make[2]: *** [rgbdslam_v2-hydro/CMakeFiles/rgbdslam.dir/src/openni_listener.o] Error 1
make[1]: *** [rgbdslam_v2-hydro/CMakeFiles/rgbdslam.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed



$ gcc -march=native -Q --help=target | grep march
  -march=                             corei7-avx

Solution:

In /home/swagatika/catkin_ws/src/rgbdslam_v2-hydro/CMakeLists.txt,

You can add -march=native -mno-avx This worked for me.
In my CMakeLists.txt, I added the above to the CMAKE_CXX_FLAGS :
SET(CMAKE_CXX_FLAGS "-ggdb -O3 -fPIC -std=c++0x -march=native -mno-avx")
 
Ref:

http://stackoverflow.com/questions/17126593/compile-errors-with-assembler-messages

http://stackoverflow.com/questions/10327939/erroring-on-no-such-instruction-while-assembling-project-on-mac-os-x-lion

Tuesday, October 7, 2014

Grab Pointclouds and save as pcd files using ROS and Openni

1) Install ROS Hydro Openni2 packages:

$sudo apt-get install ros-hydro-openni2-camera ros-hydro-openni2-launch

2) Run ROS

$roscore

3) Launch openni

$roslaunch openni2_launch openni2.launch

4) Launch RViz

$rosrun rviz rviz

5) Do settings in RViz to receive data from Kinect

6) Back in terminal, use the following command to save the point clouds


$rosrun pcl_ros pointcloud_to_pcd input:=<your target topic name>
 
For ex:
$ rosrun pcl_ros pointcloud_to_pcd input:=/camera/depth_registered/points
The output is :

[ INFO] [1412698428.630599815]: Listening for incoming data on topic /camera/depth_registered/points
[ INFO] [1412698428.870419685]: Received 307200 data points in frame /camera_rgb_optical_frame with the following fields: x y z rgb
[ INFO] [1412698428.870483694]: Data saved to 1412698428747359.pcd
[ INFO] [1412698429.421970793]: Received 307200 data points in frame /camera_rgb_optical_frame with the following fields: x y z rgb
[ INFO] [1412698429.422065179]: Data saved to 1412698429281241.pcd
[ INFO] [1412698429.979569838]: Received 307200 data points in frame /camera_rgb_optical_frame with the following fields: x y z rgb
[ INFO] [1412698429.979637397]: Data saved to 1412698429848510.pcd
[ INFO] [1412698430.495591052]: Received 307200 data points in frame /camera_rgb_optical_frame with the following fields: x y z rgb
[ INFO] [1412698430.495632948]: Data saved to 1412698430415787.pcd
[ INFO] [1412698430.974854796]: Received 307200 data points in frame /camera_rgb_optical_frame with the following fields: x y z rgb
[ INFO] [1412698430.974940083]: Data saved to 1412698430882933.pcd
 
(Ref: http://answers.ros.org/question/47345/kinect-point-cloud-to-pcd-files/ )
This will keep dumping the pointcloud files until you stop the process (ctrl + c).


Quick PCL commands to capture data using Kinect

$ pcl_openni_viewer
 press 'r' to visualize the point cloud. Pointcloud appears inverted manner. have to use mouse to see in correct orientation.

you can see 2 windows (PCL OpenNI cloud, PCL OpenNI Image)

$ pcl_openni_save_image  (saves depth and RGB image in .tiff format... You have to stop it if you want to save only 1 frame.)


View the depth image in octave:

$octave
octave:1> imshow('1_1_depth.tiff' , [])

$ pcl_openni_grabber_example
Warning: USB events thread - failed to set priority. This might cause loss of data...
<Esc>, 'q', 'Q': quit the program
' ': pause
's': save


$ pcl_viewer pcd_file.pcd
(press r to view, 5 to see color)

Friday, September 26, 2014

PCL: pointcloud transformation




// transform the model by the transformation value
  Eigen::Matrix4f txform;
 

 //get the txformation matrix (discussed below)
 
 pcl::transformPointCloud (*cloud_3dmodel, *txformed_model, txform );


ICP can be used to estimate the transform :

Eigen::Matrix4f txform;

 pcl::IterativeClosestPoint<pcl::PointXYZRGB, pcl::PointXYZRGB> icp;
 icp.setInputCloud(cloud_3dmodel);
 icp.setInputTarget(cloud_cluster);
 pcl::PointCloud<pcl::PointXYZRGB> Final;
 icp.align(Final);
 std::cout << "ICP has converged:" << icp.hasConverged() << " score: " <<    icp.getFitnessScore() << std::endl;

txform = icp.getFinalTransformation();

Refer:
http://stc0.wordpress.com/2013/03/22/equivalent-ways-to-register-two-point-clouds-with-pcl/
http://pointclouds.org/documentation/tutorials/iterative_closest_point.php

Eigen: block access to matrices

  
 Eigen library: matrix block operation: 

 http://eigen.tuxfamily.org/dox-devel/group__TutorialBlockOperations.html


 //Code snippet to define a 4x4 transformation matrix:


  Eigen::Matrix4f txform;

  .........

  // Get Rotation Matrix and translation vector: T = [R | t]
  Eigen::Matrix3f rotation = txform.block<3,3>(0, 0);
  Eigen::Vector3f translation = txform.block<3,1>(0, 3);
 

  //Print he individual values
    printf ("\n");
    printf ("            | %6.3f %6.3f %6.3f | \n", rotation (0,0), rotation (0,1), rotation (0,2));
    printf ("        R = | %6.3f %6.3f %6.3f | \n", rotation (1,0), rotation (1,1), rotation (1,2));
    printf ("            | %6.3f %6.3f %6.3f | \n", rotation (2,0), rotation (2,1), rotation (2,2));
    printf ("\n");
    printf ("        t = < %0.3f, %0.3f, %0.3f >\n", translation (0), translation (1), translation (2));