|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|
#2
|
||||
|
||||
|
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.
|
|
#3
|
|||
|
|||
|
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)
|
|
#4
|
||||
|
||||
|
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();
}
}
|
|
#5
|
|||
|
|||
|
Re: Running Code Problems
+1^^. You have to override those functions manually.
Alex Brinister |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|