Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Command ataching issue (http://www.chiefdelphi.com/forums/showthread.php?t=149316)

yedidya03 07-08-2016 11:24 AM

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.

euhlmann 07-08-2016 01:23 PM

Re: Command ataching issue
 
If you could post a link to your code so we could read it, that would be helpful.

yedidya03 07-09-2016 04:09 PM

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());
        }
       
}

the OI was :
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());
    }
}

the second problem was when trying to have 2 commands at different actions of a button (in this case I also had no communication)

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());
    }
}

the third problem was when I tried to define a trigger and run a command with it.

trigger code:
Code:

public class ThrottleTrigger extends Trigger{

        @Override
        public boolean get() {
                // TODO Auto-generated method stub
                return Robot.oi.stick.getThrottle() > 0;
        }

}

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 ThrottleTrigger throttleTrigger = new ThrottleTrigger();
       
    public OI(){
            throttleTrigger.whenActive(new RaiseCollectorArm());
    }
}

if someone knows why is that happening it will be very helpful.

euhlmann 07-09-2016 11:32 PM

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
This might allow you to catch some stack trace you're not seeing

- 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

Waz 07-11-2016 02:00 PM

Re: Command ataching issue
 
Quote:

Originally Posted by yedidya03 (Post 1596030)
...
the command group was :
Code:

public class DropAndCollect extends CommandGroup{

        public DropAndCollect() {
                // TODO Auto-generated constructor stub
                addSequential(new DropAndCollect());
                addSequential(new Collect());
        }
       
}

...

The first addSequential is using the wrong class. As you have it, it will result in an infinite loop creating many nested DropAndCollect instances.

Hope this helps,
Steve


All times are GMT -5. The time now is 08:20 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi