Go to Post I think that FIRST should just give up and officially recognize Chiefdelphi as the place to go for community and team resources. - Greg Needel [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 01-15-2015, 03:42 PM
DrOmni9885's Avatar
DrOmni9885 DrOmni9885 is offline
Registered User
FRC #1595 (Dragons)
Team Role: Programmer
 
Join Date: Feb 2013
Rookie Year: 2012
Location: Spokane, WA
Posts: 8
DrOmni9885 is an unknown quantity at this point
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:

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!
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 09:50 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