Serial Load Cell is slow in ROS
Hi all,
So I have these load cells (4 of them) for which I have written a nice C++ class wrapper to interface with the sensors in a ROS environment. I have 4 topics, called "loadSensorX" where X = 0,1,2,3. These topics publish the force felt by these sensors in millipounds.
Now the load cells are actually LoadStar Sensor capacitive sensors with serial USB output. Here is the link to it
http://www.loadstarsensors.com/lc003-iload-tr-series-tilt-resistant-usb-load-cell.html
To the left of the page, you can see that default data rate for a standard sensor is 150 Hz. I have 4 of these sensors connected to my PC with a USB hub. Now all the topics and everything work fine. But when I do
rostopic hz /loadSensor0
instead of getting 150 Hz, I get only about 10-15 Hz. Also, when I connect just a single load cell instead of all 4 and try
rostopic hz /loadSensor0
I get about 50-55 Hz.
In both cases, I get much less data output rate compared to the promised 150 Hz. Which brings me to my question. Why does this happen? Is it because I am using a USB hub? Or is it my laptop specifications? Or is it ROS using up a lot of CPU power for just publishing 4 topics? Also, why do multiple load cells being connected with the hub affect my data rate?
My laptop specifications are
Intel Pentium CPU B960 Processor @ 2.20 GHz
64-bit Windows 8 OS with 32-bit Ubuntu 12.04 on VMWare Player.
4 GB RAM for host OS, 1 GB RAM for Ubuntu 12.04.
Thanks and any help is greatly appreciated.
Can you try on Ubuntu installed on an actual machine? I'm curious if maybe there is some odd interaction in the VMWare USB stack that could be affecting this. Try @dornhege's suggestion first, but if it doesn't look like your code that is the problem, try removing the VM.
Yes, I had that feeling too. Plus, the computer I am using has only 1 processor. On an different computer that I used earlier, with 4 processors (pentium core i7), I got 16-20 Hz when I used 4 sensors and 60-65 Hz with 1 sensor. In any case, I will first try dornheges solution and post updates here.