![]() |
Child function problems
My goal right now is to put everything in our main code (west coast, motor automation, etc.) into child functions in the IterativeRobot.h header file. However, the CANTalon and Talon instances, when initialized within the function itself, executes over and over again as the main TeleopPeriodic section in the main program loops and therefore starts and shuts off the motor over and over again. Here's the code:
Code:
|
Re: Child function problems
Quote:
|
Re: Child function problems
I agree with lopsided. I'll add a few things as well.
* As a bug/nit - I dont see encoderDist being 'set' or assigned or incremented anywhere. Maybe outside the scope of what you pasted in. But without...it'll not operate as you intend. * You talk about putting code into the .h header file. Header files are not the best place to put implementations (code). This is because there are other files which may EACH #include such a header file. When it gets included by multiple files, the implementation will be done multiple times and you'll at least get strange errors from the compiler which may be very non-obvious how to fix. Put implementation/code in .cpp files only. bob |
Re: Child function problems
Quote:
|
Re: Child function problems
Quote:
Code:
motorAutomationEncoder(e_encoder_dist, 200, -100, fan_motor_SRX, 1.0);Code:
|
Re: Child function problems
Quote:
|
Re: Child function problems
Quote:
|
Re: Child function problems
Quote:
Code:
int motorAutomationEncoder(double encoderDist, |
Re: Child function problems
If you want to use your CANTalon object, you should pass it as a pointer .
Code:
CANTalon *pMySpeedController |
Re: Child function problems
Quote:
Code:
Info: Nothing to build for EncoderMain program Code:
...Code:
int motorAutomationEncoder(double encoderDist, |
Re: Child function problems
A couple thoughts...
I teach my students to right-click on the project they want to build (in the left pane) and select "Build Project" ... this way there's no question what was being asked of Eclipse. I would suggest doing the following to help further diagnose if the above doesn't help (which it probably wont since its really just general)... - Right click on the project and select 'clean project' - Verify it's clean by opening up the 'Debug' folder in eclipse for that project and you should NOT see FRCUserProgram which is the final binary output file that gets sent to the roborRIO - Click on the 'problems' tab in the lower / console area at the bottom of Eclipse. - Right click on 'Errors' and select 'Delete' - and confirm. - Right click on 'Warnings' and select 'Delete' - and confirm. - Confirm there is nothing in the 'problems' tab any longer. This is a bit painful but will make sure you're only looking at NEW problems and not old ones. - Now right click on the project again and select 'Build Project' ... After it completes, look in the 'problems' tab for errors and warnings. - If there are errors/warnings - post them here. - If there are no errors, take a look again in the Debug folder in the project (left pane) and see if there is a FRCUserProgram (this would indicate a successful compile) - If there is indeed an FRCUserProgram, then you should be good to right click on the project and select RunAs->WPILibC++Deploy If you got to the deploy - then check in the lower area for a 'Console' tab which will have the results of the deploy operation. Once this works well, it shouldn't be so painful as described above. I'm just trying to eliminate any variables I can so that the next step of troubleshooting becomes illuminating of the root cause. Hopefully. :) bob |
| All times are GMT -5. The time now is 12:07. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi