Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Code running slow (http://www.chiefdelphi.com/forums/showthread.php?t=113113)

gman 09-02-2013 13:44

Code running slow
 
We've set up our robot's code using java to run Jaguar motor controllers via a DriveTrain subsystem. Thing is, the DriveTrain's execute() method is only being called once every 10-15 seconds. This means that we push the joystick forward, wait a few seconds, and the wheel starts spinning, then, when we release the joystick, we have to wait another 10-15 seconds for it to update again to stop. If you need code/other information, let me know and I'll post it. Thanks in advance.

Team3266Spencer 09-02-2013 13:57

Re: Code running slow
 
What format of code are you using? The command-based?

gman 09-02-2013 14:00

Re: Code running slow
 
Yes, command-based.

Team3266Spencer 09-02-2013 14:10

Re: Code running slow
 
Have you checked to see if its a networking issue, are you losing packets?

gman 09-02-2013 14:15

Re: Code running slow
 
We put some print statements next to the command statements; they're running just as slowly on the computer, so I don't think it's a network thing. Also, he computer is wired directly to the dlink at the moment (wireless cut out for some reason). If you have other suggestions on how else to test the network, let me know and I'll try it.

Team3266Spencer 09-02-2013 14:19

Re: Code running slow
 
You don't have two driverstations open do you?
This happens sometimes when there's one open on the driver account and one open on the developer account.

gman 09-02-2013 14:57

Re: Code running slow
 
No, I even restarted the computer just to make sure. Only one driver station running. We're going to try reimaging the cRIO without the CAN drivers to see if that is having some effect.

gman 09-02-2013 15:15

Re: Code running slow
 
We tried running it without the CAN plugin, no luck, we're reimaging the entire thing.

BradAMiller 09-02-2013 16:02

Re: Code running slow
 
The commands are run by repeated calls to Scheduler.run(). Make sure that it's being called in the teleopPeriodic() or autonomousPeriodic() methods in the main robot project like this:
Code:

    public void teleopInit() {
        // This makes sure that the autonomous stops running when
        // teleop starts running. If you want the autonomous to
        // continue until interrupted by another command, remove
        // this line or comment it out.
        if (autonomousCommand != null) autonomousCommand.cancel();
    }
    /**
    * This function is called periodically during operator control
    */
    public void teleopPeriodic() {
        Scheduler.getInstance().run();
    }

Also you can verify that the commands are running by writing the Scheduler instance to the SmartDashboard as shown in this web page:
http://wpilib.screenstepslive.com/s/...and-subsystems

Brad

gman 09-02-2013 16:25

Re: Code running slow
 
We have the Scheduler.getInstance().run() in the code already. I tried the SmartDashboard thing, its says it's running. I have print statements in the execute() method, they running, but only once every 10-15 seconds.

Arhowk 09-02-2013 16:55

Re: Code running slow
 
Quote:

Originally Posted by gman (Post 1230596)
We have the Scheduler.getInstance().run() in the code already. I tried the SmartDashboard thing, its says it's running. I have print statements in the execute() method, they running, but only once every 10-15 seconds.

Try deploying a blank SimpleRobot project with a print statement in the operator control method

BradAMiller 09-02-2013 17:33

Re: Code running slow
 
Quote:

Originally Posted by gman (Post 1230596)
We have the Scheduler.getInstance().run() in the code already. I tried the SmartDashboard thing, its says it's running. I have print statements in the execute() method, they running, but only once every 10-15 seconds.

Can you put a print statement in the teleopPeriodic() method to see how often it (and Scheduler.run()) is getting called. It should be about every 20ms (50 times per second).

Brad

gman 10-02-2013 16:27

Re: Code running slow
 
We tried running a simple robot; the problem does not occur. We tried putting the print in the teleopPeriodic; it was being called about once every 10 seconds.

Mr. Lim 10-02-2013 16:39

Re: Code running slow
 
I think the issue is you are using loops in your code.

Iterative and Command based robots should NOT be using "while" or "for" loops (generally) in their code. The methods are already looped for you, and long loops will mean that any "simultaneous" commands will be put on hold until the loop is complete.

The Simple template handles looping code by interrupting it periodically, and so you won't see any issues there.

gman 10-02-2013 16:55

Re: Code running slow
 
We double checked, there are absolutely no for or while loops anywhere in the program...


All times are GMT -5. The time now is 12:54.

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