ethz-asl / ethzasl_xsens_driver

Driver for xsens IMUs
BSD 2-Clause "Simplified" License
102 stars 112 forks source link

XSensDriver.spin_once() redefines all the functions required for populating the output messages at every loop iteration #103

Closed moooeeeep closed 5 years ago

moooeeeep commented 5 years ago

I just noticed that the function XSensDriver.spin_once, that does the parsing, populating and publishing at a potentially high frequency, redefines all the required helper functions locally at every loop iteration.

I would expect to receive a (significant?) speed-up, if these functions were converted to ordinary member functions or free functions and thus were only defined once for the runtime of the node.

It should be possible to rewrite the handler dispatching code here in a straight-forward way using getattr(). I can try to provide a PR, if I find the time.

fcolas commented 5 years ago

You're right. I'm not sure how large the speedup can be but it is inefficient. I would appreciate a PR when you have the time.

moooeeeep commented 5 years ago

As stated in the comments in the PR the inefficiency actually is insignificant compared to other factors. Therefore I'll close this issue.