Go to Post Truly listening to the wealth of advice around you is so important. Don't work in a vacuum all season long. - OZ_341 [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 11-02-2013, 20:01
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
Command Based Robot Limit Switch Help

What would be the best way to go about programming limit switches for a command based robot? The subsystem in question is intended to have two switches. One switch would stop the arm from moving too far, and the other switch would be so that it would stop in a ready position. When the arm moves, it is to move to the ready position, hit the second switch, and then move backwards until it hit the first switch. This process is intended to be run by a joystick button. I know very little about c++ and have not yet managed to program any sensors whatsoever.
Reply With Quote
  #2   Spotlight this post!  
Unread 12-02-2013, 09:24
Jefferson Jefferson is offline
Registered User
AKA: Jeff Clements
FRC #0016 (Bomb Squad)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Mountain Home, AR
Posts: 258
Jefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond reputeJefferson has a reputation beyond repute
Re: Command Based Robot Limit Switch Help

Without knowing the details, let me see if I can help you get started.

It sounds like you expect everything to run in sequence, so would suggest a command group with each of the these steps added sequentially. The command group will be tied to the joystick button "whenPressed."

Create commands that will run the arm at a set speed in the direction you want. In the "IsFinished" function, create an if statement using the limit switch input so it will return true when the limit switch is made. This will end the current command and kick off the next one in the group.

Review the screensteplive documentation on how to create the commands and command groups.

Also, you might want to create a default command for the subsystem that does nothing. it will revert to this command when it is done with the command group.
Reply With Quote
  #3   Spotlight this post!  
Unread 12-02-2013, 23:19
jalburty jalburty is offline
Joe Alburty
AKA: Joe Alburty
FRC #1763 (Paseo Pirates)
Team Role: Mentor
 
Join Date: Oct 2006
Rookie Year: 2005
Location: Kansas City
Posts: 25
jalburty will become famous soon enoughjalburty will become famous soon enough
Send a message via ICQ to jalburty
Re: Command Based Robot Limit Switch Help

You might want to hook at least one limit switch directly into the normally-closed limit switch ports of the Jaguar. Search Chief Delphi for "jaguar limit switch" or something similar to find several discussions of this nice feature. By doing this the Jaguar 'knows' to stop moving in the direction that causes the limit switch to close and therefore you don't have to program the motor to stop for that direction.
Reply With Quote
  #4   Spotlight this post!  
Unread 13-02-2013, 08:04
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is online now
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,722
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Command Based Robot Limit Switch Help

I know in Java you can activate commands based on button presses. You can also extend the Button class and override it's get() method to get the value of a limit switch. After that you fire a command when the "button" is pressed. I'd imagine you can do something similar in the C++ version. You just fire a command that tells the motor controller to stop.

If I'm reading this right the two limit switches are your two positions that you want the arm to stop at? So basically you press a button and the arm goes until it hits a limit switch, then on another button press it goes back to the original limit switch?
Reply With Quote
  #5   Spotlight this post!  
Unread 13-02-2013, 11:45
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 590
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Command Based Robot Limit Switch Help

Quote:
Originally Posted by zackd97 View Post
The subsystem in question is intended to have two switches. One switch would stop the arm from moving too far, and the other switch would be so that it would stop in a ready position. When the arm moves, it is to move to the ready position, hit the second switch, and then move backwards until it hit the first switch. This process is intended to be run by a joystick button. I know very little about c++ and have not yet managed to program any sensors whatsoever.
You could make two commands, one to move it to the ready position. It would start the motor moving in the initialize() method then check the limit switch in the isFinished() method. In the end() method, stop the motor.

A second command would start the motor moving in the other direction in its initialize() method and its isFinished() method waits for the other limit switch. Its end() method also stops the motor.

In both cases, make sure the interrupted() method also calls end() so the motors stop if something else uses that subsystem.

With those two commands working individually, make a command group that does the two commands sequentially.

It's two classes, but you only have to write a few lines of code in each one. And it's easy to test - put the commands to the SmartDashboard and you'll see buttons to test each command.

Brad
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
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