![]() |
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. ::rtm::
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; } } |
Re: Will this code successfully run my robot as a tank drive also a single forward ca
There is a problem in your robotInit where you allocate PWM channels 0-3 when constructing your RobotDrive object and then allowcate PWM channels 1-4 when creating your talons, try changing it to:
Code:
/**Code:
/** |
Re: Will this code successfully run my robot as a tank drive also a single forward ca
Some notes:
|
| All times are GMT -5. The time now is 07:59 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi