Saturday, October 19, 2013

First leJOS EV3 program

First leJOS EV3 program

Okay, so this section isn't going to start off with a working example. But that's only because I've got something much more important to write about: A quick-fix for the ever-present microSD-card problem.

Way to get the microSD-card out again!

The original solution is found here, so all credit should go to JGeo.

sdCard Bottom
sdCard Top

Eventually I came to the conclusion that I'm not going to extract the card all that often, though. Transferring files via the wireless setup is actually pretty easy.

sdCard inserted in EV3


Actual testing

First off I tried to simply cram the required packages and classes into a shared project in order to force-feed the whole project to the EV3. In my mind it was a "quick" solution to test out the basics. In one word: Don't. I ended up wasting more time then I care to admit here.
After following the guide, I was able to actually make my EV3-leJOS work again (I broke it with my "quick" test). Setting up the development environment was pretty trivial. What did take some time, however, was upgrading my distribution of Ubuntu. Again, don't do that. 13.10 messes up all menu-related tasks for any java-program; hence my IDE (eclipse) was unusable. To keep this part of the rant to a minimal, this can be fixed with the following command (which disables the Unity-menu, and instead uses the built-in java menu for eclipse):
  1. Open up a terminal
  2. Write: "export UBUNTU_MENUPROXY=0" (this will disable said menu for anything launched from this terminal in this session. Returns to normal for any other terminal)
  3. Run eclipse: "eclipse"
Now, having fought myself though the literal jungle of obstruction in a single day, I was somewhat annoyed to get a NoClassDefFoundError when following the development guide section of the wiki. This error was mostly due to me needing a cup of coffee and the fact that I forgot to include the ev3classes project when exporting my project to the jar-file. So remember to both include the ev3classes for compile-time AND for export-time. The IDE is not smart enough to figure what might be available in a later execution environment.

Enough talk of failures, here is my amazing driving robot!


... okay, so not that impressive. But it's a running robot driven by leJOS on EV3, which was my goal all along. As far as I can see, the leJOS team seems to have ported most of the old framework (if not all?), and that at some of the sensors seem to be supported already.
Seeing as the sensors seem to be very similar to the old NXT-sensors, I would expect that most of them work. More experiments on that later on.

Saturday, October 12, 2013

Experimentations with leJOS

Experimentations with leJOS

This is a very, very brief description of my experimentation with leJOS; getting it up and running and executing the initial precompiled Hello World sample-program.

First off, I simply followed the guide located here. Below will be comments of where I deviated from the descriptions of the guide, but I recommend you take a look at the above link, as I will reference to it directly in the below text.

Hardware/software

Below is a list of hardware and software I used to get leJOS up and running on my brick-labtop setup.
  1. Labtop running Ubuntu 13.04
  2. Brick Hardware: V0.60
  3. Brick Software: V1.03E
  4. Wifi-Dongle: Netgear N150 (WNA 1100)
  5. Micro-SD Card: ScanDisk Ultra microSDHC 16 GB Android
  6. Card Reader/writer: Transcend RDF5K cardreader SDHC/XC/UHS1-
  7. Wireless router: Cisco Linksys E4200
A quick run-though of my thoughts behind each of these seem to be in order. Number 1. Ubuntu for my labtop: While it is, according to the guide, possible to simply run Linux emulated/virtually, I thought that this would simply add another layer of possible failure to my initial concerns regarding the whole operation. I see no real problem with emulating the software instead of switching operation system, but on the whole, I prefer to work with what is "natively" thought for a given software-solution. I'll continue to test all the software from LEGO on a separate Windows 8 machine, if needed.
I updated my brick fairly recently and the hardware version is simply what the brick informs me, when looking at the "brick information" menu-item of the LEGO-software interface.
The dongle was more or less an accident. I got it from somebody else who was planning to experiment with EV3, but then decided against it after purchasing the dongle. Accidentally (maybe?) it's exactly the same dongle recommended by the guide, and the only explicit model supported by the brick (though all other modes with the same chip-set should be supported as well).
The wireless router was simply what I had available to me at home. My network was set up with a WPA2 authentication, which to my pleasant surprise, was exactly the same Andy used for his guide. Nice.
The card reader was practical, and more importantly, actually in stock when I purchased the micro-SD card.
Lastly I get to the microSD card itself. This one actually took a bit of thought. The guide simply suggests any card of at least 2 Gb capacity. It says nothing about how this memory is going to be used by the brick or how much space is actually used for the leJOS system files. So more about that below!

microSD Card after leJOS
  1. 2 Partitions:
    -> Partition 1: 2 Mb of data (100% filled partition)
    -> Partition 2: ~250 Mb of data (rest of the unused space of the card)
  2. All leJOS programs are located on the card, and run from the card.
Looking at the above I'm fairly happy that I've chosen to invest in a faster-then needed card. Each microSD card has a certain classification describing read/write speed. I've chosen a card that is UHS Class 1 / Class10 (~10 Mb/s). This basically means that I can expect to be able to get read/write speeds that are better then if I had chosen a Class2 (~2 Mb/s). I have no idea how much, if at all, this is going to affect my experience with the brick, as I haven't found any documentation of how fast the brick is at reading from the card. More investigation is needed, but I have a feeling that this might be fairly relevant to the performance of the setup.

