Go to Post Something has gone awry this year in FIRST. I think more teams are concerned with winning and their robot that they don't even stop to think about the kids on their team, or the learning experiences of others. - Amanda Morrison [more]
Home
Go Back   Chief Delphi > Technical > Control System > FRC Control System
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 06-02-2016, 14:02
neilmart neilmart is offline
Registered User
FRC #2130
 
Join Date: Jan 2016
Location: idaho
Posts: 2
neilmart is an unknown quantity at this point
Toggle or Digital Switches

Hi, we had a question regarding the autonomous period of competition. Our team has always used toggle switches and true / false conditionals, though we were curious if there is anyway to make a digital toggle switch on the smart dashboard that we could press shortly before the beginning of autonomous. Also, we were curious if this was even legal. Thanks for the help!
Reply With Quote
  #2   Spotlight this post!  
Unread 06-02-2016, 14:04
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Toggle or Digital Switches

Perfectly legal. This is perfectly functional, albeit 2 years old.
__________________
FRC Team 1684 - Head Programmer (2013-2016)
FRC Team 5460 - Programming Mentor (2015-2016)

FIRST in Michigan - Technical Crew (2015-continuing)
Reply With Quote
  #3   Spotlight this post!  
Unread 09-02-2016, 22:04
NegaNexus NegaNexus is offline
Registered User
AKA: Thys Ballard
FRC #2130 (Alpha+)
Team Role: Programmer
 
Join Date: Oct 2012
Rookie Year: 2012
Location: Coeur d'Alene, Idaho
Posts: 16
NegaNexus is an unknown quantity at this point
Re: Toggle or Digital Switches

When looking through some stuff, I found a Reddit post with a way that seems effective. When I tried it on the code below I get an odd error. When we select a mode, it works fine. When we disable, select another mode, and re-enable the program, it runs both cases at the same time. Any ideas anyone?

Code:
package org.usfirst.frc.team2130.robot;


import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.CANTalon;
import edu.wpi.first.wpilibj.IterativeRobot;

public class Robot extends IterativeRobot {
	
    RobotDrive myRobot;
    CANTalon talon;
    CANTalon talon1;
    final String defaultAuto = "Default";
    final String customAuto = "My Auto";
    SendableChooser chooser;
    int mode = 1;

    public Robot() {
        myRobot = new RobotDrive(0, 1);
        myRobot.setExpiration(0.1);
        talon = new CANTalon(2);
        talon1 = new CANTalon(4);
    }
    
    public void robotInit() {
        chooser = new SendableChooser();
        chooser.addDefault("Run 2", 1);
        chooser.addObject("Run 4", 2);
        SmartDashboard.putData("Auto modes", chooser);
    }

    public void autonomousInit() {
    	mode = (int) chooser.getSelected();

    }
    
    public void autonomousPeriodic(){
    	switch(mode) {
	case 1:
		talon.set(0.25);
		break;
	case 2:
		talon1.set(1);
		break;
	}
    }
    
    public void operatorControl() {
        myRobot.setSafetyEnabled(true);
        while (isOperatorControl() && isEnabled()) {
            talon.set(0.25);
        }
    }
    
    public void test() {
    }
}
Reply With Quote
  #4   Spotlight this post!  
Unread 12-02-2016, 23:22
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: Toggle or Digital Switches

Quote:
Originally Posted by NegaNexus View Post
When we disable, select another mode, and re-enable the program, it runs both cases at the same time.
Why do you think both are running? If it's just because both talon and talon1 are providing outputs, notice that nothing in your code ever turns either of them off. I think what's happening is that the first selected mode turns on one of the talons, then disabling the robot "turns it off", but it'll turn right back on again when the robot is reenabled. The second selected mode does its thing, ending up with both talons on.

You should probably set both talons to zero in autonomousInit() so you have a known starting state.
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 21:13.

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