一、安装驱动
下载地址: https://www.kvaser.cn/developer-blog/build-install-signed-kvaser-driver-modules/
严格按照操作手册说明进行:
位置: linuxcan/README 以及 linuxcan/doc/faq
验证是否成功:
Make sure the modules are loaded. The following command should print
kvcommon and at least one more module:
~/collectprogram/collectws$ lsmod | grep 'kvcommon\|mhydra\|leaf\|usbcanII\|kvpciefd\|kvpcican\|kvpcicanII\|kvvirutalcan'
leaf 26990 1
kvcommon 58711 1 leaf
验证多少路CAN: 30881 是can id.
:~/collectprogram/collectws$ /usr/doc/canlib/examples/listChannels
CANlib version 5.23
Found 1 channel(s).
ch 0: Kvaser Leaf Light v2 73-30130-00685-0, s/n 30881, v3.3.0.769 (leaf v8.23.482)
注意:kvaser leaf light v2 只有一路CAN.
二、如何在ros当中编写驱动程序
参考资料:https://github.com/astuff/kvaser_interface
1、can_msgs 自己定义,然后生成.h文件引入到程序当中
Header header
int64 id
int16 dlc
bool is_extended
uint8[8] data
2、通过程序当中的 ./install_minimal_linuxcan.sh 生成 .so文件
或者通过上面的linuxcan生成 .so文件。
但是呢,我们需要把下面的几个文件同时拷贝进来:
libcanlib.so libcanlib.so.1 libcanlib.so.1.5.0
不然会报错,未查找的引用。
3、利用自定义的can_msgs 更改程序当中所有的引用即可