Converting Hexapod code from fixed point to floating point... Performance differences

Status
Not open for further replies.

KurtE

Senior Member+
Awhile ago I converted some code that runs on several different hexapods (Quads as well), that originally was written to run on BasicMicro Pro processors to C/C++ and the Arduino environment. I have also converted the code base to run on several different Linux processors as well (RPI, BBBk, ODroid).

When I first ported the code over to Arduino and likewise Linux, I continued to use fixed point math. I have been wondering for awhile about using floating point math instead, especially since the linux boxes all have FPU's.

So I have made a pass through building a version that uses floating point and have many parts of it appear to be working. I also put some timing checks in the code to get an idea how much time the IK code was taking for both the fixed point as well as the floating point versions. As expected the floating point on the Teensy 3.1 is slower. More details about it up on the Trossen forum: http://forums.trossenrobotics.com/showthread.php?6632-PhantomX-using-a-Teensy-3-1/page23

As implied in another thread, many of the floating point functions that I used (sin, cos, sqr, atan2...) default to double even though all of the inputs are float.
When I switched these functions to sinf, cosf, atan2f... It sped things up quite a bit. When I mentioned this up on Trossen and mentioned that I needed to get back to my Linux version and port my fixes back to this version. One of the comments up on Trossen forum was:
atan2f as well as acosf and sinef are only needed if you are compiling in C. In c++ the normal functions are overloaded so it picks appropriately.
I have not verified this yet on Linux, but my guess is he is right. If so, it sure would be nice if this was true with the Teensy as well...

Now I just need to get back to it ;)
Kurt
 
Status
Not open for further replies.
Back
Top