Chief Delphi

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

Sp3ctr3 11-03-2013 23:04

Running Code Problems
 
2 Attachment(s)
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

Ginto8 12-03-2013 01:16

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.

Sp3ctr3 12-03-2013 01:44

Re: Running Code Problems
 
1 Attachment(s)
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)

Ginto8 12-03-2013 15:30

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.

AlexBrinister 14-03-2013 19:23

Re: Running Code Problems
 
+1^^. You have to override those functions manually.

Alex Brinister


All times are GMT -5. The time now is 22:33.

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