Go to Post Is it really that bad to ask a team to be able to do more than just drive? It's like asking a student to do more than just show up to class... - Katie_UPS [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 19-02-2014, 00:01
sthreet's Avatar
sthreet sthreet is offline
Registered User
AKA: scott threet
FRC #4692
 
Join Date: Oct 2012
Rookie Year: 2012
Location: Toutle Lake
Posts: 84
sthreet is an unknown quantity at this point
Any button other than joystick 2 making motor controlled by talon

If I use any buttons other than the joystick's 2 buttons (named them left and right, 3 and 4 don't work; 3 and 4 or 7 and 8 don't work on the gamepad, named gamepad.)

Any idea why this would happen? One direction it doesn't work at all, the other it works but goes off and on and generally moves very slowly. Also tried axis one of the gamepad.
__________________
Spoiler for gif:
Reply With Quote
  #2   Spotlight this post!  
Unread 19-02-2014, 12:04
NWChen's Avatar
NWChen NWChen is offline
Alum
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: New York City
Posts: 205
NWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to beholdNWChen is a splendid one to behold
Re: Any button other than joystick 2 making motor controlled by talon

Could you post your code?
__________________
2012 - 2015 • Team 2601

Reply With Quote
  #3   Spotlight this post!  
Unread 19-02-2014, 15:59
sthreet's Avatar
sthreet sthreet is offline
Registered User
AKA: scott threet
FRC #4692
 
Join Date: Oct 2012
Rookie Year: 2012
Location: Toutle Lake
Posts: 84
sthreet is an unknown quantity at this point
Re: Any button other than joystick 2 making motor controlled by talon

Sorry, don't know why I didn't.

Spoiler for isthisatitle?:
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.Compressor;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Watchdog;
import edu.wpi.first.wpilibj.AnalogChannel;

import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

/**
 * 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 team4692robot extends SimpleRobot 
{
    RobotDrive drive=new RobotDrive(2, 1);
    Joystick left=new Joystick(1);
    Joystick right=new Joystick(2);
    Compressor airCompressor=new Compressor(1, 1);
    Solenoid launchopen=new Solenoid(1);
    Solenoid launchclose=new Solenoid(2);
    Joystick gamepad=new Joystick(3);
    Talon winch=new Talon(3);
    Talon ballpickup=new Talon(4);
    DigitalInput winchstopper=new DigitalInput(2);
    DigitalInput winchstarter=new DigitalInput(3);
    AnalogChannel distance=new AnalogChannel(1);
    Solenoid extendor1open=new Solenoid(3);
    Solenoid extendor1close=new Solenoid(4);
    Solenoid extendor2open=new Solenoid(5);
    Solenoid extendor2close=new Solenoid(6);
    DigitalInput pistonstopper=new DigitalInput(4);
    
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    public void autonomous() 
    {
        int autotimer=0; int pistontimer=0;
        
        airCompressor.start();
        
        while(true && isAutonomous() && isEnabled())
        {
            dashboard();
            
            if(distance.getAverageVoltage()/.0098>144 && autotimer==0)
            {
                drive.tankDrive(-.5, -.5);
            }
            else if(autotimer==0)
            {
                drive.tankDrive(0, 0);
                launchopen.set(true);
                launchclose.set(false);
                autotimer++;
            }
            else if(autotimer>0 && autotimer<200)
            {
                autotimer++;
            }
            else if(autotimer==200 && pistontimer==2000)
            {
                launchopen.set(false);
                launchclose.set(true);                
                autotimer++; pistontimer++;
            }
            if(pistontimer<1000)
            {
                extendor1open.set(true);
                extendor1close.set(false);
                pistontimer++;
            }
            else if(pistontimer<2000)
            {
                extendor2open.set(true);
                extendor2close.set(false);
                pistontimer++;
            }
            
            Timer.delay(.005);
        }
    }

    /**
     * This function is called once each time the robot enters operator control.
     */
    public void operatorControl() 
    {
        boolean winching=false; 
        int launchtimer=0; int reversewincher=0;
        
        airCompressor.start();
        
        while(true && isOperatorControl() && isEnabled())
        {
            double leftpow=left.getY(); double rightpow=right.getY();
            double powermod=.3;
            if(left.getTrigger())
            {
                powermod+=.2;
            }
            if(right.getTrigger())
            {
                powermod+=.5;
            }
            leftpow*=powermod; rightpow*=powermod;
            
            drive.tankDrive(leftpow, rightpow); 
            
            if(gamepad.getRawButton(1) && winching==false && winchstarter.get())
            {
                winching=true;
                reversewincher=0;
            }
            else if(winching==true)
            {
                winch.set(1);
                if(winchstopper.get())
                {
                    winching=false;
                    winch.set(-.5);
                    reversewincher=50;
                }
            }
            if(reversewincher>0)
            {
                winch.set(-.5);
                reversewincher--;
            }
            else if(winching==false)
            {
                winch.set(0);
            }
            
            if(gamepad.getRawButton(2) && launchtimer==0 && winching==false)
            {
                launchopen.set(true);
                launchclose.set(false);
                launchtimer=200;
            }
            if(launchtimer>1)
            {
                launchtimer--;
            }
            else
            {
                launchopen.set(false);
                launchclose.set(true);
            }
            if(launchtimer==1 && !gamepad.getRawButton(2))
            {
                launchtimer--;
            }
            
            if(gamepad.getRawButton(5))
            {
                extendor1open.set(false);
                extendor1close.set(true); 
            }
            if(gamepad.getRawAxis(3)>0)
            {
                extendor1open.set(true);
                extendor1close.set(false);                 
            }
            if(gamepad.getRawButton(6))
            {
                extendor2open.set(false);
                extendor2close.set(true); 
            }
            if(gamepad.getRawAxis(3)<0)
            {
                extendor2open.set(true);
                extendor2close.set(false);                 
            }
            
            if(left.getRawButton(2))
            {
                 ballpickup.set(-1);
            }
            if(right.getRawButton(2))
            {
                ballpickup.set(1);
            }
            
            if(!right.getRawButton(2) && !left.getRawButton(2))
            {
                 ballpickup.set(0);
            }
            
            dashboard();
            
            Timer.delay(.005);
        }
    }

            
            
    /**
     * This function is called once each time the robot enters test mode.
     */
    public void test() 
    {
    
    }
    
    public void robotInit()
    {
        drive.setSafetyEnabled(false);
        Watchdog.getInstance().kill();
    }
    
    public void dashboard()
    {
        SmartDashboard.putNumber("VOLTER", distance.getAverageVoltage()/.0098);
        SmartDashboard.putBoolean("SHOOTERFAR", distance.getAverageVoltage()/.0098>52);
        SmartDashboard.putBoolean("SHOOTERNEAR", distance.getAverageVoltage()/.0098<44);
    }
}

