Arcade drive/Talon controller problems

Currently I’m still testing my program on a test bed which we have assembled that has 4 motors. Right now I have my program set up so that it initializes the robot with only two motors in its drive base and the other two for testing purposes. In our teleop stage I want to programmatically set it up so that when the A button on the controller is pressed one motor moves for a certain amount of time then stops so that the whole movement is automated. However, right now though the mechanism is supposedly programmatically working, the motors that are moving are the ones that I initialized as drive train motors (and the arcade drive doesn’t work). Below is my code:


#include "WPILib.h"
#include "Timer.h"

class Robot: public IterativeRobot
{

	RobotDrive dragonBot; // robot drive system
	Joystick stick; // only joystick
	LiveWindow *lw;
	Talon l_motor;
	PowerDistributionPanel m_pdp;
	int autoLoopCounter;
	Timer autoTimer, raisingTimer;
	bool isButtonForRaisingPressed;

public:
	Robot() :
		dragonBot(0, 1),	// these must be initialized in the same order
		stick(0),		// as they are declared above.
		lw(NULL),
		l_motor(3),
		autoLoopCounter(0),
		autoTimer(),
		raisingTimer(),
		isButtonForRaisingPressed()
	{
		dragonBot.SetExpiration(0.1);
	}

private:
	void RobotInit()
	{
		lw = LiveWindow::GetInstance();
		autoTimer.Reset();
		raisingTimer.Reset();
	}

	void AutonomousInit()
	{
		autoLoopCounter = 0;
	}

	void AutonomousPeriodic()
	{
		if(autoLoopCounter <= 1) {
			autoTimer.Start();
			autoLoopCounter++;
		} else {
			double autoTime = autoTimer.Get();
			if(autoTime < 2) //Check if we've completed 100 loops (approximately 2 seconds)
			{
				dragonBot.Drive(-1.0, 0.0);
			}
			else if(autoTime >= 2 && autoTime <= 5) {
				dragonBot.Drive(0.25, 0.0);
			}
			else {
				dragonBot.Drive(0.0, 0.0);
				autoTimer.Stop();
			}
			SmartDashboard::PutNumber("elapsed time", autoTime);
			SmartDashboard::PutNumber("Current Left front", m_pdp.GetCurrent(0));
			SmartDashboard::PutNumber("Current Right Front", m_pdp.GetCurrent(1));
		}
	}

	void TeleopInit()
	{
		autoTimer.Reset();
		raisingTimer.Reset();
	}

	void TeleopPeriodic()
	{
		dragonBot.ArcadeDrive(stick);
		SmartDashboard::PutBoolean("is button for raising pressed?", isButtonForRaisingPressed);
		if(stick.GetRawButton(1)) {
			isButtonForRaisingPressed = true;
			raisingTimer.Start();
		}
		else {
			double raisingTime = raisingTimer.Get();
			if(isButtonForRaisingPressed == true && raisingTime <= 4) {
				l_motor(1.0);
			}
			else {
				l_motor(0.0);
				raisingTimer.Stop();
				raisingTimer.Reset();
				isButtonForRaisingPressed = false;
			}
			SmartDashboard::PutNumber("Voltage", m_pdp.GetVoltage());
		}
	}

	void TestPeriodic()
	{
		lw->Run();
	}
};

START_ROBOT_CLASS(Robot);

Additionally, on the l_motor(1.0) and l_motor(0.0) lines eclipse gives me and error that says “no match to call to ‘(Talon)(double’”. I’d appreciate any help and in the meantime I will try to figure out why the motors are not working correctly. Thanks!

First of all, the l_motor(1.0) call doesn’t work because to drive the motor, you need to use the set function: l_motor.Set(1.0). What you have is meaningless, as l_motor is an object, not a function.

As for the arcade drive, I would try first using the ArcadeDrive function with constant inputs (ie ArcadeDrive(1.0, 0.0) ) and see what happens. That way you know the issue isn’t with your joystick. It looks like you’re using Talons for everything, but if the drive motors aren’t talons then the way you initialized dragonBot won’t work.

For testing purposes, don’t bother with all the loops and timing; just try to run the motor if the button is pressed. The more complicated the code, the harder it is to find what’s wrong.

Thanks, figured out the l_motor.Set part today and will create a simple testing program tomorrow.