Go to Post To me, every robot is a moving mechanical art form, a sculpture made of aluminum, motors and gears, and I think that soon we will be seeing those art forms involved in some of the most fantastic robotic "dances" that any of us have ever seen - DougHogg [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

 
 
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 04-02-2015, 18:46
DrOmni9885's Avatar
DrOmni9885 DrOmni9885 is offline
Registered User
FRC #1595 (Dragons)
Team Role: Programmer
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Spokane, WA
Posts: 8
DrOmni9885 is an unknown quantity at this point
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:
	
int motorAutomationEncoder(double encoderDist,
				           double encoderDistThresholdMax,
					   double encoderDistThresholdMin,
					   const int motorPort,
					   double motorSpeed)
	{
		CANTalon motor(motorPort);
		if(encoderDist > encoderDistThresholdMax) {
			motor.Set(0.0);
		}
		else if(encoderDist <= encoderDistThresholdMax && encoderDist >= encoderDistThresholdMin) {
			motor.Set(motorSpeed);
		}
		else if(encoderDist < encoderDistThresholdMin) {
			motor.Set(0.0);
		}
		SmartDashboard::PutNumber('current motor value', motor.Get());
	}
I'd appreciate any help. Thanks!
Reply With Quote
 


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 12:07.

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