|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Help! Robot Not Moving Even With Connection and Code!
Hi everyone. I'm a newbie programmer for Team 2496 and so far I have this driving code for our mecanum drive robot. However, even though I connected to the robot and enabled it, moving the joystick does nothing....Is there anything wrong with the code I have made for the 2015 roboRIO? I know for a fact it should be working because it worked on our team's older practice bot with the older cRIO.
package org.usfirst.frc.team2496.robot; import edu.wpi.first.wpilibj.RobotDrive; import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.IterativeRobot; public class Robot extends IterativeRobot { RobotDrive wholeDrive = new RobotDrive(0, 1, 2, 3); Joystick stick = new Joystick(1); public void robotInit() { wholeDrive.setInvertedMotor(RobotDrive.MotorType.k FrontRight, true); wholeDrive.setInvertedMotor(RobotDrive.MotorType.k RearRight, true); } public void autonomousPeriodic() { } public void teleopPeriodic() { wholeDrive.mecanumDrive_Polar(stick.getMagnitude() * .50, -stick.getDirectionDegrees(), stick.getTwist() * .75); if(stick.getRawButton(3)) { System.out.println("Button pressed!"); } if(stick.getRawButton(4)) { System.out.println("Regular Direction: " + stick.getDirectionDegrees()); } if(stick.getRawButton(1)) { this.driveStraight(1); System.out.println("Drive Straight Activated!"); } } public void driveStraight(int joystickButton) { double stickDegrees = 0; while (stick.getRawButton(joystickButton)) { if(stick.getDirectionDegrees() < 0) stickDegrees = -90.0; else stickDegrees = 90.0; wholeDrive.mecanumDrive_Polar(stick.getMagnitude() * .60, -stickDegrees, stick.getTwist()); } System.out.println("Stick Direction: " + stick.getDirectionDegrees()); } public void testPeriodic() { } } |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|