EV3 and threading

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

EV3 and threading

Postby ruperty » Sun Jul 13, 2014 1:14 pm

I have an application to run on the EV3 which will continuously access multiple sensors and motors, and I am wondering if I need to consider running different threads for them, rather than my current scheme of accessing them serially. That is, in each iteration I may be reading 3 sensors, reading 4 motors and writing 4 motors, do any of the methods take much significant time to return?

Any thoughts?
Regards,
Rupert
www.perceptualrobots.com
ruperty
Active User
 
Posts: 130
Joined: Sun Oct 14, 2007 11:21 am

Re: EV3 and threading

Postby gloomyandy » Sun Jul 13, 2014 3:04 pm

Why not just try it and see? Without knowing what sensor you are trying to use, and what particular motor operations it really is not possible to make any useful comment. Obviously you will need to avoid the blocking versions of the motor calls. I would always do things serially unless you find a problem, people are not good at writing multi-threaded code.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4238
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: EV3 and threading

Postby wdavies » Fri Dec 12, 2014 12:19 am

Is there a guide to multi-threading in EV3 - it seems to be something that LabView does seamlessly?

I found this for NXT, assume it can't be too different?
http://www.juanantonio.info/docs/2008/J ... EADING.pdf

Winton
wdavies
New User
 
Posts: 6
Joined: Fri Nov 14, 2014 2:16 am

Re: EV3 and threading

Postby gloomyandy » Fri Dec 12, 2014 1:44 am

There is nothing specific to the EV3 about leJOS threads, they are simply Java threads. There are many tutorials out there that describe how to use Java threads. Note however that threads can be very tricky and even very experienced Java programmers often run into problems with them. They are very powerful, but use them with care, many problems can be solved without using threads and if you are new to Java it is probably best to avoid using them until you are more familiar with the language.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4238
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: EV3 and threading

Postby esmetaman » Sat Dec 13, 2014 12:05 pm

Hi,

Andy has the reason.
It is very important to learn to develop robots with Java if you have more experience with leJOS API and later you use advanced features from the Java Language, for example multi threading.

In the PDF which I wrote some years ago, I showed classic Java Thread Features, but now exist more features to handle "Concurrency problems."
I recommend this book:
http://www.amazon.com/Java-Threads-Scott-Oaks/dp/0596007825/ref=sr_1_2?ie=UTF8&qid=1418472296&sr=8-2&keywords=java+thread&pebp=1418472303230
http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601/ref=sr_1_3?ie=UTF8&qid=1418472296&sr=8-3&keywords=java+thread&pebp=1418472315812
Juan Antonio Breña Moral
http://www.juanantonio.info/lejos-ebook/
https://github.com/jabrena/livingrobots
http://www.iloveneutrinos.com/
User avatar
esmetaman
Advanced Member
 
Posts: 311
Joined: Wed Sep 13, 2006 12:16 am
Location: Madrid, Spain


Return to EV3 Software

Who is online

Users browsing this forum: Michelle_Mouse and 2 guests

more stuff