Go to Post Do I think the bar is too high? I think impossible dreams and lofty goals are a key part of FIRST; the "top" being extremely far away only pushes people farther. - Chris is me [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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 17-03-2014, 13:34
Team1605 Team1605 is offline
Registered User
FRC #1605
 
Join Date: Feb 2012
Location: toronto
Posts: 30
Team1605 is an unknown quantity at this point
Coding

Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.*;
import edu.wpi.first.wpilibj.Joystick; 
import edu.wpi.first.wpilibj.RobotDrive; 
import edu.wpi.first.wpilibj.SimpleRobot; 
import edu.wpi.first.wpilibj.Timer; 



/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the SimpleRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class Team1605 extends SimpleRobot {
    
    
    Joystick stickDriverLeft = new Joystick(1);
    Joystick stickDriverRight = new Joystick(2);
    
    //remeber to switch jag port values for original robot
    Jaguar leftMotor = new Jaguar(2);
    Jaguar rightMotor = new Jaguar(1);
    Jaguar shooter = new Jaguar(3);
    //Victor gatherer = new Victor(4); 
    //Victor bridgeHandMotor = new Victor(6);
    
    RobotDrive robotDrive = new RobotDrive(leftMotor,rightMotor);
    
   
    
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    public void autonomous() {
        robotDrive.setSafetyEnabled(false);
        robotDrive.drive(-0.35,0.0);//drive at 35% speed 0% turn
        Timer.delay(1.0);//wait 1 second
        robotDrive.drive(0.0, 0.0);//stop
        Timer.delay(1.0);//wait 1 second
        shooter.set(1.0);//full spped shoots
        Timer.delay(1.0);//wait one second
        shooter.set(0.0);//stop shooter
        Timer.delay(7.0);// wait 7 seconds

        //robotDrive.drive(0.5,0.0);//drive at 50% speed 0% turn
        //Timer.delay(5.0);//wait 5 seconds
        //robotDrive.drive(0.0,0.0);//stop
        //Timer.delay(10.0);// wait 10 seconds
        
        //leftMotor.set(-1);
        //yrightMotor.set(1);
        //Timer.delay(15);
        //leftMotor.set(0);
        //rightMotor.set(0);
        //Timer.delay(3);
        
        
        
    }

    /**
     * This function is called once each time the robot enters operator control.
     */
    public void operatorControl() {
      while(isOperatorControl() && isEnabled())
    {
        
    
     robotDrive.tankDrive(stickDriverLeft.getAxis(Joystick.AxisType.kY), stickDriverRight.getAxis(Joystick.AxisType.kY));
    
        
       
        if(stickDriverRight.getButton(Joystick.ButtonType.kTrigger)) {
           shooter.set(1);
        }
        else {
            shooter.set(0);
        }
        
        
        if(stickDriverLeft.getButton(Joystick.ButtonType.kTrigger)) {
            shooter.set(-0.5);
            
        }
        else {
            shooter.set(0);
            
        }
       
       // bridgeHandMotor.set(stickDriverLeft.getAxis(Joystick.AxisType.kY)); 
               
        
        Timer.delay(.01);
    }

    }
}
can someone check if my programming for the shooter is correct...
Reply With Quote
  #2   Spotlight this post!  
Unread 17-03-2014, 13:37
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
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,717
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: Coding

Quote:
Originally Posted by Team1605 View Post
Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.*;
import edu.wpi.first.wpilibj.Joystick; 
import edu.wpi.first.wpilibj.RobotDrive; 
import edu.wpi.first.wpilibj.SimpleRobot; 
import edu.wpi.first.wpilibj.Timer; 



/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the SimpleRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class Team1605 extends SimpleRobot {
    
    
    Joystick stickDriverLeft = new Joystick(1);
    Joystick stickDriverRight = new Joystick(2);
    
    //remeber to switch jag port values for original robot
    Jaguar leftMotor = new Jaguar(2);
    Jaguar rightMotor = new Jaguar(1);
    Jaguar shooter = new Jaguar(3);
    //Victor gatherer = new Victor(4); 
    //Victor bridgeHandMotor = new Victor(6);
    
    RobotDrive robotDrive = new RobotDrive(leftMotor,rightMotor);
    
   
    
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    public void autonomous() {
        robotDrive.setSafetyEnabled(false);
        robotDrive.drive(-0.35,0.0);//drive at 35% speed 0% turn
        Timer.delay(1.0);//wait 1 second
        robotDrive.drive(0.0, 0.0);//stop
        Timer.delay(1.0);//wait 1 second
        shooter.set(1.0);//full spped shoots
        Timer.delay(1.0);//wait one second
        shooter.set(0.0);//stop shooter
        Timer.delay(7.0);// wait 7 seconds

        //robotDrive.drive(0.5,0.0);//drive at 50% speed 0% turn
        //Timer.delay(5.0);//wait 5 seconds
        //robotDrive.drive(0.0,0.0);//stop
        //Timer.delay(10.0);// wait 10 seconds
        
        //leftMotor.set(-1);
        //yrightMotor.set(1);
        //Timer.delay(15);
        //leftMotor.set(0);
        //rightMotor.set(0);
        //Timer.delay(3);
        
        
        
    }

    /**
     * This function is called once each time the robot enters operator control.
     */
    public void operatorControl() {
      while(isOperatorControl() && isEnabled())
    {
        
    
     robotDrive.tankDrive(stickDriverLeft.getAxis(Joystick.AxisType.kY), stickDriverRight.getAxis(Joystick.AxisType.kY));
    
        
       
        if(stickDriverRight.getButton(Joystick.ButtonType.kTrigger)) {
           shooter.set(1);
        }
        else {
            shooter.set(0);
        }
        
        
        if(stickDriverLeft.getButton(Joystick.ButtonType.kTrigger)) {
            shooter.set(-0.5);
            
        }
        else {
            shooter.set(0);
            
        }
       
       // bridgeHandMotor.set(stickDriverLeft.getAxis(Joystick.AxisType.kY)); 
               
        
        Timer.delay(.01);
    }

    }
}
can someone check if my programming for the shooter is correct...
What are you expecting the shooter to do?

From what I'm reading the robot will:
Drive forward at 35% speed for 1 second.
Wait one second.
Turn on the shooter motor at full speed for one second.
Wait 7 seconds.

Without knowing what your shooter is I can't really tell you if it is correct or not.
Reply With Quote
  #3   Spotlight this post!  
Unread 17-03-2014, 14:12
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: Coding

Your teleop shooter is wrong, it should be like this

if(condition1)
shooter.set(speed)
else if(condition2)
shooter.set(otherspeed)
else
shooter.set(0)
endif

the way you have it up is

if(condition1)
shooter.set(speed)
else
shooter.set(0)
endif

if(condition2)
shooter.set(other)
else
shooter.set(0)
endif

If conditon1 is met, it will still be 0 because the second time around, its setting it to 0

Last edited by Arhowk : 17-03-2014 at 14:14.
Reply With Quote
  #4   Spotlight this post!  
Unread 17-03-2014, 15:56
Team1605 Team1605 is offline
Registered User
FRC #1605
 
Join Date: Feb 2012
Location: toronto
Posts: 30
Team1605 is an unknown quantity at this point
Re: Coding

Quote:
Without knowing what your shooter is I can't really tell you if it is correct or not.
the shooter is pretty much a kicker which is driven by a motor. for now i am trying to make it move.
Reply With Quote
  #5   Spotlight this post!  
Unread 17-03-2014, 15:57
Team1605 Team1605 is offline
Registered User
FRC #1605
 
Join Date: Feb 2012
Location: toronto
Posts: 30
Team1605 is an unknown quantity at this point
Re: Coding

Quote:
Originally Posted by Arhowk View Post
Your teleop shooter is wrong, it should be like this

if(condition1)
shooter.set(speed)
else if(condition2)
shooter.set(otherspeed)
else
shooter.set(0)
endif

the way you have it up is

if(condition1)
shooter.set(speed)
else
shooter.set(0)
endif

if(condition2)
shooter.set(other)
else
shooter.set(0)
endif

If conditon1 is met, it will still be 0 because the second time around, its setting it to 0
i tried it but the shooter still doesn't work...
Reply With Quote
  #6   Spotlight this post!  
Unread 18-03-2014, 08:01
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
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,717
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: Coding

Quote:
Originally Posted by Team1605 View Post
i tried it but the shooter still doesn't work...
What are the lights on the motor controller doing when you press the button?
Reply With Quote
  #7   Spotlight this post!  
Unread 18-03-2014, 18:40
cogbrained3244 cogbrained3244 is offline
Registered User
FRC #3244
 
Join Date: Nov 2012
Location: St.Cloud MN
Posts: 5
cogbrained3244 is an unknown quantity at this point
Re: Coding

I want to make sure that you understand what Arhowk is trying to say, and make sure you made the change correctly. Your if-else statements are sending conflicting signals to the motor controllers. The Java Virtual Machine (JVM) will evaluate the two if statements separately the way you have them written. The first one will be evaluated, and send either a full-speed signal or stop motion signal. Then the second one will be evaluated, sending either a half-speed signal or a stop signal. This results in several possible combinations such as full-speed and zero, half-speed and zero, or full-speed and half-speed. The usual result of the first two is a jumpy motion where the movement stops and then starts again, especially if the button is held down.

Combining the code to have an else-if statement should prevent that paticular kind of jumpy motion. An else-if statement is evaluated as one statement, and will therefore only set your motor to one speed, rather than trying to set it to two speeds at once.

The code for an else-if statement would look like this:
Code:
 if(stickDriverRight.getButton(Joystick.ButtonType.kTrigger)) {
           shooter.set(1);
        }
        else if(stickDriverLeft.getButton(Joystick.ButtonType.kTrigger)) {
            shooter.set(-0.5);
        }
        else {
            shooter.set(0);
        }
It should replace, quite precisely, this block of code:
Code:
 if(stickDriverRight.getButton(Joystick.ButtonType.kTrigger)) {
           shooter.set(1);
        }
        else {
            shooter.set(0);
        }
        
        
        if(stickDriverLeft.getButton(Joystick.ButtonType.kTrigger)) {
            shooter.set(-0.5);
            
        }
        else {
            shooter.set(0);
            
        }
That's the only thing visibly wrong with your teleop code-I've seen this problem exactly with a claw we were working on during build, and experienced the jumpy motion I described earlier. The only other things that I could think of to check are trying different parameters for the .getButton method, in case the one you're using doesn't work (it might be perfectly valid but I've never used it before), and running through wiring debugs.

Also, the more details you give us on what you're looking to do and the problems you're having, the more we can help
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 22:38.

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