Go to Post Okay guys I am enabling the robot. Honestly I have know idea what it is going to do. SO MOVE!! - JulieB [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 06-02-2011, 21:52
divisionByZero0's Avatar
divisionByZero0 divisionByZero0 is offline
Hexadecimal Hacker Droid no. 0x2328
FRC #0498 (Cobra Commanders)
Team Role: College Student
 
Join Date: Jan 2011
Rookie Year: 2008
Location: Glendale, AZ
Posts: 30
divisionByZero0 is an unknown quantity at this point
Exclamation Multiple .cpp files in Windriver

The basic structure of our team's code was to have multiple .cpp files in the same project. Each .cpp was a custom Class for each component for our robot.

The problem was that our robot will refuse to load its own code.


My theory about this was the compiled .o files were not compiled in the correct order in the .out program for the CRIO's bootloader to recongize our main robot's code. Does anyone knows if the .cpp file for our main robot codes should be compiled before or after every other .cpp file? Or does the order of how each .cpp into the .out code shouldn't matter?
Reply With Quote
  #2   Spotlight this post!  
Unread 06-02-2011, 22:23
demosthenes2k8's Avatar
demosthenes2k8 demosthenes2k8 is offline
Graduated but not gone
AKA: Matt Soucy
FRC #0166 (Chop Shop 166)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Merrimack, NH
Posts: 589
demosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to beholddemosthenes2k8 is a splendid one to behold
Send a message via AIM to demosthenes2k8 Send a message via Yahoo to demosthenes2k8
Re: Multiple .cpp files in Windriver

Normally, the .cpps can be compiled in any order, since they'll all be linked together in the end.
__________________


GSR Dean's List Finalist 2011
Reply With Quote
  #3   Spotlight this post!  
Unread 08-02-2011, 03:27
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: Multiple .cpp files in Windriver

It is also true of the cRIO. The linker runs after each file is compiled. Any unresolved symbols are resolved by the loader at runtime. If the loader can't resolve them, then you get an error.

-Joe
Reply With Quote
  #4   Spotlight this post!  
Unread 08-02-2011, 07:00
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Multiple .cpp files in Windriver

If you haven't already, use the "target console" in windriver or the serial output on the cRio to find out what symbols aren't loading.

Make sure you're using matching versions of the cRio image (v27, for example) and WPILib.

Make sure that all your CPPs are added to windriver and are actually getting compiled (easy test: insert compile errors in them and see if you fail to build your project). Having a definition in a .h file but forgetting to include the cpp will allow you to compile, but it'll fail once it is on the robot.
Reply With Quote
  #5   Spotlight this post!  
Unread 10-02-2011, 00:19
divisionByZero0's Avatar
divisionByZero0 divisionByZero0 is offline
Hexadecimal Hacker Droid no. 0x2328
FRC #0498 (Cobra Commanders)
Team Role: College Student
 
Join Date: Jan 2011
Rookie Year: 2008
Location: Glendale, AZ
Posts: 30
divisionByZero0 is an unknown quantity at this point
Unhappy Re: Multiple .cpp files in Windriver

Thanks for the advice...
That problem was easily resolved....


..... but now we have a new problem
Our team-coded classes are failing to initalize some components.
Each time these components are called, The cRIO freaks out and
reboots it self. So please, just a few more questions:

How "Bug-less-ly" can you initalize a WPILib C++ object via.......
Object i.e: Victor myVictor(...)
vs.
Pointer i.e: DigitalInput* myDI = new DigitalInput(...)

What are all the possible program exceptions to look
for that relates only when initalizing the object?

If we were to put them in a custom C++ class that
our main robot will use, of which that custom class will hold all
of the required group of electronic objects of the special component
on the robot that custom class is made for; What would be a nice,
error/exception free example for this? (Sorry if you see this as a run-on)


Our team has the recent updates for Windriver, the cRIO, and the
Driver Station. So we don't think those shouldn't be the problem.

Please, help us.....

Thank you all in advance,
And thank you everyone else who helped us on this topic so far.....
__________________

498 Student Programmer: 2008 to 2011
498 Hemi-mentor: 2011 to ....

If all else fails, multiply both sides by zero to neutralize the equation.

Last edited by divisionByZero0 : 10-02-2011 at 01:04.
Reply With Quote
  #6   Spotlight this post!  
Unread 10-02-2011, 07:28
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Multiple .cpp files in Windriver

What we typically do is instantiate all our component pointers in the Robot constructor, then pass them into the sub-controller classes.

Example: Let's say my robot class is Robot2702

class ArmController2702
{
public:
ArmController2702(Victor* pClaw, Victor* pArm, Encoder* pArmEncoder) : m_pClaw(pClaw), m_pArm(pArm), m_pEncoder(pEncoder) {}
};
class Robot2702
{
public:
Robot2702()
{
clawMotor = new Victor(1,2);
armMotor = new Victor(3,4);
armEncoder = new Encoder(5,6,7,8);
armController = new ArmController2702(clawMotor, armMotor,armEncoder);
}
void OperatorControl() {}
void Autonomous() {}
};


Checks:
-It's a good idea to pass objects in or instantiate them in the constructor. That way, you know they're there before you start using the class.
-To figure out what's going on, I believe there is a function you can use called wpi_fatal which will halt execution. You could use it like this
if(armEncoder == NULL) wpi_fatal("oh no, our arm is missing!");
then watch the output in the console to see what's going on
-Make sure your battery is full. A low battery can cause the robot to reset once a motor draws current and drops the voltage too low.
Reply With Quote
  #7   Spotlight this post!  
Unread 14-02-2011, 23:42
divisionByZero0's Avatar
divisionByZero0 divisionByZero0 is offline
Hexadecimal Hacker Droid no. 0x2328
FRC #0498 (Cobra Commanders)
Team Role: College Student
 
Join Date: Jan 2011
Rookie Year: 2008
Location: Glendale, AZ
Posts: 30
divisionByZero0 is an unknown quantity at this point
Talking Re: Multiple .cpp files in Windriver

Works perfectly!!!!!!

Thank you so MUCH
__________________

498 Student Programmer: 2008 to 2011
498 Hemi-mentor: 2011 to ....

If all else fails, multiply both sides by zero to neutralize the equation.
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 03:06.

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