Go to Post ... Better to treat everything like it's about to explode and be wrong than the other way round. - Bongle [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 19-03-2010, 00:13
oddboy oddboy is offline
Registered User
FRC #2186
 
Join Date: Dec 2009
Location: Centreville
Posts: 2
oddboy is an unknown quantity at this point
Code Inefficient?

Hello,

We are currently at the FIRST Robotics Regional @ Richmond/VCU. We have been getting massive lag during tele op. However, this doesn't seem to be happening during autonomous. What we were told is that our code is "bloated/inefficient/RAM hog,etc". Can some one double check this code?

Here is our code(s):

RobotTemplate:
Code:
a/*----------------------------------------------------------------------------*/
/* 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.*;
import edu.wpi.first.wpilibj.DriverStationLCD.Line;


/**a
 * 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 {

   private static Joystick dualShock = new Joystick(1);
   protected static Joystick jordansFolly = new Joystick(2);
   protected static Jaguar jag1 = new Jaguar(1);
   protected static Jaguar jag2 = new Jaguar(2);
   protected static Jaguar shooterJag = new Jaguar(3);
   protected static Victor rampMotor1 = new Victor(4);
   protected static Victor rampMotor2 = new Victor(5);
   protected static double shooterControl;
   protected static RobotDrive drive = new RobotDrive(jag1, jag2);
   // 1 for near, 2 for middle, 3 for far
   // need some way of setting
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    public void autonomous() {
      // Will hopefully be able to hit all balls if positioned in a line

     getWatchdog().setExpiration(7);
     getWatchdog().feed();
     shooterJag.set(1.0);
     jag1.set(-1.0);
     jag2.set(1.0);
     Timer.delay(1.00);
     jag1.set(0.0);
     jag2.set(0.0);
     shooterJag.set(0.0);
     getWatchdog().setExpiration(20);
     // needs code to turn pi/2 left, move 3 feet, turn back, and repeat above
     // then do again
    }
    

   public void testOutput(String s, Line l) {
        DriverStationLCD lcd = DriverStationLCD.getInstance();
        lcd.println(l, 1, s);
        lcd.updateLCD();
    }
    /**
     * This function is called once each time the robot enters operator control.
     */
    public void operatorControl() {
        getWatchdog().setEnabled(true);
        //shotDelay1.reset();
        while(true && isOperatorControl() && isEnabled())
          {
            getWatchdog().feed();
          //  Solenoid sol1 = new Solenoid(1);
          //  sol1.set(false);
            //Pneumatics.operate(dualShock, shotDelay1);
            DualShock.drive(dualShock, jag1, jag2, drive);
            shooterControl = jordansFolly.getZ()/-2.0 + 0.5;
            shooterJag.set(shooterControl);



            //THIS WORKS - ml. 2/22

            //raises or lowers ramp while joystick trigger is held down
         //Pressed returns false for some reason
            if (jordansFolly.getTrigger())
            {
                rampMotor1.set(1.0);
                rampMotor2.set(1.0);
            }
            else if (jordansFolly.getRawButton(2))
            {
                rampMotor1.set(-1.0);
                rampMotor2.set(-1.0);
            }
            else
            {
                rampMotor1.set(0.0);
                rampMotor2.set(0.0);
            }

          }
    
    }

}
Code for Logitech DualShock controller:
Code:
        /*/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.*;
import edu.wpi.first.wpilibj.DriverStationLCD.Line;


/**
 *
 * @author Robotics
 */
public class DualShock {

   protected static double left;
   protected static double right;

      public static void testOutput(String s, Line l) {
        DriverStationLCD lcd = DriverStationLCD.getInstance();
        lcd.println(l, 1, s);
        lcd.updateLCD();
    }

    public static void drive(Joystick dual, Jaguar jag1,
            Jaguar jag, RobotDrive drive)

    {


    left = dual.getRawAxis(4); // Y-axis on left stick
    right = dual.getY();
    // left is jag 3, right is jag 2
    drive.setLeftRightMotorSpeeds(left, right);
    Timer.delay(0.005);
    //pause for duration between update cycles of jaguars
    //may not be needed
    }

}
Here is the ZIP file for all the code: http://qwh9pg.blu.livefilestore.com/...e.zip?download
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems integrating CMUCAM code and IFI Default Code Windward Programming 2 06-02-2007 16:48
problems using gyro/adc code with camera default code tanstaafl Programming 7 22-01-2006 23:09
Team THRUST - Kevin's Code and Camera Code Combine Chris_Elston Programming 3 31-01-2005 22:28
WRRF Code wrapper for Innovation FIRST Code FotoPlasma Programming 0 02-02-2004 19:28


All times are GMT -5. The time now is 09:43.

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