Abstract
We present Legodroid, a Java library for Android that allows cross-programming LEGO Mindstorms through an Android device to exploit its extra computational capabilities in a seamless way. From a programmer’s perspective, the paradigm it suggests for programming the EV3 is straightforward and resembles a standard main function in the likes of leJOS, which natively runs on the EV3 side though. Moreover, the library imposes type-driven coding patterns for interacting with motors and sensors, which guide developers in writing correct code with less runtime errors thanks to a rigid discipline over types. This is particularly effective in Android, whose component-based pattern complicates coding of traditional long-running algorithms for robots. Compared to leJOS, Legodroid users reported shorter bugfixing times and a more accessible paradigm for programming the robot, which had a positive impact on how much resources could be put in writing smarter algorithms and sophisticate interactions.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
At the time of writing, Legodroid does not support wifi connections, as the bluetooth counterpart is preferable in most cases. A WifiConnection class is expected by design though and will be added in a future update.
- 2.
The EV3 CPU is a 300 MHz TI Sitara AM1808 (ARM926EJ-S Core) with 64 MB of RAM.
- 3.
We refer to the EV3.Api nested static class as Api for brevity.
- 4.
The functional interface \(\texttt {Callable<T>}\) represents functions with no arguments and a result of type \(\texttt {T}\), in the same way as \(\texttt {Supplier<T>}\) does, whose functional type can be written as \(\varnothing \rightarrow \texttt {T}\).
- 5.
Refer to the documentation of EV3 firmware instructions (op-codes opOutput_ Polarity and opOutput_Set_Type) in section 4.9 of [37].
- 6.
In Java 8+ all the mentioned language constructs are equivalent type-wise.
- 7.
Bachelor degree in Computer Science, year 2018-19, at DAIS, Università Ca’ Foscari Venezia.
References
Barendregt, H.P.: Functional programming and lambda calculus. In: Formal Models and Semantics, pp. 321–363. Elsevier (1990)
Bloch, J.: Effective Java. Pearson Education India (2016)
Bracha, G.: Generics in the Java Programming Language (2004)
Bracha, G., Odersky, M., Stoutamire, D., Wadler, P.: Making the future safe for the past: adding genericity to the Java programming language. ACM SIGPLAN Not. 33(10), 183–200 (1998)
Brady, E.: Programming and reasoning with algebraic effects and dependent types. ACM SIGPLAN Not. 48, 133–144 (2013)
Brady, E.: Type-Driven Development with Idris. Manning (2016)
Cardelli, L.: Typeful programming. In: Formal Description of Programming Concepts, pp. 431–507 (1991)
Chalin, P., James, P.R.: Non-null references by default in Java: alleviating the nullity annotation burden. In: Ernst, E. (ed.) ECOOP 2007. LNCS, vol. 4609, pp. 227–247. Springer, Heidelberg (2007). https://doi.org/10.1007/978-3-540-73589-2_12
Chalin, P., James, P.R., Rioux, F.: Reducing the use of nullable types through non-null by default and monotonic non-null. IET Softw. 2(6), 515–531 (2008)
Damas, L., Milner, R.: Principal type-schemes for functional programs. POPL 82, 207–212 (1982)
Ehringer, D.: The Dalvik virtual machine architecture. Tech. Rep. 4(8) (2010)
Ellis, B., Stylos, J., Myers, B.: The factory pattern in API design: a usability evaluation. In: Proceedings of the 29th International Conference on Software Engineering, pp. 302–312. IEEE Computer Society (2007)
Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design patterns: abstraction and reuse of object-oriented design. In: Nierstrasz, O.M. (ed.) ECOOP 1993. LNCS, vol. 707, pp. 406–431. Springer, Heidelberg (1993). https://doi.org/10.1007/3-540-47910-4_21
Gibbons, J.: Design patterns as higher-order datatype-generic programs. In: Proceedings of the 2006 ACM SIGPLAN Workshop on Generic Programming, pp. 1–12. ACM (2006)
Goetz, B.: State of the Lambda, 4th edn. (2011). http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-4.html
Google Inc.: Android Executor Interface Documentation (2012). https://developer.android.com/reference/java/util/concurrent/Executor
Google Inc.: Android FutureTask Class Documentation (2012). https://developer.android.com/reference/java/util/concurrent/FutureTask
Google Inc.: Understand the Activity Lifecycle (Android documentation) (2014). https://developer.android.com/guide/components/activities/activity-lifecycle
Google Inc.: Android Studio download page (2019). https://developer.android.com/studio/
Haack, C., Poll, E.: Type-based object immutability with flexible initialization. In: Drossopoulou, S. (ed.) ECOOP 2009. LNCS, vol. 5653, pp. 520–545. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-03013-0_24
Haller, P., Prokopec, A., Miller, H., Klang, V., Kuhn, R., Jovanovic, V.: Futures and promises (2012). http://docs.scala-lang.org/overviews/core/futures.html
Kestelyn, J.: How Apache Spark, Scala, and Functional Programming Made Hard Problems Easy at Barclays (2015). https://blog.cloudera.com/blog/2015/08/
McClean, J.: Lambdas are not functional programming (2018). https://medium.com/@johnmcclean/lambdas-are-not-functional-programming-63533ce2eb74
Mycroft, A.: Polymorphic type schemes and recursive definitions. In: Paul, M., Robinet, B. (eds.) Programming 1984. LNCS, vol. 167, pp. 217–228. Springer, Heidelberg (1984). https://doi.org/10.1007/3-540-12925-1_41
Nguyen, D., Wong, S.B.: Design patterns for lazy evaluation. ACM SIGCSE Bull. 32, 21–25 (2000)
Odersky, M., Wadler, P.: Pizza into Java: translating theory into practice. In: POPL (1997)
Oracle Corp: JDK 8 Documentation: Package java.util.function (2010). https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html
Oracle Corp: Method References (Java Documentation) (2017). https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html
Petricek, T.: Type-First Development (2015). http://tomasp.net/blog/type-first-development.aspx/
Pratikakis, P., Spacco, J., Hicks, M.: Transparent proxies for java futures. In: Proceedings of the 19th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2004, pp. 206–223. ACM, New York (2004)
Seemann, M.: Type Driven Development (2015). https://blog.ploeh.dk/2015/08/10/type-driven-development/
Seemann, M.: Type Driven Development (2015). https://blog.ploeh.dk/2016/02/10/types-properties-software/
Setzer, A.: Java as a functional programming language. In: Geuvers, H., Wiedijk, F. (eds.) TYPES 2002. LNCS, vol. 2646, pp. 279–298. Springer, Heidelberg (2003). https://doi.org/10.1007/3-540-39185-1_16
Subramaniam, V.: Functional programming in Java: harnessing the power of Java 8 Lambda expressions. In: Pragmatic Bookshelf (2014)
The Lego Group: LEGO Mindstorms NXT Education Kit (2011). https://www.generationrobots.com/media/Lego-Mindstorms-NXT-Education-Kit.pdf
The Lego Group: EV3 Communication Developer Kit (2013). https://le-www-live-s.legocdn.com/sc/media/files/ev3-developer-kit/lego
The Lego Group: EV3 Firmware Developer Kit (2013). https://le-www-live-s.legocdn.com/sc/media/files/ev3-developer-kit/lego
The Lego Group: ROBOLAB Reference Guide (2013). http://www.legoengineering.com/robolab-programming-references/
Warburton, R.: Java 8 Lambdas: Pragmatic Functional Programming. O’Reilly Media Inc., Sebastopol (2014)
Welc, A., Jagannathan, S., Hosking, A.: Safe futures for Java. In: Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2005, pp. 439–453. ACM, New York (2005)
Wlaschin, S.: Designing with Types (2013). https://fsharpforfunandprofit.com/series/designing-with-types.html
Wlaschin, S.: Designing with Types: Making illegal states unrepresentable (2013). https://fsharpforfunandprofit.com/posts/designing-with-types-making-illegal-states-unrepresentable
Xi, H., Pfenning, F.: Dependent types in practical programming. In: Proceedings of the 26th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 214–227. ACM (1999)
Zhang, L., Krintz, C., Nagpurkar, P.: Language and virtual machine support for efficient fine-grained futures in Java. In: Proceedings of the 16th International Conference on Parallel Architecture and Compilation Techniques, PACT 2007, pp. 130–139. IEEE Computer Society, Washington, DC (2007)
Zhang, L., Krintz, C., Soman, S.: Efficient support of fine-grained futures in Java. In: International Conference on Parallel and Distributed Computing Systems (PDCS). Citeseer (2006)
Zibin, Y., Potanin, A., Ali, M., Artzi, S., et al.: Object and reference immutability using java generics. In: Proceedings of the 6th Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on the Foundations of Software Engineering, pp. 75–84. ACM (2007)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2019 Springer Nature Switzerland AG
About this paper
Cite this paper
Spanò, A., Cortesi, A., Zausa, G. (2019). Type-Driven Cross-Programming for Android and LEGO Mindstorms Interoperability. In: Saeed, K., Chaki, R., Janev, V. (eds) Computer Information Systems and Industrial Management. CISIM 2019. Lecture Notes in Computer Science(), vol 11703. Springer, Cham. https://doi.org/10.1007/978-3-030-28957-7_17
Download citation
DOI: https://doi.org/10.1007/978-3-030-28957-7_17
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-28956-0
Online ISBN: 978-3-030-28957-7
eBook Packages: Computer ScienceComputer Science (R0)