-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ros socketcan_interface misses messages that candump can see. #448
Comments
It is the first time that such an issue has been reported. Do you see that loss as well, if you try it with socketcan_bridge?
Did you try it with candump in this repo?
Performance-wise there should not be much of a difference between the threaded and the non-threaded version.
I believe that this might be the root cause of your troubles. You could use BufferedReader to decouple your user code properly. |
It's all automotive can so it's 500kbps and the messaging frequency varies.. and the hardware does it's own buffering i believe at the USB interface. I don't know the exact timing but if i look at 1 second of the log i'm getting 2600 msgs on one bus but i'm taking action on a specific subset of that via the FilteredFrameListener. I actually am getting decent performance with the SocketCanInterface and driver.run() approach. The compute load just seems high. Only occasional missed frames.
Yes, that does work. Which is why I then took the driver.run() approach from that with the SocketCanInterface vs ThreadedSocketCanInterface.
Interesting, I thought that Boost ASIO would have been the culprit. Sounds like it's not the case.
Our callbacks are quite small. When profiling the code, the conversion library code functions made up 10% of the load vs the Boost ASIO and interface stack took up the remaining majority.
This looks like exactly what I need. Do you know if this buffered reader would respect the CAN message order (FIFO)? Do you have any examples of this being used that I could take a look at? |
This does not mean that they cannot block ;)
Yes.
ros_canopen/canopen_master/src/master_plugin.cpp Lines 95 to 115 in eaaf0a1
This is independent from the actual CAN interface.
ros_canopen/socketcan_interface/include/socketcan_interface/filter.h Lines 49 to 66 in eaaf0a1
How many are you using? It might be faster, if you just write your own filter in one callback (or using a |
Or just create a
|
Sorry, this question isn't clear. What are you referring to?
Would the key in this case be can ID? I will do some experimentation today and see if there's an improvement. Thanks for the help. If you need to close the issue, feel free but it would be good to continue documenting for others if that's okay with you. |
How many instances of
Yes. It is the CAN ID including the high bits for RTR and extended CAN IDs. |
Only one. All the can traffic flows through that. |
Then the performance should be okay. |
Edited: Putting more than one question in. I'm new to multi-process and there's a lot of templating here. I thought I was decent at C++ but I'm being humbled by this library. I might need a little more spoon feeding. I looked over the I've looked at the multiple I see this being used a lot but can't figure out it's purpose. What does the |
I'm finding that any solution I attempt using the ThreadedSocketCanInteface is performing significantly worse than the non-threaded version. I don't know how I am able to use the non-threaded version with with the BufferedReader My next step is to examine the build scheme for differences between the base install and mine. |
Exactly.
I would not use a timer, but just use read all messages in a loop and process them.
Again, there is not much of a difference, except for one additional thread.
I still believe that your user code does something, which might not work well with that many threads (or the way they are used in ros_canopen).
It is part of the (optional) plugin system: http://wiki.ros.org/class_loader
Since you have to do the switch/case anyway, I would suggest to only use a single callback. |
Hello,
18.04 melodic, installed via apt, verified we're up to date as of writing .
I am currently using the socketcan_interface to re-assemble object lists and other data groupings from a vehicle can network to pass to ROS as a prototyping platform for autonomous vehicle work.
Some of this comes from vehicle can networks, some of this comes directly from Adas sensors but the struggle here is dropped messages at the ROS layer.
As an example, let's say the format is as follows with each message being unique:
They get assembled into an object list with all the parts and published to ros.
Or we're taking various vehicle state signals and packaging them into a single rosmsg and publishing them on a topic.
End result is we're collecting a specific # of can msgs, converting to engineering units from hex/binary and assembling a ros message from them. In many (nearly all) cases the receipt order and the completeness of the full package matters.
As a template for building these nodes we started with the socketcan_to_topic node (and the corresponding .cpp) which uses the can::ThreadedSocketCANInterface. When running this, we would often can messages that were dropped.
In order to get this running in a more reliable manner I had to convert to using the candump.cpp file as a template where we are using can::SocketCanInterface (which i assume is a non-threaded version) and the driver.run() command which forces the program to be shutdown via ctrl+c. This does capture nearly everything and runs significantly more reliable but it does consume a significantly higher amount of resources. I have looked high and low for people with the same issue but I'm not seeing it. I've done some tests with this and I've found the following:
If anyone has an idea how i can reduce the dropped messages coming into this node, it would be very helpful. I don't believe any of our data conversion code is specifically high consumption so i would be very surprised if this was it. With the driver.run() method we do have an issue with throughput if we have more processes running on that same piece of hardware. As a result I think our next step is to move the can content off of the main PC and onto some other smaller machiens running ROS but this just seems like it's not such a high throughput that this should be necessary.
The text was updated successfully, but these errors were encountered: