Go to Post We have not always been a winning team but we have always tried to be a quality team. - WynS [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 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
  #2   Spotlight this post!  
Unread 08-02-2014, 10:50
OwenVanTiem OwenVanTiem is offline
Code Monkey
FRC #0453 (Rock Em Sock Em Robotics)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Michigan
Posts: 5
OwenVanTiem is an unknown quantity at this point
Re: Motors not running

The mistake you made is very subtle and easy to miss. In your RobotDrive object, you gave it the arguments (frontleft, frontright, rearleft, rearright), but when using a 4 motor configuration, you have to give it (frontleft, rearleft, frontright, rearright). Try structuring it like that and it should work.
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 09:30.

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