robotology / whole-body-estimators

YARP devices that implement estimators for humanoid robots.
26 stars 12 forks source link

Attempt to improve the performances of the ctrlLibRT library #143

Open GiulioRomualdi opened 2 years ago

GiulioRomualdi commented 2 years ago

As a consequence of #141 I tried to improve the performances of the ctrlLibRT. Before explaining what I did I would recall that: ⚠️ we should test this PR on the robot to understand if the performances are improved

First of all, I tried to remove the copies from yarp to idyntree, thanks to this choice this code

iDynTree::toYarp(jointAcc,filters.bufferYarpDofs);
const yarp::sig::Vector & outputJointAcc = filters.jntAccFilter->filt(filters.bufferYarpDofs);
iDynTree::toiDynTree(outputJointAcc,jointAcc);

becomes

iDynTree::toEigen(jointAcc) = filters.jntAccFilter->filt(iDynTree::toEigen(jointAcc));

so I removed two copies every time the joint state is filtered. A similar approach has been used for joint vel, joint acc, accelerometers and gyros, ft.

To achieve that I changed the interface of the ctrLibRT to consider eigen::ref

traversaro commented 2 years ago

⚠️ we should test this PR on the robot to understand if the performances are improved

Based on my experience, the change in performance also on a custom example that uses those classes as the wbd does may be also a good indication in the increase in the performance.

GiulioRomualdi commented 2 years ago

I benchmarked the two implementations and I didn't notice any notable timing improvements

traversaro commented 2 years ago

Let's see the bright side. If you have a simple executable it is much easier to profile the code with something like callgrind or flamegraphs

traversaro commented 2 years ago

Removing myself from the reviewers, feel free to add me back if the PR is being worked on.