Hi, our team is having a problem getting Victors to work together. We have 3 victors that are supposed to control different things, but will not run if another victor is enabled in the code. For example, if we have our tension control enabled in the code, it will work. If we un-comment our other routines, maybe something like the catapult launch, catapult launch won’t work, but tension control will. If we disable tension control, catapult launch will work. Each victor has worked by itself, but no two victors will run at the same time. The exception to this is that the four victors controlling the motors for driving are always working. Have any ideas?
Here’s our code. Some of it is commented out, because we were testing different things.
/----------------------------------------------------------------------------/
/* Copyright © FIRST 2008. All Rights Reserved. /
/ Open Source Software - may be modified and shared by FRC teams. The code /
/ must be accompanied by the FIRST BSD license file in the root directory of /
/ the project. /
/----------------------------------------------------------------------------*/package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.Joystick;/**
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 RobotTemplate extends IterativeRobot {
/*
- This function is run when the robot is first started up and should be
- used for any initialization code.
*/
Victor rightall = new Victor(1);
Victor leftall = new Victor(2);
Joystick joy1 = new Joystick(1);
Joystick joy2 = new Joystick(2);
double rightdrive;
double leftdrive;
Victor stickMotor = new Victor(3);
Victor tensionControl = new Victor(4);
Victor catapult = new Victor(5);
public void robotInit()
{
rightdrive = 0;
leftdrive = 0;
}
//This function is called periodically during autonomous
public void autonomousPeriodic()
{
GoForwards();
}// This function is called periodically during operator control
public void teleopPeriodic()
{
Drive();
// SlotThree();
// SlotThreeNegative();
SlotFour();
// SlotFourNegative();
SlotFive();
// SlotFiveNegative();
}
public void GoForwards()
{
rightall.set(0.2);
leftall.set(-0.2);
}
public void Drive()
{rightdrive = joy1.getY(); leftdrive = joy2.getY(); rightall.set(rightdrive/2); leftall.set(-leftdrive/2);
}
public void SlotThree()
{
double stickSpeed = 1.0;
if (joy1.getRawButton(6) == true)
stickMotor.set(stickSpeed);
else
stickMotor.set(0);
}
public void SlotThreeNegative()
{
double stickSpeed = 1.0;
if (joy1.getRawButton(9) == true)
stickMotor.set(-stickSpeed);
else
stickMotor.set(0);
}
public void SlotFour()
{
double stickspeed1 = 1.0;
if (joy1.getRawButton(7) == true)
//tensionControl.set(stickspeed1);
tensionControl.set(1.0);
else
tensionControl.set(0);
}
public void SlotFourNegative()
{
double stickspeed1 = 1.0;
if (joy1.getRawButton(10) == true)
tensionControl.set(-stickspeed1);
else
tensionControl.set(0);
}
public void SlotFive()
{if (joy1.getRawButton(8) == true) catapult.set(-1.0); else catapult.set(0);
}
public void SlotFiveNegative()
{
if (joy1.getRawButton(11) == true)
catapult.set(1.0);
else
catapult.set(0);
}/* public void SlotFour()
{
double stickspeed1 = 1.0;
if (joy1.getRawButton(7) == true)
//tensionControl.set(stickspeed1);
tensionControl.set(1.0);
else
if (joy1.getRawButton(8) == true)
catapult.set(stickspeed1);
else
{
tensionControl.set(0);
catapult.set(0);
}
if (joy1.getRawButton(7) == false && joy1.getRawButton(7) == false)
{
tensionControl.set(0);
catapult.set(0);
}
}
*//** * This function is called periodically during test mode */ public void testPeriodic() { }
}