View Single Post
  #1   Spotlight this post!  
Unread 01-02-2014, 17:23
MichaelB MichaelB is offline
Registered User
FRC #3573 (The Ohms)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2011
Location: Conyers
Posts: 8
MichaelB is an unknown quantity at this point
Motors not running

This is the first year as the main programmer on the robot. Even though I think I have them written correctly, no motors are running. The code gives no errors and seems to correctly deploy onto the robot. I know that the electronics are wired correctly because when I uploaded last year's code onto the robot, they were able to spin. What am I doing wrong?

RobotMap
Code:
package edu.wpi.first.wpilibj.templates;

/**
 * The RobotMap is a mapping from the ports sensors and actuators are wired into
 * to a variable name. This provides flexibility changing wiring, makes checking
 * the wiring easier and significantly reduces the number of magic numbers
 * floating around.
 */
public class RobotMap {
    // For example to map the left and right motors, you could define the
    // following variables to use with your drivetrain subsystem.
    // public static final int leftMotor = 1;
    // public static final int rightMotor = 2;
    
    // If you are using multiple modules, make sure to define both the port
    // number and the module. For example you with a rangefinder:
    // public static final int rangefinderPort = 1;
    // public static final int rangefinderModule = 1;
    
        // Joysticks
    public static final int moveStickPort = 1;
    public static final int twistStickPort = 2;
    
    // Jaguars
    public static final int fLeftFrontMotorPort = 1;
    public static final int rLeftBackMotorPort = 2;
    public static final int fRightFrontMotorPort = 3;
    public static final int rRightBackMotorPort = 4;
    
    // Victors
    public static final int clawLeftPort = 5;
    public static final int clawRightPort = 6;
    public static final int armPort = 7;
    public static final int kickerPort = 8;
    
    // Relays
    public static final int vacuumReleasePort = 1;
    public static final int vacuumPort = 2;
    
    // Servo
    public static final int kickerReleasePort = 1;
    
    // Sensors
    public static final int ultrasonicPort = 1;
    public static final int potentiometerPort = 2;
    
    // Speeds
    public static final double clawSpeed = 0.75;
    public static final double windSpeed = 1.0;
    public static final double armSpeed = 0.01;
    
    // Times
    public static final int vacuumEvacuateTime = 50; //needs testing
    public static final int vacuumEngageTime = 20; //needs testing
    public static final int springWindTime = 500; //needs testing
    public static final int springShootTime = 20; //needs testing
    public static final int autoDriveTime = 100; //needs testing
    public static final int vacuumReleaseTime = vacuumEvacuateTime -20; //needs testing
    
    // Constants
    public static final double cameraConstant = 5.0;
    public static final double kickerReleaseNumber = 0.0; //servo release from 0 to 1
    public static final double kickerEngageNumber = 0.3; //servo release from 0 to 1
    
    // Move Buttons
    public static final int autoShootNumber = 1;
    public static final int windUpNumber = 2;
    
    // Twist Buttons
    public static final int clawsToggleNumber = 1;
    public static final int clawsReverseNumber = 2; 
    
    // Camera
    public static final boolean cameraIsEnabled = true;
}
DriveWithJoystick
Code:
package edu.wpi.first.wpilibj.templates.commands;

public class DriveWithJoystick extends CommandBase {
    public DriveWithJoystick() {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
        requires(driveTrain);
    }

    // Called just before this Command runs the first time
    protected void initialize() {
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        driveTrain.driveWithJoystick(oi.getMoveStick().getY(), oi.getMoveStick().getX(), oi.getTwistStick().getX()); //check out ewct
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return false;
    }

    // Called once after isFinished returns true
    protected void end() {
        driveTrain.drive(0, 0);
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
}
DriveTrain
Code:
package edu.wpi.first.wpilibj.templates.subsystems;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.templates.RobotMap;
import edu.wpi.first.wpilibj.templates.commands.DriveWithJoystick;

public class DriveTrain extends Subsystem {
    // Put methods for controlling this subsystem
    // here. Call these from Commands.
    
    private Jaguar leftFront = new Jaguar(RobotMap.fLeftFrontMotorPort);
    private Jaguar rightFront = new Jaguar(RobotMap.rLeftBackMotorPort);
    private Jaguar leftBack = new Jaguar(RobotMap.fRightFrontMotorPort);
    private Jaguar rightBack = new Jaguar(RobotMap.rRightBackMotorPort);
    RobotDrive driveTrain;
    
    public DriveTrain() {
        driveTrain = new RobotDrive(leftFront, rightFront, leftBack, rightBack);
        driveTrain.setSafetyEnabled(false);
    }

    public void initDefaultCommand() {
        // Set the default command for a subsystem here.
        setDefaultCommand(new DriveWithJoystick());
    }
    
    public void driveWithJoystick(double y, double x, double twist) {
        driveTrain.mecanumDrive_Polar(y,x,twist);
    }
    
    public void drive(double x, double twist){
        driveTrain.arcadeDrive(x,twist);
    }
}
Claws
Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.subsystems;

import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.templates.RobotMap;

/**
 *
 * @author The Ohms
 */

public class Claws extends Subsystem {
    // Put methods for controlling this subsystem
    // here. Call these from Commands.
    private Victor clawLeft;
    private Victor clawRight;
    private double speed;
    
    public Claws(){
        clawLeft = new Victor(RobotMap.clawLeftPort);
        clawRight = new Victor(RobotMap.clawRightPort);
        speed = RobotMap.clawSpeed;
    }
    
    public int getState(){
        return((int)clawLeft.get());
    }
    
    public void reverseClaws(){
        clawLeft.set(-clawLeft.get());
        clawRight.set(-clawRight.get());
    }
    
    public void turnOnClaws(){
        clawLeft.set(speed);
        clawRight.set(-speed);
    }
    
    public void turnOffClaws(){
        clawLeft.set(0);
        clawRight.set(0);
    }

    public void initDefaultCommand() {
        // Set the default command for a subsystem here.
        //setDefaultCommand(new MySpecialCommand());
    }
}
Reply With Quote