|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Command ataching issue
Hello,
While programming our robot I struggled with three problems I coud'nt solve that are all related to ataching commands to buttens/triggers and I wondered if it is all one problem. In all three problems it did maneged to buid right but in the driver station I saw no robot code. The first problem occurred when I tryed to define a command group and atach it to a button action. The second problem was when I tryed to atach two commands to the same button (one to whileHeld and one to whenRelease). The third problem was when I tryed to define a new Trigger to the throttel of the joystick and atach to it a command whenActive. if someone knows what am I doing wrong it would be very helpfull. |
|
#2
|
||||
|
||||
|
Re: Command ataching issue
If you could post a link to your code so we could read it, that would be helpful.
|
|
#3
|
|||
|
|||
|
Re: Command ataching issue
the first problem was when I added a command group to a button action.
the command group was : Code:
public class DropAndCollect extends CommandGroup{
public DropAndCollect() {
// TODO Auto-generated constructor stub
addSequential(new DropAndCollect());
addSequential(new Collect());
}
}
Code:
public class OI {
public Joystick stick = new Joystick(0);
public Button[] btns = new Button[11];{
for (int i = 0; i < 11; i ++){
btns[i] = new JoystickButton(stick, i + 1);
}
}
public OI(){
btns[0].whileHeld(new DropAndCollect());
}
}
OI code : Code:
public class OI {
public Joystick stick = new Joystick(0);
public Button[] btns = new Button[11];{
for (int i = 0; i < 11; i ++){
btns[i] = new JoystickButton(stick, i + 1);
}
}
public OI(){
btns[0].whenPressed(new DropCollector());
btns[0].whileHeld(new Collect());
}
}
trigger code: Code:
public class ThrottleTrigger extends Trigger{
@Override
public boolean get() {
// TODO Auto-generated method stub
return Robot.oi.stick.getThrottle() > 0;
}
}
Code:
public class OI {
public Joystick stick = new Joystick(0);
public Button[] btns = new Button[11];{
for (int i = 0; i < 11; i ++){
btns[i] = new JoystickButton(stick, i + 1);
}
}
public ThrottleTrigger throttleTrigger = new ThrottleTrigger();
public OI(){
throttleTrigger.whenActive(new RaiseCollectorArm());
}
}
|
|
#4
|
||||
|
||||
|
Re: Command ataching issue
At a glance I can't see anything wrong with your code, but here are some suggestions
- If you lost communications, check your connection to the robot. Communications aren't typically dependant on the presence of robot code (although robot code that crashes very quickly combined with auto-restart causes some problems in roboRIO responsiveness from experience) - If your robot code is crashing very quickly for some reason, the driverstation usually doesn't have a chance to grab the log. Instead, open up an SSH session (with PuTTY on Windows and ssh on Linux, or whatever client you prefer) to "roborio-3211-frc.local" (default username is admin; password is blank [so hit enter directly on the prompt]) and use Code:
tail -f /home/lvuser/FRC_UserProgram.log - Try using the debugger. It will probably trigger a breakpoint on any error, so this might also allow you to see if anything's causing a crash |
|
#5
|
|||
|
|||
|
Re: Command ataching issue
Quote:
Hope this helps, Steve |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|