Go to Post Let's not speak without knowing the "facts." If you say something please have valid reasonings behind it. =) - Arefin Bari [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
  #1   Spotlight this post!  
Unread 22-02-2016, 16:33
Heber Hooper's Avatar
Heber Hooper Heber Hooper is offline
Rocktaπ Inkling
AKA: Heber Hooper
FRC #6051 (Rocktaπ)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2016
Location: Converse
Posts: 25
Heber Hooper is an unknown quantity at this point
Exclamation Will this code successfully run my robot as a tank drive also a single forward camera

and quite possibly an intake if at all possible all posts should be to tell me yes or no and if no what to do to fix it so that my team can be almost done.


package org.usfirst.frc.team6051.robot;

import com.ni.vision.NIVision;
import com.ni.vision.NIVision.Image;

import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Timer;
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 {
private static final int Intake = 0;
RobotDrive myRobot;
Joystick stick;
int autoLoopCounter;
private Joystick leftstick;
private Joystick rightstick;
private GenericHID leftStick;
private GenericHID rightStick;
private Talon frontright;
private Talon frontleft;
private Talon rearright;
private Talon rearleft;
int currSession;
int sessionfront;
Image frame;

/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {
myRobot = new RobotDrive(0,1,2,3);
setLeftstick(new Joystick(0));
setRightstick(new Joystick(1));
frontright = new Talon(1);
frontright.set(.5);
frontleft = new Talon(2);
frontleft.set(.5);
rearright = new Talon(3);
rearright.set(.5);
rearleft = new Talon(4);
rearleft.set(.5);
frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_ RGB, 0);

sessionfront = NIVision.IMAQdxOpenCamera("cam1", NIVision.IMAQdxCameraControlMode.CameraControlMode Controller);

currSession = sessionfront;

NIVision.IMAQdxConfigureGrab(currSession);
}

/**
* This function is run once each time the robot enters autonomous mode
*/
public void autonomousInit() {
autoLoopCounter = 0;
myRobot.drive(0.5, 0.0);
}

/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
if(autoLoopCounter < 100) //Check if we've completed 100 loops (approximately 2 seconds)
{
myRobot.drive(0.5, 0.0); // drive forwards half speed
autoLoopCounter++;
} else {
myRobot.drive(0.0, 0.0); // stop robot
}
}

/**
* This function is called once each time the robot enters tele-operated mode
*/
public void teleopInit(){
}

/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
myRobot.setSafetyEnabled(true);
while (isOperatorControl() && isEnabled()) {
myRobot.tankDrive(leftStick, rightStick);
System.out.println(leftStick.getY());
System.out.println(rightStick.getY());
leftStick.getRawAxis(0);
Timer.delay(0.005) ;
LiveWindow.run();
rightStick.getPOV(Intake);
}}


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

public Joystick getLeftstick() {
return leftstick;
}

public void setLeftstick(Joystick leftstick) {
this.leftstick = leftstick;
}

public Joystick getRightstick() {
return rightstick;
}

public void setRightstick(Joystick rightstick) {
this.rightstick = rightstick;
}

}

Last edited by Heber Hooper : 22-02-2016 at 16:35. Reason: To add the code
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 08:35.

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