Go to Post 254 isn't just good at building their robot. They're also good at taking pictures of it. - Chickenonastick [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-14-2015, 08:22 PM
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
  #2   Spotlight this post!  
Unread 01-14-2015, 08:32 PM
Pault's Avatar
Pault Pault is offline
Registered User
FRC #0246 (Overclocked)
Team Role: College Student
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Boston
Posts: 618
Pault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond reputePault has a reputation beyond repute
Re: Help! Robot Not Moving Even With Connection and Code!

Joysticks are now zero-indexed. They probably should have made that clearer in the documentation.
Reply With Quote
  #3   Spotlight this post!  
Unread 01-14-2015, 08:33 PM
Team3266Spencer's Avatar
Team3266Spencer Team3266Spencer is offline
Team Captain and Lead Programmer
AKA: Spencer Lanman
FRC #3266 (Robots-R-US)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Richmond, Indiana
Posts: 280
Team3266Spencer is an unknown quantity at this point
Re: Help! Robot Not Moving Even With Connection and Code!

What kind of speed controllers are you using? RobotDrive defaults to Talon speed controllers.

I would also recommend removing the while loop from driveStraight. Put that code inside the if statement instead of driveStraight as teleopPeriodic is already being called periodically.

Also using [code] tags lets you share your code in a more reader-friendly style.
__________________
2012: Buckeye Regional, Queen City Regional, Human Player
2013: Queen City Regional, Buckeye Regional, Crossroads Regional
Shooter Operator
2014: Crossroads Regional, Queen City Regional
Catapult Operator
2015: Georgia Southern Classic Regional (Winner), Queen City Regional
Chainsaw Operator
Want to talk? TeamSpeak: team3266.noip.me
Reply With Quote
Reply


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 09:02 AM.

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