stack-of-tasks / pinocchio

A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
http://stack-of-tasks.github.io/pinocchio/
BSD 2-Clause "Simplified" License
1.84k stars 386 forks source link

Speeding Up Computation Time of Inverse Dynamics #934

Closed gsutanto closed 4 years ago

gsutanto commented 4 years ago

Dear Pinocchio Authors,

I am using Pinocchio's RNEA inverse dynamics computation in a real-time control loop at 1000 Hz, which means 1ms control window. However, I measured the RNEA computation time itself is 0.5ms. Is there anyway to make it compute faster?

Best Regards,

Giovanni Sutanto

gabrielebndn commented 4 years ago

Normal execution times are in the order of a few microseconds. Are you sure you are compiling your project with the correct compilation flags? -O3 should give best performances

gsutanto commented 4 years ago

Oh yeah, you're right. Once I use Release mode and -O3 flag, the computation time goes down to 3 microseconds. Thanks a lot @gabrielebndn !

jcarpent commented 4 years ago

@gsutanto Just for information, what is the model of your robot? model.nq? model.nv?

gsutanto commented 4 years ago

Hi @jcarpent , model.nq=7, model.nv=7

jcarpent commented 4 years ago

You may have a look at the paper https://hal-laas.archives-ouvertes.fr/hal-01866228 which describes Pinocchio. And you will see some benchmarks on several robots. You can expect to go below 1us for the RNEA. Can you run:

make bench
./benchmarks/timings

It will show the bench for a standard humanoid robot, but you can also do

./benchmarks/timings my_urdf_model.urdf

for your specific robot.

Thanks in advance for your reply.

gsutanto commented 4 years ago

Dear @jcarpent ,

I see. Thanks for the references. For now, this is fine for our need. If we need optimize further, we will refer to (and potentially re-open) this thread.

Thanks!

Best Regards,

Giovanni