Go to Post As a rookie team member at my first event, i had a great time, the little glitches meaning nothing. - Gluedtothefloor [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-17-2014, 05:11 PM
William Kunkel William Kunkel is offline
Programming Lead
AKA: Kunkel
FRC #0422 (Mech Tech Dragons)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Richmond, VA
Posts: 94
William Kunkel is an unknown quantity at this point
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?
Reply With Quote
  #2   Spotlight this post!  
Unread 02-18-2014, 01:23 AM
Joe Hershberger Joe Hershberger is offline
National Instruments
AKA: jhersh
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 1997
Location: Austin, TX
Posts: 148
Joe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to allJoe Hershberger is a name known to all
Re: Using atan2 on the cRIO

Quote:
Originally Posted by MaraschinoPanda View Post
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?
I think the problem is not the header you are including, but the library that is not loaded. It is possible that the function is not compiled in, but that would surprise me a bit. Perhaps there is a separate library that needs to be loaded.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-19-2014, 01:15 PM
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Using atan2 on the cRIO

#include "Math.h" is likely what you are looking for
Reply With Quote
  #4   Spotlight this post!  
Unread 02-19-2014, 05:05 PM
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,033
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Using atan2 on the cRIO

Quote:
Originally Posted by Joe Hershberger View Post
I think the problem is not the header you are including, but the library that is not loaded. It is possible that the function is not compiled in, but that would surprise me a bit. Perhaps there is a separate library that needs to be loaded.
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.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #5   Spotlight this post!  
Unread 02-20-2014, 06:14 PM
William Kunkel William Kunkel is offline
Programming Lead
AKA: Kunkel
FRC #0422 (Mech Tech Dragons)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Richmond, VA
Posts: 94
William Kunkel is an unknown quantity at this point
Re: Using atan2 on the cRIO

Huh, I was unaware of that. I'm surprised I haven't come across this before.
Reply With Quote
  #6   Spotlight this post!  
Unread 02-20-2014, 08:05 PM
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,168
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Using atan2 on the cRIO

Quote:
Originally Posted by virtuald View Post
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.
That would not be true in this case. The .out file we load on the robots is a relocatable object that is dynamically loaded and linked into the VxWorks kernel space. So it works like adding a kernel module in Linux, not like an executable and library in user space. It would be true if we used real-time processes (RTPs) in VxWorks which are much like processes in Linux but we don't. I think support for them is not included in the kernel we are provided.

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!
__________________
Fast, cheap or working - pick any two!
Reply With Quote
  #7   Spotlight this post!  
Unread 02-20-2014, 09:41 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,997
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Using atan2 on the cRIO

Quote:
Originally Posted by MaraschinoPanda View Post
Whenever I try to use the atan2 function by including <cmath>, I can compile, but I get "no robot code"...
If you still haven't been able to get the library atan2 function to work, and you need something to tide you over until you can get it figured out, here's a simple C code implementation that's good to within 1/10 of a degree.


Reply With Quote
  #8   Spotlight this post!  
Unread 02-22-2014, 09:15 AM
taichichuan's Avatar
taichichuan taichichuan is offline
Software Mentor
AKA: Mike Anderson
FRC #0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2010
Location: Herndon, VA
Posts: 328
taichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud oftaichichuan has much to be proud of
Send a message via AIM to taichichuan
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
Reply With Quote
  #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
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 04:11 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi