ros-drivers / um6

ROS driver for UM6 inertial measurement device.
4 stars 21 forks source link

Reduce CPU IO by reading in bigger chunks and buffering locally #8

Closed mikepurvis closed 7 years ago

mikepurvis commented 11 years ago

Implementation from @cedricpradalier using a separate background reading thread: https://github.com/cedricpradalier/um6/tree/rosbuild

Simpler might be just a single blocking read, and then pick bytes off of it using a ros::serialization::IStream.

Alternatively, the threaded implementation could be adopted, or an approach along the same lines, perhaps based on coroutines or async.

cedricpradalier commented 11 years ago

As the original author, I should precise that my priority was reducing CPU load, eventually at the cost of slight delays and code complexity. That being said, I fully agree that I would have preferred to move to a blocking read with an ASyncSpinner taking care of service calls. The reason why I still chose the thread was the implementation of the configuration request. A blocking reader would make sending and waiting for acknowledgement slightly more complicated, although this could be done by another little state machine. Also because that only happens at start-time/reset-time, strong assumption could be made to simplify the logic. In the end, I found the logic of an independent reading thread easier and nicer to design.