Go to Post Come on, Dave! We need more lyrics! (I'll bring you fresh KK doughnuts at VCU's regional! :D ) - Squirrelrock [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 14-02-2013, 21:47
zackd97 zackd97 is offline
Registered User
FRC #4102
 
Join Date: Feb 2013
Rookie Year: 2013
Location: New Mexico
Posts: 16
zackd97 is an unknown quantity at this point
Limit Switch Problems

I'm having trouble creating a functional program for limit switches. The idea is that there is an arm that will move forward, trigger a switch at its limit, and move back until it triggers another switch in the ready position. I think the problem is either the switches themselves, my if statements, or how I'm trying to take the values of the switches. Right now when I run the program the arm will move back without stopping. The arm will continue to move back until I restart the cRio, completely ignoring the switches. I tried changing the if statements to false, but when I do that the arm just twitches for a second. If anyone can find what I'm doing wrong or give a better solution, that would be awesome.

The code can be found here- https://github.com/zackd97/RobotProject4

Sorry if the github repository sucks, I'm pretty new at this.

Edit: I forgot to mention that all of the issues are in the loader subsystem, pushfrisbee command, readyposition command, and the frisbeeload command group.

Last edited by zackd97 : 15-02-2013 at 10:28. Reason: Missing Information
Reply With Quote
  #2   Spotlight this post!  
Unread 17-02-2013, 00:36
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Limit Switch Problems

I'm not a pro at reading robotbuilder code, but in just taking a cursory glance at your loader subsystem file, I see the following code...
Code:
bool Loader::GetReadySwitch(){
	readySwitch->Get();
}
bool Loader::GetEndSwitch(){
	endSwitch->Get();
}
While I didn't study the way these functions are used, it would seem that they are not doing you any good... GetReadySwitch() and GetEndSwitch() should *return* a boolean. They are not returning anything. They each go and 'Get()' the value of the digital inputs, but they don't return them... a corrected version might be:

Code:
bool Loader::GetReadySwitch(){
	return readySwitch->Get();
}
bool Loader::GetEndSwitch(){
	return endSwitch->Get();
}
Without returning anything, whomever calls those Get*Switch() functions won't get any info back.

Also, please look at your compiler warnings. The compiler should warn you that you have defined a function as a 'bool' but you returned no value at all. Warnings from compilers are often times very important - especially when you're less experienced.

bob
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
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 15: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