Quote:
Originally Posted by nighterfighter
If you can post your entire code (or just the teleoperated part) that will help.
I imagine the problem is what Poseidon said, your Robot object's TankDrive() method is taking priority over your code.
The code that you posted SHOULD be working,(when the trigger is pressed on the joystick, the Talon moves the motor at full speed), assuming everything is initialized properly and the robot class isn't using those Talons for tank drive.
|
okay here is the whole code
Code:
/**
* Runs during test mode
*/
#include "WPILib.h"
/**
* This is a demo program showing the use of the RobotDrive class.
* The SampleRobot class is the base of a robot application that will automatically call your
* Autonomous and OperatorControl methods at the right time as controlled by the switches on
* the driver station or the field controls.
*
* WARNING: While it may look like a good choice to use for your code if you're inexperienced,
* don't. Unless you know what you are doing, complex code will be much more difficult under
* this system. Use IterativeRobot or Command-Based instead if you're new.
*/
class Robot: public SampleRobot
{
RobotDrive myRobot; // robot drive system
Joystick stick; // only joy stick
Joystick stick2;
TalonSRX talon;
TalonSRX talon2;
public:
Robot() :
myRobot(0, 1), // these must be initialized in the same order
stick(0), // as they are declared above.
stick2(1),
talon(2),
talon2(1)
{
myRobot.SetExpiration(0.1);
}
/**
* Drive left & right motors for 2 seconds then stop
*/
void Autonomous()
{
myRobot.SetSafetyEnabled(false);
myRobot.Drive(-1.0, 1.0); // drive forwards half speed
Wait(2.0); // for 2 seconds
myRobot.Drive(0.0, 0.0); // stop robot
}
/**
* Runs the motors with arcade steering.
*/
void OperatorControl()
{
myRobot.SetSafetyEnabled(true);
while (IsOperatorControl() && IsEnabled())
{
myRobot.TankDrive(stick, stick2); // drive with arcade style (use right stick)
Wait(0.005); // wait for a motor update time
talon.Get();
talon2.Get();
if(stick.GetRawButton(1)){
talon.Set(1);
}else{
talon.Set(0);
}
if(stick2.GetRawButton(1)){
talon2.Set(1);
}else{
talon2.Set(0);
}
}
}
/**
* Runs during test mode
*/
void Test()
{
}
};
START_ROBOT_CLASS(Robot);