View Single Post
  #4   Spotlight this post!  
Unread 18-11-2014, 18:50
weaversam8 weaversam8 is offline
Team Captain
AKA: Sam Weaver
FRC #4534 (Wired Wizards)
Team Role: Leadership
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Wilmington, North Carolina
Posts: 137
weaversam8 is a splendid one to beholdweaversam8 is a splendid one to beholdweaversam8 is a splendid one to beholdweaversam8 is a splendid one to beholdweaversam8 is a splendid one to beholdweaversam8 is a splendid one to behold
Re: Robot Spins on Start

I am our team's programmer, so I will post code, but I am certain that it is not the issue.

This code is from Ultimate Ascent, but it was our very basic rookie code.

Code:
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.Jaguar;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.camera.AxisCamera;

/**
 * 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 RobotTemplate extends SimpleRobot {
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    
    RobotDrive chassis = new RobotDrive (1, 2);
    Joystick leftStick = new Joystick(1);
    Joystick rightStick = new Joystick(2);
    Jaguar shooterMotor1 = new Jaguar(3);
    Jaguar shooterMotor2 = new Jaguar(4);
    AxisCamera camera;
    
    public void autonomous() {
        /*
        chassis.setSafetyEnabled(false);
        chassis.drive(-0.5, 0.0);
        Timer.delay(2.0);
        chassis.drive(0.0, 0.0);
        */
    }
    
    public void disabled() {
        chassis.drive(0.0, 0.0);
        
    }
    
    /**
     * This function is called once each time the robot enters operator control.
     */
    public void operatorControl() {
        chassis.setSafetyEnabled(true);
        // value from joystick's wheel
        double v1;
        camera = AxisCamera.getInstance();
        chassis.drive(0.0, 0.0);
        while (isOperatorControl() && isEnabled()) {
            
            double left = leftStick.getY();
            double right = rightStick.getY();
            
//            if (left > -.1 && left < .1)
//            {
//                left = 0;
//            }
//            if (right > -.1 && right < .1)
//            {
//                right = 0;
//            }
            
            if (right < 0)
            {
                right = -1 * right * right;
            }
            if (right > 0)
            {
                right = right * right;
            }
            
            if (left < 0)
            {
                left = -1 * left * left;
            }
            if (left > 0)
            {
                left = left * left;
            }
            
            chassis.tankDrive(left, right);
            
            // get value from the little wheel below stick
            v1 = leftStick.getRawAxis(3);
            // -1.0 is all the way up, 1.0 all the way down
            //System.out.println(v1);
            shooterMotor1.set(-v1);
            shooterMotor2.set(-v1);
            
            Timer.delay(0.01);
            
            
        }

    }
    
    /**
     * This function is called once each time the robot enters test mode.
     */
    public void test() {
        chassis.setSafetyEnabled(false);
        chassis.drive(1, 1);
        Timer.delay(2.0);
        chassis.drive(-1, -1);
        Timer.delay(2.0);
        chassis.drive(0.0, 0.0);
    }
}
The robot is disabled and PWM unplugged and it is still occurring.