• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can you program robots in java?  RSS feed

 
Ahmad Auada
Ranch Hand
Posts: 56
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does java compare to other languages out there when it comes to robotics?
 
Les Morgan
Rancher
Posts: 779
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The biggest problem I see with Java with anything is that it was never meant to control hardware, as such, there are better choices if you want to do low level control including hardware interfacing.
 
Steffe Wilson
Ranch Hand
Posts: 165
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Les Morgan wrote:The biggest problem I see with Java with anything is that it was never meant to control hardware

On the contrary, Java was initially conceived as a language for embedded systems ...
http://www.oracle.com/technetwork/java/javase/overview/javahistory-index-198355.html

And embedded control is the area targeted by Java ME ...
http://www.oracle.com/technetwork/java/embedded/javame/index.html
 
Les Morgan
Rancher
Posts: 779
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed you can go thought the JNI and interface to hardware, but IMO if you have to go multi lingual to do it, and the low level interface has to be written in a language like C/C++, then C/C++ is a better choice for the project to start with.

Java does not have the ability to control most hardware directly, so such, it is not a good fit for many low level applications, such as robotics.

Steffe Wilson wrote:
Les Morgan wrote:The biggest problem I see with Java with anything is that it was never meant to control hardware

On the contrary, Java was initially conceived as a language for embedded systems ...
http://www.oracle.com/technetwork/java/javase/overview/javahistory-index-198355.html

And embedded control is the area targeted by Java ME ...
http://www.oracle.com/technetwork/java/embedded/javame/index.html
 
Simon Roberts
Author
Ranch Hand
Posts: 182
9
Java Linux Netbeans IDE Scala Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It probably depends what robot you're trying to control. Quite a few "embedded" hardware controllers, e.g. Rasperry pi can be programmed in Java, they just have libraries for the purpose.

I'd also offer a different value judgement from the notion that

if you have to go multi lingual to do it, [...] then C/C++ is a better choice for the project to start with.


I would suggest that an equally reasonable judgement is to say that if you know Java, and you like the relative safety of the code you generate with it, then using it for the bulk of your solution is a good thing. If you're at all unsure about the natively hosted language, why would you propagate that across the entire project, when you can squeeze it into a smaller footprint, with easier tests, and fewer of them, to ensure you didn't break anything.

Of course, the converse--I like C++, let me at it--is also valid, but my essential point is that the bulk of a project might best be done in a language you know well, and that supports your non-functional goals (for example, not making mistakes with memory management).

$0.02
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can program a Raspberry Pi using Java. http://www.oracle.com/technetwork/articles/java/raspberrypi-1704896.html You will have to do all the robot building yourself. The Raspberry Pi is a programmable controller that can be used to control external devices

You cannot run Java on Arduino. You can however, run Java on a server running on the same network as an Arduino, and have the Java program send commands to the Arduino to control the Arduino. The Arduino is rather dumb in this scenario. It does what the server tells it to do. This is actually very powerful because the server can control tens, even hundreds of Arduino. For example, let's say you want to make a fun little butterfly robot that flies to you and greets you when you come in to the room. You can have a camera on the robot and wings, and you run software on the robot that recognizes you and tracks your location makes it fly towards you. That's fine. Except what if you want like ten of them in your room, and you want all of them to come to you and hover next to you. Now, not only do you need to put a camera on each one (which is costly), you will need to build in some sort of collision avoidance into each robot (which is difficult). This means each of them will have to figure out every other butterfly's location. Instead of this you could have one (or two) cameras hooked to the server. The server will recognize you and track your location, and tell the butterflies where to fly to. It can compute the path so they don't collide. Much easier to implement than a collision avoidance algorithm. Plus, you can do so much more. You can program the server to make them line up.. or dance.. or hide in differrent places in the room
 
Stevens Miller
Bartender
Posts: 1445
30
C++ Java Netbeans IDE Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at lejos.org for firmware that makes the Lego NXT controller run a Java Virtual Machine.
 
Stephan van Hulst
Saloon Keeper
Posts: 7973
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have actually programmed little robots and a few autonomous RC cars, using SunSPOTs. It was a lot of fun, but I wouldn't recommend it because the support is rather lacking. I'm actually not even sure if SunSPOTs are obsolete.

Anyway, the point is that yes, you can do this. Raspberry Pi was already mentioned, and I wouldn't be surprised if there are other embedded systems that support a Java ME VM.
 
Tim Holloway
Saloon Keeper
Posts: 18792
74
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A lot depends on resources. You cannot run Java on an Arduino, as mentioned, but then you also cannot run Java on an IBM System/370 Model 168 (a water-cooled mainframe circa 1980 - maximum address space size was only 16MB).

A Raspberry Pi, on the other hand, runs Java just fine. The Pi's Minecraft app is written in Java, is quite performant, and one could even argue that some of the more active resources in it are robots-in-software.

