Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Problem Loading Java Code (http://www.chiefdelphi.com/forums/showthread.php?t=79233)

Trevor_Decker 08-12-2009 22:51

Re: Problem Loading Java Code
 
Quote:

Originally Posted by aaeamdar2 (Post 886967)
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);
    }


From your post I believe it is that your tela operated function is not being called/running correctly, so why don't you try a line of code that does not require feedback, to see if that is the problem, you could just have the robot drive strait for a few seconds to test the function

for instance you could try
Code:


 public void operatorControl()
    {
       
            drivetrain.Drive(1, 0);
            Timer.delay(0.005);
 
    }


Trevor_Decker 08-12-2009 22:59

Re: Problem Loading Java Code
 
I know that we declare what port to use for the power distribution block thru out our code for example
Code:

drivetrain = new RobotDrive(1, 2);
But where do we declare what port to use for the Crio, is their a way to use a different port? In case something where to happen to the normal port.

EHaskins 08-12-2009 23:19

Re: Problem Loading Java Code
 
Quote:

Originally Posted by Trevor_Decker (Post 886979)
I know that we declare what port to use for the power distribution block thru out our code for example
Code:

drivetrain = new RobotDrive(1, 2);
But where do we declare what port to use for the Crio, is their a way to use a different port? In case something where to happen to the normal port.

Nowhere in code do you specify the power source for the motors. You specify the PWM outputs (from the digital sidecar) which the motor controllers are connected to.

The code you posted is creating a RobotDrive using Jaguar controllers on PWMs 1 and 2 on the default digital sidecar (CRIO slot 4).

If you want to use different PWM outputs you could modify it like so:

Code:

drivetrain = new RobotDrive(3, 4); //Uses PWM outputs 3 and 4.
drivetrain = new RobotDrive(1, 2, 3, 4); //Used PWMs 1 and 2 for the left drives, and 3 and 4 for the right drives.


aaeamdar2 09-12-2009 02:00

Re: Problem Loading Java Code
 
Trevor,

Your solution trouble-shoots the joystick/jaguar issue, not whether operatorControl() is being called. I might give that a try, but I'm reasonably certain I don't have 2 joysticks failing spontaneously, or 2 jaguars etc.

Ehaskins,

Got a reply on official FIRST forums (this does not mean it's correct of course) that the RobotMain() function is not the problem (and boy do I hate the casing of that method name - why did they make it look like a constructor?)

At the moment I'm most interested in examining the WatchDog angle - does anyone fully understand this and could explain to the unenlightened?

derekwhite 09-12-2009 09:14

Re: Problem Loading Java Code
 
Are you getting any text output at all to indicate that the autonomous() or operatorControl() methods are being called? Some more print statements can help here...

flyvin 28-12-2009 12:03

Re: Problem Loading Java Code
 
I am having the exact same problem with our robot. I download the code to the robot, but when I try to run it it just says watchdog where it usually says enabled. I put a print statement in the autonomous() and operatorControl() methods and it printed to the screen, so it's to that part. Then I made it print something if the trigger was pressed on the joystick and that worked too. Please help.

flyvin 28-12-2009 12:39

Re: Problem Loading Java Code
 
I figured out the problem, I disabled the watchdog in the wrong part of the code. In the getting started PDF file, it said to put it in the constructor, but that doesn't work, you have to put it in the operator control method. Hope this helps anyone else who might have this problem.

1195mentor 23-01-2010 17:04

Re: Problem Loading Java Code
 
What is the fix for the "[cRIO] Information: No user-supplied RobotMain()" problem? We are still stuck with that...
Thank you,
Chris

flyvin 23-01-2010 20:35

Re: Problem Loading Java Code
 
The "[cRIO] Information: No user-supplied RobotMain()" is not an issue. If you look at the simple robot class (the superclass), there is a method called RobtMain() with a print statment that says "Information: No user-supplied RobotMain()". If you don't override it, it will print that on the screen. The comment above the method says you only need to oeverride it if you don't want to use the operatorControl() and autonomous() methods, and just want to program them in manually.

charrisTTI 26-01-2010 23:01

Re: Problem Loading Java Code
 
Java example code is wrong. Disable the watch dog at the top of autonomous and/or operatorControl. The disable of the watchdog in the constructor is cancelled out by code in the startApp method of RobotBase which is called after the instance is created but before autonomous or driverControl is called.


All times are GMT -5. The time now is 11:17.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi