Go to Post Alright, looks like we've sidetracked into "Off-Topic Land", an area I know I have to visit every so often but I am always happy to leave. - Jessica Boucher [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 30-01-2012, 21:35
-J.- -J.- is offline
Registered User
FRC #3610 (Islanders)
Team Role: Programmer
 
Join Date: Mar 2011
Rookie Year: 2011
Location: Minneapolis
Posts: 4
-J.- is an unknown quantity at this point
Problematic Java code

Hi, I'm trying to start using Java for my team. I haven't had success yet, so we're probably using LabVIEW again. Nevertheless, I'd like to know what went wrong with this 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.                                                               */
/*----------------------------------------------------------------------------*/

/*HOW (my name) CODES FOR ALL YALL
 * I like using small variables. You will see lots of chars.
 * I write my variables likeThis. That's called Pascal style, I think.
 */

package edu.wpi.first.wpilibj.templates;


//first stuff
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Jaguar;
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 IterativeRobot
 * 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 JRobot extends IterativeRobot {
    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    
    
    
    //button mappings
    
    //powers
    
    //random variables
    final boolean useSlowmo = false;
    
    
    //actual objects
    RobotDrive driveObject;
    Joystick mainPad;
    Jaguar motor1,motor2,motor3,motor4;
    public void robotInit() {
        mainPad = new Joystick(1);
        motor1 = new Jaguar(1);
        motor2 = new Jaguar(2);
        motor3 = new Jaguar(3);
        motor4 = new Jaguar(4);
        driveObject = new RobotDrive(motor1,motor2,motor4,motor3);
        //distanceMonitor = new Encoder(2,1,2,2);
        //tooEasy = new KinectStick(1);
    }

    /**
     * This function is called periodically during autonomous
     */
   
    public void disabledInit() {
        driveObject.stopMotor();
    }
    
    public void disabledContinuous() {
        //blah blah nobody cares
        Timer.delay(0.1);
    }
    
    public void disabledPeriodic() {
        //¡Nos gustan a los deportes y no nos importan a quienes lo saben!
        getWatchdog().feed();
    }
    
    public void autonomousInit() {
        
    }
    
    public void autonomousPeriodic() {
    
    }
    
    public void autonomousContinuous() {
      getWatchdog().feed();
      Timer.delay(0.1);
    }

    /**
     * This function is called periodically during operator control
     */
    
    public void teleopInit() {
        //still nothing here
    }
    
    public void teleopPeriodic() {
        
        
    }
    
    public void teleopContinuous() {
            //i use a double here so java doesn't complain about casting a float
            /*this says: is useSlowmo false? if so, halve the joysticks.
             otherwise, use full output.*/
        double slowmoMultiplier = 1;
            driveObject.mecanumDrive_Cartesian(mainPad.getX()*slowmoMultiplier,
                    mainPad.getY()*slowmoMultiplier,
                    mainPad.getTwist()*slowmoMultiplier,0.f);
            
    }
}
EDIT: There are some odd pieces of code (like slowmoMultiplier) because this is edited down from a larger chunk with more features. This is just a drivetrain test, so I removed most of that.

Last edited by -J.- : 30-01-2012 at 21:48.
Reply With Quote
 


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:47.

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