Program Issues

We are having issues with our robot code. There are no errors on vs code but it is saying that the differential drive is not being updated often enough on the driver station. Please help us.

Capture

Can’t really help you without seeing your code. You are likely overrunning the 20ms loop based on the error message.

Hard to know without seeing how your robot is setup.

MAIN

// RobotBuilder Version: 2.0
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// Java from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.

package org.usfirst.frc7309.Talon2;

import edu.wpi.first.wpilibj.RobotBase;

/**

  • Do NOT add any static variables to this class, or any initialization at all.
  • Unless you know what you are doing, do not modify this file except to
  • change the parameter class to the startRobot call.
    */
    public final class Main {
    private Main() {
    }

/**

  • Main initialization function. Do not perform any initialization here.
  • If you change your main robot class, change the parameter type.

*/
public static void main(String… args) {
RobotBase.startRobot(Robot::new);
}
}

OI

// RobotBuilder Version: 2.0
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// Java from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.

package org.usfirst.frc7309.Talon2;

import edu.wpi.first.wpilibj.Joystick;

/**

  • This class is the glue that binds the controls on the physical operator

  • interface to the commands and command groups that allow control of the robot.
    */
    public class OI {
    //// CREATING BUTTONS
    // One type of button is a joystick button which is any button on a joystick.
    // You create one by telling it which joystick it’s on and which button
    // number it is.
    // Joystick stick = new Joystick(port);
    // Button button = new JoystickButton(stick, buttonNumber);

    // There are a few additional built in buttons you can use. Additionally,
    // by subclassing Button you can create custom triggers and bind those to
    // commands the same as any other Button.

    //// TRIGGERING COMMANDS WITH BUTTONS
    // Once you have a button, it’s trivial to bind it to a button in one of
    // three ways:

    // Start the command when the button is pressed and let it run the command
    // until it is finished as determined by it’s isFinished method.
    // button.whenPressed(new ExampleCommand());

    // Run the command while the button is being held down and interrupt it once
    // the button is released.
    // button.whileHeld(new ExampleCommand());

    // Start the command when the button is released and let it run the command
    // until it is finished as determined by it’s isFinished method.
    // button.whenReleased(new ExampleCommand());

    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
    public Joystick drivestick;

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS

    public OI() {
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS

     drivestick = new Joystick(0);
     
    
    
     // SmartDashboard Buttons
    
     // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
    

    }

    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=FUNCTIONS
    public Joystick getDrivestick() {
    return drivestick;
    }

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=FUNCTIONS
    }

Robot

// RobotBuilder Version: 2.0
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// Java from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.

package org.usfirst.frc7309.Talon2;

import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import org.usfirst.frc7309.Talon2.commands.;
import org.usfirst.frc7309.Talon2.subsystems.
;

/**

  • The VM is configured to automatically run this class, and to call the

  • functions corresponding to each mode, as described in the TimedRobot

  • documentation. If you change the name of this class or the package after

  • creating this project, you must also update the build.properties file in

  • the project.
    */
    public class Robot extends TimedRobot {

    Command autonomousCommand;
    SendableChooser chooser = new SendableChooser<>();

    public static OI oi;
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
    public static Subsystem1 subsystem1;

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS

    /**

    • This function is run when the robot is first started up and should be

    • used for any initialization code.
      */
      @Override
      public void robotInit() {

      // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
      subsystem1 = new Subsystem1();

      // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
      // OI must be constructed after subsystems. If the OI creates Commands
      //(which it very likely will), subsystems are not guaranteed to be
      // constructed yet. Thus, their requires() statements may grab null
      // pointers. Bad news. Don’t move it.
      oi = new OI();

      // Add commands to Autonomous Sendable Chooser
      // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS

      chooser.setDefaultOption(“Autonomous Command”, new AutonomousCommand());

      // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS
      SmartDashboard.putData(“Auto mode”, chooser);
      }

    /**

    • This function is called when the disabled button is hit.
    • You can use it to reset subsystems before shutting down.
      */
      @Override
      public void disabledInit(){

    }

    @Override
    public void disabledPeriodic() {
    Scheduler.getInstance().run();
    }

    @Override
    public void autonomousInit() {
    autonomousCommand = chooser.getSelected();
    // schedule the autonomous command (example)
    if (autonomousCommand != null) autonomousCommand.start();
    }

    /**

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

    @Override
    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.
    if (autonomousCommand != null) autonomousCommand.cancel();
    }

    /**

    • This function is called periodically during operator control
      */
      @Override
      public void teleopPeriodic() {
      Scheduler.getInstance().run();
      }
      }

