Go to Post Diversity means diversity in ideas too. Some of the robots from the singapore competition might have employed strategies or ideas that we may not even have come up with in North America. - J Flex 188 [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-07-2009, 09:27 AM
Chief Pride's Avatar
Chief Pride Chief Pride is offline
<3
AKA: James Kiefer
no team
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Kalamazoo, MI
Posts: 653
Chief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond repute
Passing a motor as an argument in a function

Hello, I am trying to pass a speed controller (victor) as an BYREF argument in a function and set its value, however, the motor wont turn on and I get no errors. Here is what it looks like:

Code:
void SpecialControl(SpeedController &Motor); /* prototype */
class Robot : public SimpleRobot
{
	Victor InitialMotor;
	public:
		Robot(void):		// these must be initialized in the same order 
		InitialMotor(1)
	{
		GetWatchdog().SetExpiration(0.1);
	}



void OperatorControl(void)
	{
		GetWatchdog().SetEnabled(true);
		SpecialControl(InitialMotor);
	}
};

void SpecialControl(SpeedController &Motor)
{
	Motor.Set(1);
}
Thanks in advance.
Reply With Quote
  #2   Spotlight this post!  
Unread 02-09-2009, 01:07 AM
Redneck's Avatar
Redneck Redneck is offline
Hacker Hick
AKA: Jamie (2.0) Moran
FRC #0599 (Robodox)
Team Role: Engineer
 
Join Date: Aug 2004
Rookie Year: 2004
Location: California
Posts: 90
Redneck is just really niceRedneck is just really niceRedneck is just really niceRedneck is just really nice
Send a message via AIM to Redneck
Re: Passing a motor as an argument in a function

Give this a shot:
Code:
void SpecialControl(SpeedController *Motor); /* prototype */
class Robot : public SimpleRobot
{
	Victor *InitialMotor;
	public:
		Robot(void)
	        {
                       InitialMotor = new Victor(1);
		       GetWatchdog().SetExpiration(0.1);
	        }


                void OperatorControl(void)
	        {
		     GetWatchdog().SetEnabled(true);
		     SpecialControl(InitialMotor);
	        }
};

void SpecialControl(SpeedController *Motor)
{
	Motor->Set(1);
}
__________________


Which badges can you claim?
Reply With Quote
  #3   Spotlight this post!  
Unread 02-09-2009, 12:45 PM
Chief Pride's Avatar
Chief Pride Chief Pride is offline
<3
AKA: James Kiefer
no team
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Kalamazoo, MI
Posts: 653
Chief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond repute
Re: Passing a motor as an argument in a function

I have tried that, and it gives me these errors:
Quote:
error: cannot convert `Victor' to `SpeedController*' for argument `1' to `void SpecialControl(SpeedController*)'
Thanks in advance.
Reply With Quote
  #4   Spotlight this post!  
Unread 02-09-2009, 02:25 PM
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Passing a motor as an argument in a function

Look carefully at this line, and make sure you didn't leave out anything.
Code:
	Victor *InitialMotor;
Reply With Quote
  #5   Spotlight this post!  
Unread 02-09-2009, 07:53 PM
Chief Pride's Avatar
Chief Pride Chief Pride is offline
<3
AKA: James Kiefer
no team
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Kalamazoo, MI
Posts: 653
Chief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond reputeChief Pride has a reputation beyond repute
Re: Passing a motor as an argument in a function

Ah, finally, that compiles... I will see if it runs on the robot tomorrow. Thanks so much...
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Team Argument! dmoody92 General Forum 30 02-05-2009 09:28 AM
Generate_Pwms argument error in MPLAB LieAfterLie Programming 6 12-06-2007 05:01 PM
Motor Ramp Up/Ramp Down Function Tom Bottiglieri Programming 12 12-03-2006 11:31 PM
Motor drive function? Mike Programming 3 02-15-2006 11:55 AM
Pbasic argument question... Ghetto_Child Programming 10 02-18-2002 09:23 AM


All times are GMT -5. The time now is 10:13 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