OK, I’m not new at the programming thing but I seem to be having one of those problems that I believe should have a simple solution. Long story short, our robot has a roller on the front. I want buttons 4, 3, and 5 on the Joystick attached to USB port 3 on the DS to control Reverse, Stop, and Forward respectively. I’m extending the IterativeRobot Class for this code. This is what I have so far:
// These lines are in the declaration
Joystick* m_rollerStick; // joystick 3 (roller)
Victor *m_roller;
int m_rollerCondition;
// These lines are in the constructor
m_roller = new Victor(4,3);
m_rollerStick = new Joystick(3);
m_rollerCondition = 0;
//These lines are in TelopPeriodic()
.
.
.
if (m_ds->GetPacketNumber() != m_priorPacketNumber) {
.
.
.
// Roller Control
if(m_rollerStick->GetRawButton(4)) m_rollerCondition = -1;
if(m_rollerStick->GetRawButton(5)) m_rollerCondition = 1;
if(m_rollerStick->GetRawButton(3)) m_rollerCondition = 0;
switch (m_rollerCondition)
{
case -1:
m_roller->Set(-1);
break;
case 1:
m_roller->Set(1);
break;
case 0:
default:
m_roller->Set(0);
break;
}
.
.
.
}
I think that I’ve pasted all of the pertinent code here so I don’t have to copy & paste (or upload) the entire file here.
By the way, I’ve also tried using the Joystick::GetY() function to just output the Y axis on the Joystick directly to the Victor::Set() like this
m_roller->Set(m_rollerStick->GetY());
However that just caused our roller to run at a forward speed just outside of the deadband. Also, I’m pretty sure that this is a programming issue since Im able to use the m_roller->Set() and m_roller->SetRaw() functions to run the roller.
Thank you all for any help that you can provide for me.