View Single Post
  #9   Spotlight this post!  
Unread 05-29-2014, 01:20 AM
jrw jrw is offline
Registered User
FRC #4774 (The Drop Bears)
Team Role: Mentor
 
Join Date: Sep 2013
Rookie Year: 2013
Location: Sydney
Posts: 6
jrw is an unknown quantity at this point
Lightbulb Re: Using atan2 on the cRIO

For anyone hitting the same obscure problem here is the answer.

I note from the github repo of the OP's code that they are using the C++11 toolchain from FirstForge. We haven't used the original toolchain, only the C++11 toolchain too, so it might only affect those teams using this.

Anyway, the problem is that the compiler substitutes the float version of trig functions if it thinks you don't need the extra precision.
If you have:
Code:
float f = atan2(float x, float y)
then the compiler will substitute this for the atan2f function, and this is not on board the cRIO.

Change your code to:
Code:
double d = atan2(double x, double y)
and it will be plain sailing. Even casting the floats to doubles as you call the function will work.
Reply With Quote