astuff / kvaser_interface

A Kvaser CAN interface ROS abstraction layer.
MIT License
84 stars 52 forks source link

How to get started with the Kvaser CAN interface? #86

Closed bonjiman closed 2 years ago

bonjiman commented 2 years ago

Hi,

I'm a master's student on a collegiate student design team, and we're using the Kvaser Leaf Light v2 to connect our CPU to the CAN network. We've had trouble using the generic SocketCAN implementation, so we decided to try a Kvaser-specific solution.

I've followed the README on the main page of the repo, but still we aren't able to get the ROS node to connect to the Kvaser unit. I can see the Leaf module when I run the lsusb tool in the terminal: Bus 001 Device 011: ID 0bfd:0120 Kvaser AB Kvaser Leaf Light v2

However, using the list_channels tool, it returns No channels found.

Is there any additional setup that needs to be performed before running these tools? Is it like SocketCAN where we have to set up the IP link to the device? Or is it really supposed to be plug-and-play?

Any guidance would be greatly appreciated. Thanks so much!

icolwell-as commented 2 years ago

Hi @bonjiman, your kvaser hardware should most definitely be supported, so maybe it's some small detail that got missed.

First things first, what version of Ubuntu and ROS are you running?

Also, you mentioned you followed the README, but I just want to double-check: You installed sudo apt install kvaser-canlib-dev kvaser-drivers-dkms right? You may need to reboot after installing kvaser-drivers-dkms since the kernel needs to load the drivers. I can't remember if they auto-load or not, so a reboot may help.

bonjiman commented 2 years ago

Sorry for the late reply! We are running on Ubuntu 20.04 LTS, and we're using ROS Noetic. I double-checked myself and ran the command you suggested, and the all the files have already been installed onto our machine. The machine has been rebooted since originally installing the files, and the ROS list_channels tool is still returning a No channels found result after the Kvaser unit has been plugged into the USB port. Again, I ran lsusb and received confirmation that the OS "sees" the Kvaser unit.

We happen to have 4 different Leaf Light v2's from a previous project (we only need 1 for this project), and I tried plugging all 4 of them into the USB ports of our PC. One of them is also connected to a powered and terminated CAN bus. Each Leaf has 2 lights (PWR and CAN), and each of them has only the PWR lights illuminated. I don't know if the CAN light should be on or not.

I tried rebooting the computer, working all the way through the README again, and rebooting the computer again. Running lsusb, I see all 4 of the Leafs. When I rosrun kvaser_interface list_channels, I still see No channels found..

What can we try next?

In the event that we cannot get the Kvaser driver to work, and we decide to continue pursuing the SocketCAN solution, how do we uninstall the Kvaser SDK? I've been reading about this online, and it appears that the Kvaser SDK basically blacklists SocketCAN from being able to access the Kvaser hardware. I'd like to be able to avoid re-flashing our SDD if possible.

Edit #1: We used the Kvaser Firmware update tool to try uploading the latest edition of the firmware to the Kvaser unit, and we still see the same results. The original firmware version was V4.6.607 (16-SEP-2018), and the current version is now V4.19.933 (15-FEB-2022)

icolwell-as commented 2 years ago

Hi @bonjiman, That's very strange behaviour, your setup typically works fine. I even installed it on my 20.04 laptop and list channels shows me some virtual channels since I don't have hardware with me at the moment.

One more thing you can try is running /usr/doc/canlib/examples/listChannels This should give you pretty much the same output as rosrun kvaser_interface list_channels, but it's straight from Kvaser's SDK, so if that doesn't work, then we can narrow it down a bit.

So ya, if you still don't see anything with listChannels, then that means Kvaser's software SDK/driver is unable to see Kvaser's hardware. At this point, you can try installing Kvaser's SDK directly from source: https://www.kvaser.com/linux-drivers-and-sdk/ (download SDK + Drivers and follow the included README. If the source-installed SDK also doesn't work, you can reach out to kvaser support about it.

If you wish to go back to using socketCAN, simply uninstall kvaser-drivers-dkms (or follow uninstall instructions from source SDK README) and it will remove the kvaser socketcan kernel module blacklists.

Don't forget to do a reboot any time after changing drivers just to be 100% sure.

bonjiman commented 2 years ago

@icolwell-as Thanks for all the suggestions! A group of students was continuing to work on getting SocketCAN to work, and they were successful. We decided to simply uninstall the Kvaser drivers and use SocketCAN for our project. I still do not know what our issues may have been, but our approaching deadline does not allow the opportunity to continue troubleshooting.

I appreciate the support, as always.

Have a good one!

icolwell-as commented 2 years ago

Glad you have a solution!