Go to Post Dean may have asked that every high school in America be involved with FIRST, but he never said [teams] all had to have separate high schools. - Amanda Morrison [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #12   Spotlight this post!  
Unread 17-02-2015, 16:35
BrighidKHeh's Avatar
BrighidKHeh BrighidKHeh is offline
Registered User
FRC #3871 (Trojan Robotics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2011
Location: Worthington, MN
Posts: 37
BrighidKHeh is an unknown quantity at this point
Re: No Code in Driver Station!

Robot.java:
Code:
package org.usfirst.frc.team3871.Trojans2015.robot;
import org.usfirst.frc.team3871.Trojans2015.commands.Autonomous;
import org.usfirst.frc.team3871.Trojans2015.robot.IO;
import org.usfirst.frc.team3871.Trojans2015.subsystems.DriveTrain;
import org.usfirst.frc.team3871.Trojans2015.subsystems.NoodleAndToteSystems;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;

/**
* 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 Robot extends IterativeRobot {
 public static Object NoodleAndToteSystem;
 public static Autonomous Autonomous;
 public static IO io;
 public static DriveTrain driveTrain;
 public static NoodleAndToteSystems noodleAndToteSystems;
/**
  * This function is run when the robot is first started up and should be
  * used for any initialization code.
 * @param Autonomous 
  */
 public void robotInit(Autonomous Autonomous) {
	RobotMap.init();
     driveTrain = new DriveTrain();
     noodleAndToteSystems = new NoodleAndToteSystems();
     // This MUST be here. If the OI creates Commands (which it very likely
     // will), constructing it during the construction of CommandBase (from
     // which commands extend), subsystems are not guaranteed to be
     // yet. Thus, their requires() statements may grab null pointers. Bad
     // news. Don't move it.
     io = new IO();
     // instantiate the command used for the autonomous period
     Autonomous = new Autonomous();
 }
 public void autonomousInit() {
     // schedule the autonomous command (example)
     if (Autonomous!= null) Autonomous.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.
	if (Autonomous != null) Autonomous.cancel();
 }

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

 /**
  * This function called periodically during test mode
  */
 public void testPeriodic() {
     LiveWindow.run();
 }
}

IO.java
Code:
package org.usfirst.frc.team3871.Trojans2015.robot;
//import org.usfirst.frc3871.Trojans3.commands.*;

import org.usfirst.frc.team3871.Trojans2015.commands.Autonomous;
import org.usfirst.frc.team3871.Trojans2015.commands.NoodleBottomSystem;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Sendable;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
//import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
//import edu.wpi.first.wpilibj.*;
//import edu.wpi.first.wpilibj.Joystick;
//import edu.wpi.first.wpilibj.buttons.*;
/**
* 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.
* @param <Joystick>
* @param <JoystickButton>
 * @param <limitSwitch>
*/
public class IO {
	 //// 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);
	 
	 // Another type of button you can create is a DigitalIOButton, which is
	 // a button or switch hooked up to the cypress module. These are useful if
	 // you want to build a customized operator interface.
	 // Button button = new DigitalIOButton(1);
	 
	 // 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());
	
	 public Joystick rightJoystick;
	 public JoystickButton NoodleBottomMotorsOn;
	 public JoystickButton NoodleTopMotorsOn;  
	 public Joystick ArmUpDown;
	 public Joystick leftJoystick;
	 public DigitalInput limitSwitch1;
	 public DigitalInput limitSwitch2;
	 public DigitalInput limitSwitch3;
	 public DigitalInput limitSwitch4;
	
