View Single Post
  #14   Spotlight this post!  
Unread 12-08-2009, 09:45 PM
aaeamdar2 aaeamdar2 is offline
Registered User
FRC #1893
 
Join Date: Nov 2009
Location: Baltimore
Posts: 9
aaeamdar2 is an unknown quantity at this point
Re: Problem Loading Java Code

New update:

Of note: though I disabled WatchDog in the code, it still says

"System: Watchdog"

below the team number.

I'm starting to get pretty stumped.

EDIT: It also tells me when I'm loading code:


[cRIO] Information: No user-supplied RobotMain()

Is this possibly a problem?

OK so, now I have a slightly different problem:

I fixed the aforementioned issue (thanks to all who confirmed that that's what it was) and have (as far as I know) successfully loaded code onto the robot. However, there's a minor issue: nothing happens.

I'm still working on troubleshooting this issue, and I'm not by any means tapped out, but if anyone has any suggestions, I would very much appreciate them. A few facts:

1. I have communication established between robot and DS.
2. The code is supposed to be tank-drive - I essentially copied the code in the doc.
3. Nothing happens when I activate the joysticks.

EDIT: One problem was that I had two projects running. One was blank and selected as the main project; the other had the code in it and was NOT selected as the main project. However fixing this did NOT solve the problem (frowny face).


Here's my 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.*;
import edu.wpi.first.wpilibj.DriverStation.*;
import edu.wpi.first.wpilibj.camera.*;


/**
 * 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 is all SANDBOX code.
    public static final boolean PRESSED = true;
    public static final boolean UNPRESSED = false;

    Joystick j1;
    Joystick j2;
    RobotDrive drivetrain;
    Compressor comp;
    DriverStation ds;

    Accelerometer a;
    DigitalInput bump;
    AxisCamera cam;
    Timer t;
    Gyro robotHeadingGyro;



    public RobotTemplate()
    {
        comp = new Compressor(1, 1);
        j1 = new Joystick (1);
        j2 = new Joystick (2);
        drivetrain = new RobotDrive (1, 2);
        this.getWatchdog().setEnabled(false);
        
        ds = DriverStation.getInstance();
        /*
        robotHeadingGyro = new Gyro (1);
        a = new Accelerometer(2);
        bump = new DigitalInput(1);

        if (bump.get())
        {
            System.out.println("oh no cap'n we've been bumped");
        }
         */
    }


    
    /**
     * This function is called once each time the robot enters autonomous mode.
     */
    public void autonomous()
    {
        Alliance a = ds.getAlliance();
        if (a.equals(Alliance.kBlue))
        {
            System.out.println("we're blue");

        }
        else
        {
            System.out.println("we're red");
        }

        while (this.isAutonomous() && this.isEnabled())
        {
            double voltage = ds.getBatteryVoltage();
            System.out.println(voltage);
            if (voltage < 10.0)
            {
                break;
            }
        }
    }

    /**
     * This function is called once each time the robot enters operator control.
     */
    public void operatorControl() 
    {
        while (this.isEnabled() && this.isOperatorControl())
        {
            drivetrain.tankDrive(j1, j2);
            Timer.delay(0.005);
        }
    }

    private void driveStraight(double speed, Gyro g)
    {
        double d = g.getAngle();
        d = d / 360.0;
        if (d > 1.0)
        {
            d = 1.0;
        }
        if (d < -1.0)
        {
            d = -1.0;
        }
        drivetrain.drive (speed, d);
    }
Reply With Quote