I received a review electronic copy of Packt Publishing’s ‘Lego Mindstorms EV3 Essentials’ book. This book covers Java and leJOS programming on the EV3, so it differs from most other books on the market in that it choose a 3rd party environment rather than relying on the Lego-supplied one. It also requires a Linux environment as you will be typing a lot of commands in the terminal. The review copy I received is in electronic format so I can’t comment on the final print quality.
The challenge with writing a book based on an evolving open-source program is that you will be forever behind the curve. Despite being a relatively new publication this book is based on the 0.8.1 release of leJOS, which has been superseded by the 0.9.0 release. The leJOS team are constantly improving the platform and making it easier to install and program, so this book has already fallen out-of-date.
Chapter 2 of the ebook opens with coverage of the Lego Mindstorms EV3, and a survey of the sensors, motors and EV3 programmable brick. While it is welcome to have this in the book the content is nothing new; multiple pictures of the major pieces with some descriptive text. You can get this from Lego’s official website, and spending the first 40 pages of the book covering it again was not needed.
In Chapter 3 the on-brick programming functions of the EV3 brick area covered. Now this is where I started to get confused; wasn’t this book meant to be about leJOS programming and more advanced topics? Chapter 3 spends 30 pages covering on-brick programming, before finally we get to…
Chapter 4: leJOS – at last! This chapter introduces the leJOS Java environment for the EV3. Now the first problem is that the instructions given here are very Linux specific, so if you have a Windows or Mac then you are out of luck. Don’t worry though; Windows users have a graphical installer available to them from the official lejos.org website.
Chapter 5 discusses various ways to connect to the EV3. If you have a wifi dongle your EV3 can connect to your wifi hub and then you can simply ssh into it (or better yet, connect via the Eclipse plugin). If you don’t have a wifi dongle then you can use the USB cable and ssh to 10.0.1.1, which is the address the EV3 appears as to your PC or Mac.
This chapter spends a lot of time discussing how to configure the wifi password on the EV3 by editing the /etc/wpa_supplicant.conf file. Now this is certainly the hard-core Linux way to solve this problem, but by far the easier approach is to use the built-in wifi configuration screen on the EV3 to type in your wifi passphrase and connect automatically. This is covered in better detail at the leJOS website.
Chapter 6: this chapter covers programming the EV3 in Java, and it’s where I have a big issues with the book. It leaps into a discussion of the Gradle Java build environment. However all of the guidance on the lejos.org website is around using Eclipse to do your development, with ant build files. There’s no problem in choosing an alternate build environment but I think that an introductory book should have just stuck to the standard IDE suggested by the leJOS project. Another problem in the text is that once you have compiled your program the book suggests that you remove the SDcard from the EV3 and insert it into the computer to manually copy the .class files over. But we just spent the whole last chapter configuring our wifi and setting up ssh keys to avoid this! Very confusing.
Chapter 7 covers the basic operation of moving the motor and using the touch sensor. This is so basic that it really doesn’t require a whole chapter; one program to make the motor go forwards and another to wait for a press of the touch sensor.
Chapter 8, 9 and 10 discuss building a line-follower robot (your read that right; three chapters to cover one of the most basic robots). I was disappointed to find that the code in this chapter re-invented the wheel. It built a very simple differential-drive line follower robot that used simple rotations to try and find the line. The logic of the line-follower program uses a narrow sweep to find the line and if that fails it performs a wider sweep. This is the classic single sensor approach to line-following.
The author spends 60 pages over three chapters creating the line-follower code. This is the longest treatment of a line-follower robot I have ever read. I would suggest instead presenting the final program first and then explaining the parts step-by-step. I found it very difficult to follow all of the modifications made to the source code over three chapters.
Avoiding re-inventing code is critical to bug-free programming, but the sample line-follower robot reinvents the DifferentialPilot class from leJOS. There is little point in choosing the leJOS environment if you are not going to show users how to get the most advantage from using the class library!
The code also failed to perform one of the most basic tasks of a line-following robot; calibrating the colour sensor to the line and non-line parts of the floor! It assumes that you can specify the colour of the line absolutely in the code, and there will be no interference from ambient light or noise. As anyone who has built a line-follower knows this is far from true!
So now we’ve built a basic line-follower robot and…the book is complete! Appendix A explains how to use Make in great detail (why?) and Appendix B gives two pages over to the various IDEs available for Java (again, why?)
This book does not contain building instructions, and it contains one programming project; a very simple line-following robot.
Conclusion: I’d avoid buying this book and instead use the tutorials available for free on the lejos.org website. It was very disappointing, spending more time on introductory concepts instead of creating advanced projects in Java and leJOS.