A good platform for a robot might be an Android system. Especially since robots and phone control are already pretty common.

Interfacing with hardware can be problematical. You either need a JNI library or an OS that translates specialized hardware controls to make them look more like traditional file and character I/O. Which, these days is more common than not. Most modern peripherals are smart enough that they don't need microsecond-fast micro-managing, so high-level commands suffice. Many of these devices, in fact, can be controlled via web services, so having file I/O control makes everything easier.
 
Simon Roberts
Author
Ranch Hand
Posts: 182
9
Java Linux Netbeans IDE Scala Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maximum address space size was only 16MB


16MB? Luxury! At that time, I built my first computer, which had 1KiB RAM (yes one... and in those days, we refered to is as a kB), and in the mid 1980s was working on embedded micro controllers (building "robots" actually; welding machines that layered new hard metal onto big truck camshafts, so they could be re-ground to original size rather than being tossed out). One of those had a glorious 256 bytes of RAM (to be fair, both these machines had additional ROM space for their programs, but still, probably only 4 or 8KiB

But seriously, yes, Java these days is very hungry, but that's more an artifact of the huge space available (at least comparatively) on modern machinery. We still have "smaller" versions of Java. I recall one year at JavaOne we were given a "Java Ring" which ran something like "Embedded Java" (or it might have been "JavaCard"--the marketing and terminology was always hard to keep up with, and had a total of 64KiB RAM. Today, I think the minimum requirement is more than that. Not sure how up to date this is, but it discusses Java ME. Java ME CLDC

Anyway, you try to tell kids today... OK, enough of the three Yorkshiremen sketch
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simon Roberts wrote:. . . 1KiB RAM (yes one... and in those days, we refered to is as a kB) . . .
There is a subtle difference: a kB is 1000B and a KiB is 1024B. That difference might not have been defined 30 years ago.
 
Simon Roberts
Author
Ranch Hand
Posts: 182
9
Java Linux Netbeans IDE Scala Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a subtle difference: a kB is 1000B and a KiB is 1024B

Exactly, the distinction was not considered 30 years ago. The IEC adopted KiB in 1998 [1]
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1998? That long ago?
 
Simon Roberts
Author
Ranch Hand
Posts: 182
9
Java Linux Netbeans IDE Scala Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, though I'll add that I don't think it got much traction for a long time. I'm still very lazy about using the "right" terminology. Most of the time, after all, we're just trying to give an idea of scale, not an actual measurement! I still usually get the wrong suffix anyway; I almost always say Megs when I mean Gigs, and Gigs when I mean Terabytes. The growth has been really mindblowing. Of course, part of the problem is "how come I could get a perfectly good word processor, with host execution environment, in 64K and now, I can't even find an app for my phone that doesn't run into Megabytes..."
 
Ahmad Auada
Ranch Hand
Posts: 56
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have read that I can write my code in java then cross-compile it to C using something called VBB. Do this actually work and solve the memory space issue? The raspberry pi is good but it just doesn't have as many IO pins as something like the Arduino Mega.
 
Simon Roberts
Author
Ranch Hand
Posts: 182
9
Java Linux Netbeans IDE Scala Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What, you want us to get back on topic? We were having fun reminiscing there

It looks like you can. yes:

http://www.virtualbreadboard.com/Main.aspx?TAB=VBB&doc=VBB/Articles/WhyManagedEmbedded

though I've not done it (yet... might have to try--take me back to my youth!)
 
Tim Holloway
Saloon Keeper
Posts: 18792
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahmad Auada wrote:The raspberry pi is good but it just doesn't have as many IO pins as something like the Arduino Mega.


What it has is an I/O bus. You can put "pi plate" boards on top of it just like you can with an Arduino. In fact, I think both of them can run a GPIO bus. You'll definitely find some useful extenders at places like Adafruit.

But a Pi and an Arduino combined can do awesome things.
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another option if you want a java capable single board computer like raspberry pi + lots of I/O pins + 2 onboard realtime microcontrollers (very useful for motor actuation) is Beaglebone Black.
Very useful for combining low level sensing and actuating logic with higher level capabilities like computer vision.
There are 3rd party java libraries for it with GPIO capabilities (though I subjectively prefer python + C/C++ for such boards).
 
Ahmad Auada
Ranch Hand
Posts: 56
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karthik Shiraly wrote:Another option if you want a java capable single board computer like raspberry pi + lots of I/O pins + 2 onboard realtime microcontrollers (very useful for motor actuation) is Beaglebone Black.
Very useful for combining low level sensing and actuating logic with higher level capabilities like computer vision.
There are 3rd party java libraries for it with GPIO capabilities (though I subjectively prefer python + C/C++ for such boards).


Sounds nice!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!