一、安裝驅動
下載地址: 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 更改程序當中所有的引用即可
