Thursday 30 June 2016

Python permission error

I am following the Head First Python, which is a great book, to develop a webapp, and then encounter some permission error of the .py file. 

Based on this, it turns out that I should use #!/usr/bin/python instead of #!/usr/bin/python3.

Monday 13 June 2016

Latex figure position

Normally I use \begin{figure}[thpb] to include figures in Latex. However, sometimes this results in a lot of space between figures. According to here, we can use \begin{figure}[h!] to place the figures in a compact manner, so that all of them fit tightly with text.

Sunday 12 June 2016

windows转ubuntu遇到的问题

GCC

遇到了很多_m256d does not name a type之类的,好像是immintrin.h没有link好。把gcc从4.8升级到4.9解决了这个问题

Ceres

安装的时候如果遇到

Eigen compilation error: error: partial specialization of ‘std::vector<T, Eigen::aligned_allocator<U> >
就按照这里说的把internal/numeric_diff.h里面的#include <Eigen/StdVector>去掉,然后从新build。注意build好了之后是跟新usr/local/include里面的ceres

VTK

cc1plus: warning: /usr/local/lib/cmake/vtk-7.0/UseVTK.cmake: not a directory。之后会显示fatal error: vtk/vtkSmartPointer.h: No such file or directory。

我先试着把include(${VTK_USE_FILE})改成include_directories(${VTK_INCLUDES})这时候虽然不会显示warning了,但还是显示fatal error: vtk/vtkSmartPointer.h: No such file or directory

后来我发现在usr/local/include里面安装的文件夹叫vtk-7.1,需要把它改名字ie sudo rm vtk-7.1 vtk就ok了。

还有undefined reference to vtkRenderingOpenGL_AutoInit_Construct,在target_link_libraries里面加入/usr/local/lib/libvtkRenderingOpenGL-6.1.so搞定

cc1plus: warning: /usr/local/lib/cmake/vtk-7.0/UseVTK.cmake: not a directory还有一种解决办法就是include(${VTK_USE_FILE}),不写include_directories(${VTK_INCLUDES})

vtk初始化的时候用smart pointer和New()会爆出segmentation fault的error, 需要在target_link_libraries里面加入/usr/local/lib/libvtkRenderingOpenGL2-7.1.so
/usr/local/lib/libvtkInteractionStyle-7.1.so,注意这里的版本是7.1,相应的要写VTK_MODULE_INIT(vtkRenderingOpenGL2);而不是VTK_MODULE_INIT(vtkRenderingOpenGL);

liblapack

gcc 4.9提示liblapack.so: undefined reference to `ATL_dgemoveT',根据这里,sudo apt-get remove libopenblas-base解决了问题

build速度慢

lib里面没有用的东西都删掉可以让cmake变快,如果一个package安装在了usr/local/include里面,那么lib里面的build文件夹就没用了。此外build好之后原来的source文件夹也可以删掉。

OpenCV

undefined imread等等问题,直接link到so文件上,比如在target_link_libraries之中加入${OpenCV_LIBS}/libopencv_core.so.3.1

_ZN2cv8cvtColorERKNS_11_InputArrayERKNS_12_OutputArrayEii undefined
加入#include "opencv2/imgproc.hpp"和${OpenCV_LIBS}/libopencv_imgproc.so.3.1

targets may link only to libraries. cmake is dropping the item
不用
#set(OpenCV_INCLUDE_DIRS "/home/nusuav/ms_workspace/opencv/build/include")
#set(OpenCV_LIBS "/home/nusuav/ms_workspace/opencv/build/lib")
而是用
SET("OpenCV_DIR" "/home/nusuav/ms_workspace/opencv/build/")
find_package( OpenCV )
不过虽然没有了warning,但是编译的时候报错找不到libopencv_core.so.3.1

LCM

包含lcm/lcm-cpp.hpp的时候提示找不到lcm_create,安装好lcm后需要在target_link_libraries里面加入/usr/local/lib/liblcm.so

Boost

运行的时候提示error loading libboost_system.so.1.59.0,根据这里,需要export LD_LIBRARY_PATH=/path/to/my/library,再rosrun

我用boost 1.55的时候显示has no member named ‘serialize’,据说要加入#include <boost/serialization/utility.hpp>,不过后来还是出现error,用boost 1.59就没有这个问题

boost load的archive ibinary会提示
terminate called after throwing an instance of 'boost::archive::archive_exception'
what(): incompatible native format - size of long
去掉error的方法是std::make_shared<boost::archive::binary_iarchive>(filename, 1),而不是std::make_shared<boost::archive::binary_iarchive>(filename),括号里面的1表示使用unsigned int

ROS

error loading librospack.so,根据这里,需要source /opt/ros/indigo/setup.bash

[rospack] Warning: error while crawling...Permission denied when I try to tab-complete your package name,根据这里这里,似乎应该
#umount /home/useraccount/.gvfs
#rm -rf .gvfs/
不过我试过之后没有效果,重新启动之后才好了。

visual studio

在用VS build的时候,出现了code analysis的错误,发现并没有enable code anlaysis。改了code analysis中的一些东西之后发现不能保存。后来用administrator模式开启VS才解决了这个问题。

cout is not a member of std
根据这里,加入#include <iostream>

localtime_s or localtime_r
在windows里面用的localtime_s,在ubuntu中并没有定义,根据这里,可以换成localtime_r,注意input的两个参数位置对调

timestamp问题

每次显示timesstamp都是1970年的,实际应该是2016年。
这个问题debug了好久,最后终于找到问题了。load时候存储epoch的t少了两位数,用t *= 100就得到正常的值了。这是因为在从windows转换到linux的时候,std::chrono_system_clock 分别用的100-nanoseconds和nanoseconds。

检查epoch的值到底应该是多少,可以参考转换时间的网站。

ros node运行慢的问题

cmake生成的是debug模式,可以用release模式catkin_make CMAKE_BUILD_TYPE=RelWithDebInfo

编译的时候生成
init done
opengl support available
根据这里,这是一个opencv的bug,貌似没什么卵用,不用管它。

无法roslaunch
roslaunch的时候遇到process died,用sudo chmod a+wrx /dev/ttyACM0

No module named catkin_pkg.packages
Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.
用pip install catkin_pkg,问题原因可能是有不同版本的Python