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!