	 public IO() {
	     rightJoystick = new Joystick(1);
	     leftJoystick = new Joystick(2);
	     NoodleBottomMotorsOn = new JoystickButton(rightJoystick, 3);
	     NoodleBottomMotorsOn.whileHeld(new NoodleBottomSystem());
	     NoodleTopMotorsOn = new JoystickButton(rightJoystick, 2);
	     ArmUpDown = new Joystick(1);
	     limitSwitch1 = new DigitalInput(1);
	     limitSwitch2 = new DigitalInput(2);
	     limitSwitch3 = new DigitalInput(3);
	     limitSwitch4 = new DigitalInput(4);
	     
	     // SmartDashboard Buttons
	     SmartDashboard.putData("Autonomous", (Sendable) new Autonomous());
	     SmartDashboard.putData("Drive With Joysticks", (Sendable) new org.usfirst.frc.team3871.Trojans2015.commands.DriveWithJoysticks());
	     SmartDashboard.putData("Noodle Bottom Motors On", (Sendable) new org.usfirst.frc.team3871.Trojans2015.commands.NoodleBottomSystem());
	     SmartDashboard.putData("Noodle Top Motors On", (Sendable) new org.usfirst.frc.team3871.Trojans2015.commands.NoodleTopSystem());
	     SmartDashboard.putData("Arm Up", (Sendable) new org.usfirst.frc.team3871.Trojans2015.commands.ArmUp());
	 }
	 public Joystick getrightJoystick() {
		return rightJoystick;
	 }      
	 /**
	  *
	  * @return
	  */
	 public Joystick getleftJoystick() {
	     return leftJoystick;
	 }
 }


RobotMap.java
Code:
package org.usfirst.frc.team3871.Trojans2015.robot;
    
import edu.wpi.first.wpilibj.*;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;

/**
 * The RobotMap is a mapping from the ports sensors and actuators are wired into
 * to a variable name. This provides flexibility changing wiring, makes checking
 * the wiring easier and significantly reduces the number of magic numbers
 * floating around.
 */
public class RobotMap {
    public static SpeedController driveTrainFrontRightMotor;
    public static SpeedController driveTrainFrontLeftMotor;
    public static RobotDrive driveTrainRobotDrive41;
    public static SpeedController toteLiftSystemArmMotor;
    public static SpeedController noodleWheel1SystemMotor;
    public static SpeedController noodleWheel2SystemMotor;
    public static SpeedController noodleWheel3SystemMotor;
    public static RobotDrive noodleBottomSystemMotor;
    public static RobotDrive noodleTopSystemMotor;
    public static SpeedController ArmMotor;

    public static void init() {
        driveTrainFrontRightMotor = new Talon(1);
	LiveWindow.addActuator("Drive Train", "Front Right Motor", (Talon) driveTrainFrontRightMotor);
        driveTrainFrontLeftMotor = new Talon(2);
	LiveWindow.addActuator("Drive Train", "Front Left Motor", (Talon) driveTrainFrontLeftMotor);
        noodleWheel1SystemMotor = new Talon(3);
        LiveWindow.addActuator("NoodleAndToteSystem", "Wheel 1 System", (Talon) noodleWheel1SystemMotor);
        noodleWheel2SystemMotor = new Jaguar(4);
        LiveWindow.addActuator("NoodleAndToteSystem", "Wheel 2 System", (Jaguar) noodleWheel2SystemMotor);
        noodleWheel3SystemMotor = new Jaguar(5);
        LiveWindow.addActuator("NoodleAndToteSystem", "Wheel 3 System", (Jaguar) noodleWheel3SystemMotor);
        ArmMotor = new Talon(6);
        LiveWindow.addActuator("NoodleAndToteSystem", "Tote Lift System", (Talon) ArmMotor);
        
        driveTrainRobotDrive41 = new RobotDrive(driveTrainFrontLeftMotor,
              driveTrainFrontRightMotor);
	
        driveTrainRobotDrive41.setSafetyEnabled(true);
        driveTrainRobotDrive41.setExpiration(0.1);
        driveTrainRobotDrive41.setSensitivity(0.5);
        driveTrainRobotDrive41.setMaxOutput(1.0);
    }
}


Build Properties
# Project specific information
package=org.usfirst.frc.team3871.robot
robot.class=${package}.Robot
simula/worlds/Geation.world.file=/usr/share/frcsimrsBotDemo.world

Last edited by BrighidKHeh : 17-02-2015 at 22:33.
Reply With Quote
 


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 22:27.

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