Go to Post There is beauty in pure simplicity. - artdutra04 [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 08-12-2009, 22:51
Trevor_Decker's Avatar
Trevor_Decker Trevor_Decker is offline
Registered User
AKA: Trevor Decker
FRC #3504 (Girls of Steel)
Team Role: Mentor
 
Join Date: Apr 2009
Rookie Year: 2009
Location: Pittsburgh
Posts: 42
Trevor_Decker is an unknown quantity at this point
Re: Problem Loading Java Code

Quote:
Originally Posted by aaeamdar2 View Post
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

Team 3504 - The Girls of Steel 2011 - Present
2012 Pittsburgh Regional Engineering Inspiration, and website awards
Team 1743 - The Short Circuits 2009 - 2011
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2010 Won Autodesk Animation Competition
2010,2011 Pittsburgh Team spirit award
Reply With Quote
  #2   Spotlight this post!  
Unread 08-12-2009, 22:59
Trevor_Decker's Avatar
Trevor_Decker Trevor_Decker is offline
Registered User
AKA: Trevor Decker
FRC #3504 (Girls of Steel)
Team Role: Mentor
 
Join Date: Apr 2009
Rookie Year: 2009
Location: Pittsburgh
Posts: 42
Trevor_Decker is an unknown quantity at this point
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.
__________________
- Trevor

Team 3504 - The Girls of Steel 2011 - Present
2012 Pittsburgh Regional Engineering Inspiration, and website awards
Team 1743 - The Short Circuits 2009 - 2011
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2010 Won Autodesk Animation Competition
2010,2011 Pittsburgh Team spirit award
Reply With Quote
  #3   Spotlight this post!  
Unread 08-12-2009, 23:19
EHaskins EHaskins is offline
Needs to change his user title.
AKA: Eric Haskins
no team (CARD #6 (SCOE))
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Elkhorn, WI USA
Posts: 998
EHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond repute
Send a message via MSN to EHaskins
Re: Problem Loading Java Code

Quote:
Originally Posted by Trevor_Decker View Post
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.
__________________
Eric Haskins KC9JVH
Reply With Quote
  #4   Spotlight this post!  
Unread 09-12-2009, 02:00
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

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?
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
problems loading code with Easy C Clayton Programming 1 31-01-2008 15:15
Loading Code Onto 2005 RC chris31 Programming 13 08-11-2006 07:45
Ways to speed up code loading process? Makubesu Programming 10 21-01-2006 17:23
Java headache problem MisterX Programming 8 30-03-2005 11:09
problem loading code with ifi loader psych0gambit Programming 7 25-02-2005 20:43


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