Go to Post You know you are addicted to FIRST when you have trouble describing it because you realize it truly is way more than just a robotics competetion. - vivek16 [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 03-29-2016, 07:54 PM
aansonjr001 aansonjr001 is offline
Registered User
FRC #5432
 
Join Date: Mar 2016
Location: Gardena
Posts: 2
aansonjr001 is an unknown quantity at this point
Button assignment for specific motors

I've been having trouble trying to find out how to assign motors to buttons. In vex you could do something like.........

if(vexRT[Bn5U] == 1){
motor[left] ==127;
motor[right]==127;
}
else{
motor[left]==0;
motor[right]==0;
}'(everything probably not exact but its something like this)

so my teammate and I were trying to do the same in java for the frc programming but when we tried it, it did not work out well. We've been trying to fix it but were having trouble assigning motors(Victor, Talon, etc.) to buttons on our joystick(all motors, servos, encoders, and counters are initialized) . So if someone can help us out I will really appreciate it because it's starting to bug me since I couldn't figure it out. ^W^

This is our code now....


package org.usfirst.frc.team5432.robot;

import edu.wpi.first.wpilibj.CounterBase.EncodingType;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Servo;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.TalonSRX;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.VictorSP;
import edu.wpi.first.wpilibj.buttons.JoystickButton;

/**
* 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 {
RobotDrive myRobot;
Joystick stick;
Joystick xbox;
JoystickButton A;
JoystickButton B;
JoystickButton X;
JoystickButton Y;
JoystickButton LB;
JoystickButton RB;
JoystickButton BACK;
JoystickButton START;

int counter1 = 0;
int counter2 = 0;
int counter3 = 0;
JoystickButton button1;
JoystickButton button2;
JoystickButton button3;
JoystickButton button4;
JoystickButton button5;
JoystickButton button6;
JoystickButton button7;
JoystickButton button8;
JoystickButton button9;
JoystickButton button10;
JoystickButton button11;
JoystickButton button12;
VictorSP rightMotors;
VictorSP leftMotors;
Servo retaining;
Servo shooting;
TalonSRX arm;
Victor shooter;
Talon lift;
Talon winch;
Encoder right;
Encoder left;
Encoder shootarm;

public void roboInit() {
myRobot = new RobotDrive(0,1);
xbox = new Joystick(1);
A = new JoystickButton(xbox,1);
B = new JoystickButton(xbox,2);
X = new JoystickButton(xbox,3);
Y = new JoystickButton(xbox,4);
LB = new JoystickButton(xbox,5);
RB = new JoystickButton(xbox,6);

stick = new Joystick(0);
button1 = new JoystickButton(stick,1);
button2 = new JoystickButton(stick,2);
button3 = new JoystickButton(stick,3);
button4 = new JoystickButton(stick,4);
button5 = new JoystickButton(stick,5);
button6 = new JoystickButton(stick,6);
button7 = new JoystickButton(stick,7);
button8 = new JoystickButton(stick,8);
button9 = new JoystickButton(stick,9);
button10 = new JoystickButton(stick,10);
button11 = new JoystickButton(stick,11);
button12 = new JoystickButton(stick,12);
retaining = new Servo(9);
shooting = new Servo(8);
lift = new Talon(4);
winch = new Talon(3);
shooter = new Victor(5);
leftMotors = new VictorSP(6);
left = new Encoder(6,counter1,true, EncodingType.k1X);
rightMotors = new VictorSP(7);
right = new Encoder(7,counter2,true, EncodingType.k1X);
arm = new TalonSRX(2);
shootarm = new Encoder(2,counter3,true, EncodingType.k1X);
}

/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {

}

/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
myRobot.arcadeDrive(stick);




}

/**
* This function is called periodically during test mode
*/
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 07:28 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