Go to Post For Pete's sake, don't concentrate on the entry itself... concentrate on what your team is doing to make an impact in your community. - Andy Baker [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 14-01-2015, 20:22
ZoNi7567's Avatar
ZoNi7567 ZoNi7567 is offline
Registered User
AKA: Justin
FRC #2496 (Tru Blu)
 
Join Date: Dec 2014
Rookie Year: 2013
Location: SoCal
Posts: 6
ZoNi7567 is an unknown quantity at this point
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() {

}
}
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:45.

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