subsystem (drive)

// RobotBuilder Version: 2.0
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// Java from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.

package org.usfirst.frc7309.Talon2;

import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import org.usfirst.frc7309.Talon2.commands.;
import org.usfirst.frc7309.Talon2.subsystems.
;

/**

  • The VM is configured to automatically run this class, and to call the

  • functions corresponding to each mode, as described in the TimedRobot

  • documentation. If you change the name of this class or the package after

  • creating this project, you must also update the build.properties file in

  • the project.
    */
    public class Robot extends TimedRobot {

    Command autonomousCommand;
    SendableChooser chooser = new SendableChooser<>();

    public static OI oi;
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
    public static Subsystem1 subsystem1;

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS

    /**

    • This function is run when the robot is first started up and should be

    • used for any initialization code.
      */
      @Override
      public void robotInit() {

      // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
      subsystem1 = new Subsystem1();

      // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
      // OI must be constructed after subsystems. If the OI creates Commands
      //(which it very likely will), subsystems are not guaranteed to be
      // constructed yet. Thus, their requires() statements may grab null
      // pointers. Bad news. Don’t move it.
      oi = new OI();

      // Add commands to Autonomous Sendable Chooser
      // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS

      chooser.setDefaultOption(“Autonomous Command”, new AutonomousCommand());

      // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS
      SmartDashboard.putData(“Auto mode”, chooser);
      }

    /**

    • This function is called when the disabled button is hit.
    • You can use it to reset subsystems before shutting down.
      */
      @Override
      public void disabledInit(){

    }

    @Override
    public void disabledPeriodic() {
    Scheduler.getInstance().run();
    }

    @Override
    public void autonomousInit() {
    autonomousCommand = chooser.getSelected();
    // schedule the autonomous command (example)
    if (autonomousCommand != null) autonomousCommand.start();
    }

    /**

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

    @Override
    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.
    if (autonomousCommand != null) autonomousCommand.cancel();
    }

    /**

    • This function is called periodically during operator control
      */
      @Override
      public void teleopPeriodic() {
      Scheduler.getInstance().run();
      }
      }

// RobotBuilder Version: 2.0
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// Java from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.

package org.usfirst.frc7309.Talon2.commands;
import edu.wpi.first.wpilibj.command.Command;
import org.usfirst.frc7309.Talon2.Robot;

/**
*
*/
public class Drive extends Command {

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARIABLE_DECLARATIONS

// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTOR
public Drive(double speed) {

// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=VARIABLE_SETTING
    // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES
    requires(Robot.subsystem1);

    // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES
}

// Called just before this Command runs the first time
@Override
protected void initialize() {
}

// Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
}

// Make this return true when this Command no longer needs to run execute()
@Override
protected boolean isFinished() {
    return false;
}

// Called once after isFinished returns true
@Override
protected void end() {
}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
@Override
protected void interrupted() {
}

}

It’s a bit tough to tell where everything is with the crazy formatting, do you have a github link?

Looks like your subsystem(drive) method call is sitting outside your teleop periodic, but the weird formatting also has two robots being defined, with different implementations.

What I’m seeing here wouldn’t work at all. I’m surprised it compiles if the source files match the text here on CD.

Maybe not the only thing, as it is so difficult to read around the formatting and apparently imbalanced curly braces. Anyway, it looks like all the methods of your Drive class are empty, apart from isFinished() always returning false. The execute() method in particular should be telling the drive train (or its components) what to do (direction, speed).

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.