Go to Post Because FIRST wants everyone to have a sense of accomplishment even if you didn't accomplish anything during the match. - Koko Ed [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 11-03-2013, 23:04
Sp3ctr3 Sp3ctr3 is offline
Registered User
FRC #3120
 
Join Date: Mar 2013
Location: Los Angeles
Posts: 2
Sp3ctr3 is an unknown quantity at this point
Running Code Problems

My team and I have had a lot of problems trying to get the code to run on our cRIO for our robot. Our robot is finished and testing is complete, but when we put all of the system together into one Java 'project' with a main.java class, we run into major problems. We're using a very basic main.java class with just what seems is needed. Our CommandBase class seems to be correct, although I will link it anyways. I sadly do not have the error report with me, but I will attach both the Main and CommandBase classes. Help or tips would be much appreciated in any form! Thank you! ~T
Attached Files
File Type: java Main.java (1.2 KB, 12 views)
File Type: java CommandBase.java (1.3 KB, 9 views)
Reply With Quote
  #2   Spotlight this post!  
Unread 12-03-2013, 01:16
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Running Code Problems

Your Main isn't actually implementing the IterativeRobot methods. IterativeRobot has methods like robotInit(), teleopInit(), autonomousPeriodic(), not the methods of Command. The Command-based template gives a good example IterativeRobot implementation.
__________________
I code stuff.
Reply With Quote
  #3   Spotlight this post!  
Unread 12-03-2013, 01:44
Sp3ctr3 Sp3ctr3 is offline
Registered User
FRC #3120
 
Join Date: Mar 2013
Location: Los Angeles
Posts: 2
Sp3ctr3 is an unknown quantity at this point
Re: Running Code Problems

Would this be the proper format? Or would the Iterative.teleopInt() be moved to the execute() method and the teleopPeriodic() be moved to interrupted()? Thanks! (I'm new to this sorry)
Attached Files
File Type: java Main.java (1.3 KB, 6 views)
Reply With Quote
  #4   Spotlight this post!  
Unread 12-03-2013, 15:30
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Running Code Problems

You're still treating IterativeRobot like a Command. The default command-based template provides this:
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.IterativeRobot;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.templates.commands.CommandBase;
import edu.wpi.first.wpilibj.templates.commands.ExampleCommand;

/**
 * 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 RobotTemplate extends IterativeRobot {

    Command autonomousCommand;

    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {
        // instantiate the command used for the autonomous period
        autonomousCommand = new ExampleCommand();

        // Initialize all subsystems
        CommandBase.init();
    }

    public void autonomousInit() {
        // schedule the autonomous command (example)
        autonomousCommand.start();
    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {
        Scheduler.getInstance().run();
    }

    public void teleopInit() {
	// This makes sure that the autonomous stops running when
        // teleop starts running. If you want the autonomous to 
        // continue until interrupted by another command, remove
        // this line or comment it out.
        autonomousCommand.cancel();
    }

    /**
     * This function is called periodically during operator control
     */
    public void teleopPeriodic() {
        Scheduler.getInstance().run();
    }
    
    /**
     * This function is called periodically during test mode
     */
    public void testPeriodic() {
        LiveWindow.run();
    }
}
My team has tweaked this to use the SendableChooser, as well as having a teleop command, but the basic idea is still the same.
__________________
I code stuff.
Reply With Quote
  #5   Spotlight this post!  
Unread 14-03-2013, 19:23
AlexBrinister AlexBrinister is offline
Registered User
AKA: Alex Brinister
FRC #1768 (RoboChiefs)
Team Role: Alumni
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Bolton, MA
Posts: 93
AlexBrinister will become famous soon enough
Re: Running Code Problems

+1^^. You have to override those functions manually.

Alex Brinister
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


All times are GMT -5. The time now is 12: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