Setting up leJOS/testing

Simply following the installation-guide was enough for me. I did notice, though, that when the leJOS "welcome screen" was up there was no way to shut down the brick, except though a remote connection (for me, ssh), or by removing the battery. No need to panic, though (it did surprise me quite a bit, when I couldn't turn off the brick with the "escape" button). The brick is actually responsive though the remote connection.

Moving on, below is my first actual experiments with starting up leJOS on my brick. At first I didn't have any wifi-dongle (I had to wait a bit for that part to become available), so I tried to see if I had created the sd-card correctly under the assumption that the lack of wifi-dongle would make it quite a bit more challenging to connect to the the brick remotely.

Hardware used with brick
leJOS startup screen if no wifi-dongle is used

 Everything so far, so good. Nothing out of what I expected.
Some days later my experiments could continue, now with a wifi-dongle. This resulted in the following:

leJOS running with a wireless connection to my router

Yay. Now to test out the remote control of my now leJOS-powered brick:

Screenshot of the display seen in below video



Now that I have my hello world sample up and running, I foresee no particular difficulty in actually controlling the brick, but these experiments will probably be a bit drawn-out, as my exam period has just begun...
But I will be able to upload a post showing a running robot during the next few weeks (or a post describing a lot of problems related to getting said robot up and running).

Thursday, October 3, 2013

First experiments with the LEGO software

First experiments with the LEGO software

Developing the software for running the brick with EV3 is fairly easy. On a Windows 8 machine, I needed to install 2 things from the LEGO site. Both installed with no issue and no real difficulty. After having both of these installed I started the software and was presented with a wealth of tutorials and quick-start guides. After about 5 minutes of watching one of the relevant (for me - development) videos, I was ready to get started - or so I thought. First I had to update the Brick's firmware. This was easily accomplished in about a minute with no problems. Now I was good to go for my initial development.

Drag'n'Drop Programming. The above does nothing, but shows a few "building-blocks"
Quickly after creating a new project, I saw the above scary image: Drag'n'Drop programming. One of my dreaded enemies and a practice I loath. However, after trying it out I have to admit that LEGO actually have a pretty decent interface and that I could probably program any behavior I wanted for any given robot, with this approach. What's even more impressive, is that while the robot is hooked up to the pc, I can with the press of a key (or the big green arrow) execute the program on my brick. The uploading and execution of the program works smoothly and (for me, at least) very intuitively.
I made several small experiments involving making a wheel revolve 360 degrees, reading what the light-sensor recorded and stuff like that. Nothing worth posting, as it mostly involved connecting 2 programming components and pressing "Run".

All in all it was a much more pleasant experience then I expected upon seeing the programming interface.

Moving on from the software, I also built the robot detailed in the physical user-guide. The guide claims that you can build the robot in 45 minutes, but I guess I must either be a little slow, or it meant any given version of the robot. I spent about 1 hour to build the robot with all extensions applied to it, and only about 20 min to build the robot without any extensions. The 1 hour mark was without any of the suggested programming of the sensors/actuators applied in a given step!
Her is the finished beast:

Start robot, top (30cm ruler)
Start robot, angle
The brick comes pre-programmed with a small demo-program, which makes the robot drive, turn and drive again. While during this a pair of eyes with decreasing amount of wakefulness are displayed on the brick. This can be seen in the below video:


Now all the above is nice a well, but I feel that I should at least describe the one irritation I experienced duing the above tests: The brick is quite slow at starting up and even worse at shutting down (2 tests, both same duration):
Startup:     ~30 seconds
Shutdown: ~45 seconds
And this is with the latest firmware update! Compared to my laptop (running Ubuntu 13.04, old HardDisk):
Startup:     ~  45 seconds
Shutdown: ~    8 seconds
I do have hopes that this will change in the future, but seeing as the brick spends a huge amount of time on the shutdown procedure, I expect that something isn't quite right in that department.

EV3 - what is it all about

EV3 - what is it all about

The newest, at time of writing, LEGO Mindstorms box-set is called EV3. This blog will describe my experiments and (hopefully) insights into the workings of this toy.
I will be focusing upon the software that makes the Mindstorms solution work, but in order to fully understand the implications of a given design-choice, I expect to look into both the physical aspects of the hardware and (to a lesser degree) the usability from the users point of view.
My blog will be experiment-driven with little to no focus upon a overall coherency. My goal is to uncover and explore/experience fascinating details of how this brick works in relation to leJOS.

The box

Upon receiving the box I quickly noticed the high degree of similarity with the previous version NXT. To me, this wasn't a bad thing. The fact that LEGO tries to keep what worked from the previous edition seemed promising. Her is a few pictures:

Box from side, ~43 x 21 x 17 cm (space needed for storage)
Box from top
Opening the box up revealed a familiar sight:

Box initial
Box sorted

The actuators and sensors look deceptively similar to their NXT-version. From this point on, I naturally decided to explore what, exactly, the difference was between NXT and EV3.