-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode_notes.txt
More file actions
86 lines (86 loc) · 6.27 KB
/
code_notes.txt
File metadata and controls
86 lines (86 loc) · 6.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
1. imread等读写函数在使用时读取的是相对于源文件的路径,不是相对于可执行文件的路径
2. 链接错误:
In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:222: undefined referenc
解决1:
find_package(Boost REQUIRED COMPONENTS system)
target_link_libraries(.. ${Boost_SYSTEM_LIBRARY})
解决2:
写错了链接库名 ${PCL_LIBS}->${PCL_LIBRARIES}
3. 深度图的数据类型为无符号短整型ushort,使用的时候应先强制为double,否则无符号与有符号都转为无符号再运算
4. 编译错误:
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr
error: specializing member ‘pcl::PointCloud<pcl::PointXYZRGBA>::Ptr’ requires ‘template<>’ syntax
解决:
是上文的 struct, class等没有加 ; 导致下一语句错误!!!
5. QtCreator在ubuntu下配置:
1)~/.local/share/applications/qt -----> Exec=bash -i -c /home....
2)Qt/Tools/share/qt/generic-highlight ------> cp xml.xml launch.xml, color="#g00"
/usr/share/kde4/katepart/syntax/
6. linux下用sstream将int转string
#include <sstream>
stringstream ss;
string s;
ss << "rgb" << i++ << ".png";
ss >> s;
7. Qtcreator有时不能弹出补全
8. 有时Qtcreator的make不能编译或者链接通过,而终端make可以编译链接通过
在QtCreator编辑包含头文件的时候,未防止多个源而选择错误,可以在ide中确认头文件路径
/usr/local/lib/libg2o_types_slam3d.so: undefined reference to `g2o::opengl::drawPoint(float)'`
cmake可以编译链接通过,qt不行
9. boost::bind(&fun)函数的参数在ros下一般需要是常量指针才行
10. cmake error: Could not open file for write in copy operation.
没有权限,可能是安装的时候是sudo。 可以sudo chown -R username ./
11. 有时候qtcreator不能有效解析ws文件;同时,在qtcreator跳转时注意跳转到哪个ws下的文件了
12. const指针或变量不可更改:error: passing ‘const _stamp_type {aka const ros::Time}’ as ‘this’ argument of ‘ros::Time& ros::Time::operator=(const ros::Time&)’ discards qualifiers [-fpermissive]
goal->target_pose.target_pose.header.stamp = ros::Time::now();
13. rviz有时不能加载一些可视基类,有可能是由于~/.rviz的配置文件需要删除。
14. rviz,rqt等一些gui可能存在配置文件,即使卸载也还在,发生问题需要考虑一下这些配置文件。
15. tf2有对各种库的支持,方便的各种转换(kdl,eigen,bullet,geometry_msgs)
tf2独立于ros,因此有tf2_ros.h
16. 参数服务器是跟随core的,注意其是否更新
17. 多个工作空间存在相互依赖和包同名的时候要小心source,不妨把无关build devel 删除,防止出现rospack profile依然存在的莫名问题
否则有包编译不产生对应文件各种麻烦问题。
18. 注意有时候需要删除build devel source
19. 一般情况下一个节点的所有回调共用一个线程,所以某个回调阻塞其他回调不能进入。
20. make:no rule to make target,可能是因为build中的CMakeCache文件未删除
21. boost::bind call error, no match.除保证bind语法正确,同时确保回调函数传参正确。
as_(nh_, "turn_body", boost::bind(&myClass::executeCb, this, _1), false)
void executeCb(const common::TurnBodyDegreeGoalConstPtr &goal);
22. cv::Mat mat; 既可以在定义时构造,也可以通过creat(row,col)来改造。像素的遍历三种方法:
1. uchar *data mat.ptr<uchar>(row);
data[j] = ...通过获取行首指针遍历像素
2. mat.at<uchar>(i, j) = tmp, 通过at操作
3. 迭代起
注意,成员变量data是整个方矩阵的起始地址,不可以通过它遍历,因为不是线性存储
23. imshow("window_name", mat)后一般要要waitKey(1000)
24. 段错误,注意是否是用[]出现了越界
25. 初始化列表出错,cmake错误信息出现在初始化列表最后一列,需要注意
26. md5sum 注意是否是消息类型,服务类型,action类型名字是否正确
27. mat.at<uchar>(x, y) and mat.at<uchar>(Point(x,y))不同
28. cols, rows,行列分清,xy分清!!高是rows, 宽是cols
29. invalid initialization of non-const reference of type '' from an rvalue of type ''
意思是不能将一个引用临时变量,除非设定为const 引用
如void f(int &a); f(a+b)错误,如果你把临时变量作为非const引用参数传递,一方面,在函数申明中,
使用非常量型的引用告诉编译器你需要得到函数对某个对象的修改结果可是你自己又不给变量起名字,
直接丢弃了函数的修改结果,编译器只能说:“大哥,你这是干啥呢,告诉我把结果给你,等我把结果给你了,
你又直接给扔了,你这不是在玩我呢吗?”所以编译器一怒之下就不让过了。这下大家明白了吧
而常量引用因为反正不修改这个临时变量,所以编译器就通过了
一句话,不可以非常量引用临时变量
30. error: passing const 'sss' as 'this' argument of 'ccc' discards qualifiers
编译器有一个安全限定,认为const对象只能调用const函数,丢弃了限定符
31. error:moc: Cannot open options file specified with @...
这是由于含有非英文字符路径造成,即accentuated charactors.
可见,系统确实应该安装英文版,且程序目录最好不出现中文。
32. 运行错误:shared_ptr:Assertion 'px != 0' failed.
指针定义了但是没有初始化,没有new对象给它。
33. 返回一个点云指针(boost::shared_ptr),返回共享指针和返回共享指针的引用有什么区别?
返回共享指针就不用返回引用了。
34. roslaunch 不能启动,如果是个脚本,是否缺失#?
删除build,重新编译安装
35. boost::format format("/homa/mantou/%s/%d.png");
imread((format%"rgb"%(i+1)).str());
36. std::max(a, 10)编译不通过,因为a是double
37. string打印出来是??????要考虑可能不是英文字符,增加处理。
38. 函数原型是传入引用,因此f(a*b)编译错误,因为计算的中间临时对象在传给形参引用时已经消忙
39. 出现链接错误,有可能是编译可执行文件相关的源文件没有包含进去