/*
double left=y; double right=y;
if(x>0)
{
    left+=x;
}
if(x<0)
{
    right+=x;
}
drive.tankDrive(left, right);
*/


This code is working, but we want to move the buttons to run it from joysticks to the gamepad:
Code:
   
            if(left.getRawButton(2))
            {
                 ballpickup.set(-1);
            }
            if(right.getRawButton(2))
            {
                ballpickup.set(1);
            }
Tried gamepad.getRawbutton(3), and gampepad.getRawButton(4), also tried left.getRawButton(3) and left.getRawButton(4), along with just setting ballpickup to one outside of that code, and setting it to gamepad.getRawAxis(1)... ...none of that could get more than jerky movements, rapidly turning on and off.
__________________
Spoiler for gif:
Reply With Quote
  #4   Spotlight this post!  
Unread 27-02-2014, 16:21
sthreet's Avatar
sthreet sthreet is offline
Registered User
AKA: scott threet
FRC #4692
 
Join Date: Oct 2012
Rookie Year: 2012
Location: Toutle Lake
Posts: 84
sthreet is an unknown quantity at this point
Re: Any button other than joystick 2 making motor controlled by talon

UPDATE: Tried changing pwm to 5, it happens with any type of motor that I tested, it is only happening with ballpickup though, any statements of what I could be doing wrong, or information I have not provided would be nice.

EDIT: To make things stranger, setting it to a value in autonomous works perfectly fine.
__________________
Spoiler for gif:

Last edited by sthreet : 27-02-2014 at 16:37.
Reply With Quote
  #5   Spotlight this post!  
Unread 27-02-2014, 16:55
sthreet's Avatar
sthreet sthreet is offline
Registered User
AKA: scott threet
FRC #4692
 
Join Date: Oct 2012
Rookie Year: 2012
Location: Toutle Lake
Posts: 84
sthreet is an unknown quantity at this point
Re: Any button other than joystick 2 making motor controlled by talon

EDIT: I facepalm myself:

Code:
            if(!right.getRawButton(2) && !left.getRawButton(2))
            {
                 ballpickup.set(0);
            }
__________________
Spoiler for gif:
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 11:34.

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