|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: How do I use interrupt in Java?
And what about a Timer interrupt?
|
|
#2
|
||||
|
||||
|
Re: How do I use interrupt in Java?
In Java the simplest thing to do is create a high priority thread that runs in a loop calling sleep (or WPILibj's Timer.delay) for 25 ms.
You can also use the java.util.Timer class for more complex activities. scheduleAtFixedRate() may be something to look at. |
|
#3
|
|||
|
|||
|
Re: How do I use interrupt in Java?
The only problem is that when i call sleep, the software stops at all, so i cant move the robot while this.
Should i call inside the thread or not? |
|
#4
|
|||
|
|||
|
Re: How do I use interrupt in Java?
Quote:
Perhaps you should take a step back and explain what it is that you are trying to accomplish instead of asking how to implement the solution that you've come up with. Chances are there is a better way to accomplish it. -Joe |
|
#5
|
|||
|
|||
|
Re: How do I use interrupt in Java?
I'm trying to call a interrupt each 25ms, because i want to write my own PID control, and with this interrupt i'm acumulate the error to calc the integral.
someone here said me to use a thread, and i did it, a diferent class with with the thread, overwriting the run method. But when i try to call .sleep to wait each 25ms, it stops the intire robot. |
|
#6
|
|||
|
|||
|
Re: How do I use interrupt in Java?
Quote:
I think we would need to see the code you use to start the thread to know if you are actually running in a separate thread. Also, if you are calling out into C land, you will block the whole Java VM until you return (unless you are using the "BlockingFunction" class). |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|