Go to Post Almost fell out of my chair in the CAD room once. - ChristopherSD [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-02-2013, 13:44
gman gman is offline
Registered User
FRC #4024
 
Join Date: Jan 2013
Location: Florida
Posts: 13
gman is an unknown quantity at this point
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.
Reply With Quote
  #2   Spotlight this post!  
Unread 09-02-2013, 13:57
Team3266Spencer's Avatar
Team3266Spencer Team3266Spencer is offline
Team Captain and Lead Programmer
AKA: Spencer Lanman
FRC #3266 (Robots-R-US)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Richmond, Indiana
Posts: 280
Team3266Spencer is an unknown quantity at this point
Re: Code running slow

What format of code are you using? The command-based?
__________________
2012: Buckeye Regional, Queen City Regional, Human Player
2013: Queen City Regional, Buckeye Regional, Crossroads Regional
Shooter Operator
2014: Crossroads Regional, Queen City Regional
Catapult Operator
2015: Georgia Southern Classic Regional (Winner), Queen City Regional
Chainsaw Operator
Want to talk? TeamSpeak: team3266.noip.me
Reply With Quote
  #3   Spotlight this post!  
Unread 09-02-2013, 14:00
gman gman is offline
Registered User
FRC #4024
 
Join Date: Jan 2013
Location: Florida
Posts: 13
gman is an unknown quantity at this point
Re: Code running slow

Yes, command-based.
Reply With Quote
  #4   Spotlight this post!  
Unread 09-02-2013, 14:10
Team3266Spencer's Avatar
Team3266Spencer Team3266Spencer is offline
Team Captain and Lead Programmer
AKA: Spencer Lanman
FRC #3266 (Robots-R-US)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Richmond, Indiana
Posts: 280
Team3266Spencer is an unknown quantity at this point
Re: Code running slow

Have you checked to see if its a networking issue, are you losing packets?
__________________
2012: Buckeye Regional, Queen City Regional, Human Player
2013: Queen City Regional, Buckeye Regional, Crossroads Regional
Shooter Operator
2014: Crossroads Regional, Queen City Regional
Catapult Operator
2015: Georgia Southern Classic Regional (Winner), Queen City Regional
Chainsaw Operator
Want to talk? TeamSpeak: team3266.noip.me
Reply With Quote
  #5   Spotlight this post!  
Unread 09-02-2013, 14:15
gman gman is offline
Registered User
FRC #4024
 
Join Date: Jan 2013
Location: Florida
Posts: 13
gman is an unknown quantity at this point
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.
Reply With Quote
  #6   Spotlight this post!  
Unread 09-02-2013, 14:19
Team3266Spencer's Avatar
Team3266Spencer Team3266Spencer is offline
Team Captain and Lead Programmer
AKA: Spencer Lanman
FRC #3266 (Robots-R-US)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Richmond, Indiana
Posts: 280
Team3266Spencer is an unknown quantity at this point
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.
__________________
2012: Buckeye Regional, Queen City Regional, Human Player
2013: Queen City Regional, Buckeye Regional, Crossroads Regional
Shooter Operator
2014: Crossroads Regional, Queen City Regional
Catapult Operator
2015: Georgia Southern Classic Regional (Winner), Queen City Regional
Chainsaw Operator
Want to talk? TeamSpeak: team3266.noip.me
Reply With Quote
  #7   Spotlight this post!  
Unread 09-02-2013, 14:57
gman gman is offline
Registered User
FRC #4024
 
Join Date: Jan 2013
Location: Florida
Posts: 13
gman is an unknown quantity at this point
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.
Reply With Quote
  #8   Spotlight this post!  
Unread 09-02-2013, 15:15
gman gman is offline
Registered User
FRC #4024
 
Join Date: Jan 2013
Location: Florida
Posts: 13
gman is an unknown quantity at this point
Re: Code running slow

We tried running it without the CAN plugin, no luck, we're reimaging the entire thing.
Reply With Quote
  #9   Spotlight this post!  
Unread 09-02-2013, 16:02
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 592
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
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
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
  #10   Spotlight this post!  
Unread 09-02-2013, 16:25
gman gman is offline
Registered User
FRC #4024
 
Join Date: Jan 2013
Location: Florida
Posts: 13
gman is an unknown quantity at this point
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.
Reply With Quote
  #11   Spotlight this post!  
Unread 09-02-2013, 16:55
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 543
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Code running slow

Quote:
Originally Posted by gman View Post
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
Reply With Quote
  #12   Spotlight this post!  
Unread 09-02-2013, 17:33
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 592
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Code running slow

Quote:
Originally Posted by gman View Post
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
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
  #13   Spotlight this post!  
Unread 10-02-2013, 16:27
gman gman is offline
Registered User
FRC #4024
 
Join Date: Jan 2013
Location: Florida
Posts: 13
gman is an unknown quantity at this point
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.
Reply With Quote
  #14   Spotlight this post!  
Unread 10-02-2013, 16:39
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
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.
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
Reply With Quote
  #15   Spotlight this post!  
Unread 10-02-2013, 16:55
gman gman is offline
Registered User
FRC #4024
 
Join Date: Jan 2013
Location: Florida
Posts: 13
gman is an unknown quantity at this point
Re: Code running slow

We double checked, there are absolutely no for or while loops anywhere in the program...
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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