|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Using atan2 on the cRIO
Whenever I try to use the atan2 function by including <cmath>, I can compile, but I get "no robot code" and netconsole gives the message "Warning: module 0x26eaa80 (FRC_UserProgram.out) holds reference to undefined symbol atan2f." If I use std::atan2 or atan2f, or even just try atan, the same error occurs. I've also tried using <math.h> instead of <cmath>. All compile, but none are defined. Does the cRIO not have trig functions in its c++ library, or am I doing something wrong?
|
|
#2
|
|||
|
|||
|
Re: Using atan2 on the cRIO
Quote:
|
|
#3
|
|||
|
|||
|
Re: Using atan2 on the cRIO
#include "Math.h" is likely what you are looking for
|
|
#4
|
||||
|
||||
|
Re: Using atan2 on the cRIO
Yep. On a normal *nix machine, you have to add -lm to your link command to use the math library. I expect this is the same thing in Wind River.
|
|
#5
|
|||
|
|||
|
Re: Using atan2 on the cRIO
Huh, I was unaware of that. I'm surprised I haven't come across this before.
|
|
#6
|
||||
|
||||
|
Re: Using atan2 on the cRIO
Quote:
Are you sure it is atan2 that is not being resolved? It should be there. The OS image includes the GNU math libraries and we have used atan2 before in field-centric driver algorithms. Good luck! |
|
#7
|
||||
|
||||
|
Re: Using atan2 on the cRIO
Quote:
|
|
#8
|
||||
|
||||
|
Re: Using atan2 on the cRIO
Hmm... We used the atan2 function in the 2010 bot with no problems. A quick check on the bot shows both an atan and an atan2 in the symbol table. From the netconsole prompt:
-> lkup "atan" atan 0x000b5218 text atan2 0x000b542c text The actual addresses are not important. But the "text" shows that there are funtions out there with the names shown. Make sure that you include math.h and reference the function as "atan2" not "atan2f". WRS has the double precision version of the function on the bot. HTH, Mike |
|
#9
|
|||
|
|||
|
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) Change your code to: Code:
double d = atan2(double x, double y) |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|