|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
We would like to be able to press a button in the joystick, and that for example if the joystick was controlling motor 1, it would control motor 2.
Thanks in advance. Last edited by PredaFran : 07-02-2015 at 22:36. |
|
#2
|
|||
|
|||
|
Re: Help with toggle-button
My team does type of action for our dual acting solenoid.
Code:
bool isReady;
bool Piston;
isReady = true;
Piston = false;
if (DriverJoyStick.GetTrigger() && isReady && !Piston){
Piston = true;
isReady = false;
} else if (DriverJoyStick.GetTrigger() && isReady && Piston {
Piston = false;
isReady = false;
} else if (!DriverJoyStick.GetTrigger()){
isReady = true;
}
Code:
if(Piston){
piston.Set(Relay::kForward);
} else if (!Piston){
piston.Set(Relay::kReverse);
}
|
|
#3
|
|||
|
|||
|
Re: Help with toggle-button
Could you give me more info about it? or a simpler version using two motors only?
Thanks in advance |
|
#4
|
|||
|
|||
|
Re: Help with toggle-button
All you would have to change is this part of the code assuming you keep Booleons named the same:
Code:
if(Piston){
piston.Set(Relay::kForward);
} else if (!Piston){
piston.Set(Relay::kReverse);
}
Code:
if(Piston){
Talon1.Set(Stick.GetY()); // Where as the talon1 would be controlled by the Y axis of the Joystick
} else if (!Piston){
Talon2.Set(Stick.GetY());// Where as another talon, talon2, would be controlled by the Y axis of the Joystick
}
|
|
#5
|
|||
|
|||
|
Re: Help with toggle-button
i have this code so far, i cant get it to work, any idea of what could be wrong?
Code:
#include "WPILib.h"
class Robot: public SampleRobot
{
bool Piston;
Joystick stick; // joystick
Piston = false;
Talon m_motor1;
Talon m_motor2;
public:
Robot() :
m_motor1(1),
stick(0)
}
{
myRobot.SetExpiration(0.1);
}
if(Piston){
m_motor1.Set(Stick.GetY()); // Where as the talon1 would be controlled by the Y axis of the Joystick
} else if (!Piston){
m_motor2.Set(Stick.GetY());// Where as another talon, talon2, would be controlled by the Y axis of the Joystick
}
};
START_ROBOT_CLASS(Robot);
|
|
#6
|
|||||
|
|||||
|
Re: Help with toggle-button
You left out the part where you read the joystick button and set the flag you're calling Piston. It's always going to be false.
|
|
#7
|
|||
|
|||
|
Re: Help with toggle-button
could you give me a hand with it? im still new in the field of c++ robotics.
Thanks in advance |
|
#8
|
|||||
|
|||||
|
Re: Help with toggle-button
tomy's first reply to you gave the toggle code you are looking for.
|
|
#9
|
|||
|
|||
|
Re: Help with toggle-button
thanks for the reply, but i dont quite get what im supposed to do
Thanks in advance |
|
#10
|
|||||
|
|||||
|
Re: Help with toggle-button
I'm not skilled enough with C++ to help you in this kind of back-and-forth forum posting. It seems likely that your level of understanding is such that you would be best served by someone helping you in person. Do you know any other teams in the Long Beach area?
|
|
#11
|
|||
|
|||
|
Re: Help with toggle-button
Unfortunately, I don't thanks for the help tho
Any thing you think i should read to get more informed in the subject or another place to get help from are appreciated |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|