Myro on .NET (Including Mono)
Myro is the name of the software created by the Institute for Person Robots in Education (IPRE) that runs the Scribbler and Fluke hardware. Myro currently exists as a prototype written in CPython, the original version of Python written in the C programming language. This version of Myro will be referred to as Myro-Pilot. Our goal is to implement a new application programming interface (API) in .NET and Mono (an open source, cross-platform implementation of .NET). This new version of Myro will be called Myro3.
This document defines the API, philosophy, and the implementation of Myro3 and serves as the design document for this development.
The most up to date information on this development is now located at PyjamaDevelopment.
- 1 Myro-Pilot
- 2 Mono and IronPython
- 3 Pyjama
- 4 Robotics Connection
- 5 API
- 6 Other Connections
- 7 Development
- 8 Resources
- 9 References
- Software running on host computer controls a low-cost, Bluetooth-enabled robot
- The robot has a simple micro-controller, and does little processing
- Communication between host and robot is to be minimized
- Host programming language is dynamic and interpreted to provide immediate feedback and interactivity for the student
- Software developed will be released under an OSI-approved open source license, namely the Microsoft Public License.
The Myro-pilot uses the language Python and editor/environment IDLE that comes as a standard package with CPython, the standard Python product. Myro-Pilot is implemented as a Python module. It talks to robots through a serial connection over Bluetooth. The current implementation works on Linux, Mac, Windows XP and Vista. Myro-Pilot is licensed under an open source license. All of the functionality from Myro-Pilot will need to be replicated in Myro3. We will call the editor/evaluator portion of Myro3 "Pyjama".
At the lowest level, Myro is designed to talk to robots. However, in order to provided all of the functionality needed in the classroom, Myro also needs to manipulate graphics and audio on the host computer. These are the core Myro functionalities. Myro-Pilot also supports a number of peripheral functions. For example, Myro-Pilot uses Instant Messaging (IM) to communicate to other robots, and to a web server, called My Web. To provide this functionality, Myro-Pilot currently has the following dependencies:
- Python Image Processing (PIL) - read/write image files
- pygame/SDL - joystick handling
- pyserial - cross-platform serial device open/read/write
- text-to-speech voice generation - (SAPI on Windows, built-in on Mac, and Festival on Linux)
- xmpppy - Jabber client
- snack - sound production on computer
- TK/Tickle - GUIs
These dependencies will have to be rewritten or replaced with .NET/Mono alternatives. Initially we will support just IronPython, an implementation of CPython in .NET. However, other .NET languages are possible and we will design for this possibility through a language plugin (described below). It is hoped that Myro could be used as a replacement for Mark Guzdial's Mediacomp and John Zelle's OOP Graphics primitives (supporting all sound and graphics functionality).
One of important aspects of Myro3 is that it will provide a path to Microsoft Robotics Studio, both directly through code, and as a route for students to explore.
Mono and IronPython
Mono is an open source implementation of the .NET standards and can be found at http://www.mono-project.com/.
IronPython is being written by Microsoft for .NET. It is not designed to run in Mono; however, the Mono group has used IronPython extensively to test (and fix) the Mono implementation of .NET and now fully supports and runs IronPython. There are a few issues in making IronPython run in a cross-platform manner in Mono, and thus a IronPython Community Edition (IPCE) has been created. IPCE patches IronPython (afterwards called FePy) and includes all of the compatible CPython libraries, which IronPython does not.
Some help on using IronPython can be found at IronPython on this wiki.
You can use the Mono binaries found here. We will be refering to Mono version 1.9 (or higher) in this document. You may wish to install gtk-sharp2-devel gtksourceview2 and gnome-sharp-devel.
Pyjama is the name of the editor/evaluator portion of Myro3. It is a editor/evaluator system designed for pedagogy. Three projects capture the simplicity of the philosophy: DrPython, IDLE and JES; however, the two-pane approach to a simplified, classroom-oriented IDE goes back many years and through many projects. Examples of this design include: DrScheme (see wikipedia), and DrJava (see main page).
DrPython (screenshot) may in fact be closest to our layout goals for Pyjama. However, it can still be too complex by offering too many options for beginning students. One the other hand, DrPython is very simplistic and has no real connection between the editor and evaluator. IDLE's simplicity and integration is a better target for functional requirements.
Error code: 127
IDLE is an editor/evaluator written in Python using the Tk graphics library. It is split into two processes: the editor and the evaluator. This was largely necessary because many users would like to edit and run Tk+Python code. Because the editor uses a Tk graphics loop, this was necessary to keep the user's Tk graphics loop separate.
For details on IDLE functionality, see http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/.
IDLE has the following functions:
- New window
- Recent files
- Class browser
- Path browser
- Save as
- Save copy as
- Print window
IDLE also breaks these two functions into separate windows.
Error code: 127
JES continues a tradition of interfaces designed for the classroom by implementing a two-pane editor/evaluator screen.
More information on JES can be found in this presentation.
- Simple editor with limited functions
- Syntax coloring
- Evaluation running in separate thread
- Plugins for languages
- Pedagogical hooks
Pyjama is planned to be written in C#, run in .NET and Mono (for cross-platform functionality), and written to use the gtk# graphics toolkit.
Additionally, it is hoped that Pyjama can provide a debugger with scripting-language-level stepping, and related support. It is unknown if the the DLR (or IronPython) can provide this level of support.
Ideally, our Python interface would be able to be used outside of Pyjama. For example:
C:\> ipy2.exe IronPython console: IronPython 2.0A5 (2.0.11011.00) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> from myro import * >>> init() >>> forward(.5, 2)
However, our first priority is to make it work in Pyjama. It may be that we need to handle the IronPython environment or the OS environment (for example starting/stopiing MSRS services, and sending the stop signal to the robot) that cannot be done in IronPython alone, and so Pyjama may be the required interface for easy use. This issue may also be relevant in discussing the graphics. For example, it may be required to run Myro in Pyjama to handle the graphics thread.
Accessibility may be provided by atk.
Internationalization could be provided by gettext. See http://www.mono-project.com/I18N_with_Mono.Unix
On Windows you have to change the file $prefix/etc/mono/config from <dllmap dll="libintl" target="libc.so.6" /> to <dllmap dll="libintl" target="intl" />
Pyjama will provide IronPython (and other languages) via hosting. In fact, Pyjama is designed for multiple-language hosting through the Dynamic Language Runtime (DLR). IronPython is still under development and the hosting interface has continued to evolve. A recent example of hosting IronPython version 2 can be found in the IronPython cookbook entry Hosting IronPython 2. See also examples on the IronPython page here.
Pyjama should provide educators with support for doing a variety of tasks, including assessment and evaluation of teaching methods.
- classroom support
- allow student/teacher interaction in the classroom (perhaps ideas similar to those in Richard Anderson's Classroom Presenter)
- be able to use IDE for demos in class
- large font size
- important text (code, or shell) in top or middle of screen
- (projectors make it hard to see at the bottom)
- suggests tabbed pages, or top/bottom switch
Consider instrumentation in other teaching platforms such as the results published in ICER.
- post-classroom analysis
- time on task support
- login and store on server?
- save and upload at end of semester?
- providing student help
- code templates/skeleton?
- handin and grading support?
- feedback support: highlight and comment student's papers (similar to Word's Trackchanges and Comments)
- links to demographic data
- installation time
We should make any data submission be optional, friendly, and easy. This could form the basis for more scalable assessment.
Myro-pilot supports functionality at the Python level to dynamically change function and method names. For example, the function to retrieve a robot's name can be getName() or get_name(). This may be important in the adoption of Myro at some locations. It is not known if other DLR languages support such flexibility. This is possible in Python (and IronPython) as function and method names are just entries in a dictionary/hash table.
Pyjama will support a few plugin, or nearly plugin capabilities:
- Additional direct-connect robot interfaces
- Scripting Languages (or GUI languages, such as Alice's drag-n-drop or MSRS's Visual Programming Language, VPL)
- Editor extensions, like IDLE's
- Pedagogical hooks
- Internationalization support for different human languages in GUI
Pyjama should have an installed config.ini file for college/classroom-level settings, and also a person config.ini for students to save customized settings.
Pyjama should support the ability to run on read-only media, for example a live virtual machine image (such as VPN) running from a CDROM.
Myro3 can connect to robots via two pathways: through Microsoft Robotics Studio (MSRS), and a direct connection. The direct connection is provided for those institutions that do not use MSRS.
The Myro CPython interface is described in the Myro Reference Manual and the implementation can be found in the Myro SVN repository. The Myro C# implementation is defined and implemented in the Foundation/MyroInterfaces.
The scripting languages (Ruby, Python, VB, JScript, etc.) extend the C# interfaces. The C# interfaces provide a connection to the MSRS path and the direct-connection path (both described below).
Myro (and any other software) can talk directly to the Scribbler, the Fluke, and the Roomba/Create. The Fluke is the IPRE hardware dongle that plugs directly into a serial port (like that on the Scribbler) and provides Bluetooth, a camera, and IR sensors.
Please see the Myro 3.0 Developer Manual for more information about how Myro works, and for tutorials on adding support for new robots to Myro.
The UI and API could be instrumented (much like Microsoft does in many of its applications under the CEIP). See CEIP to study usage patterns both for system improvement and pedagogical reasons.
The Fluke functionality is fully described in Fluke Functions and the low-level hardware level is described in Hacking the Fluke. The bytecodes for the direct connection to the Fluke can be found for the server (Fluke) in bytecode-description.txt and for the client (robot) in dongle.py.
The bytecodes for talking to the Roomba/Create are implemented in roomba.py
An initial test version for talking to Surveyor's SRV-1 can be found in surveyor.py, but was written before the Myro interface was completely defined, and is now out-of-date as Surveyor has moved the SRV-1 to the Blackfin.
Services will need to be run before attempting to connect Myro onto a MSRS-based system (a robot or simulation). The services are described in a manifest which is contained in XML, such as DrawSquare.manifest.xml. This is sent to DssHost.exe along with a port number, as shown in the batch file DrawSquare.bat . More details can be found in the readme.html.
IronPython to MSRS
A sample of using IronPython to connect to MSRS is given in Tutorial1.py. Although, IronPython and MSRS have both changed significantly since that example was created.
We are currently targeting IronPython 1.1 (due to their stable hosting API) but will move to IronPython 2.0 when it is finalized. We are targeting MSRS 2.0 (2008). You will need:
- Microsoft .NET Framework 3.5
- Microsoft .NET Compact Framework 3.5
- Microsoft XNA Framework 2.0
- AGEIA PhysX System Software
Myro also includes functionality to replace Zelle's graphical objects and Guzdial's mediacomp. This requires basic graphics which were implemented in Tkinter and Jython in Myro-pilot and JES, respectively. The largest portion of this can be mapped to gtk#, but replacements will need to be found for those parts of the Python Imaging Library (PIL) (such as loading and decoding JPEG, PNG, GIF, etc).
Development of Pyjama has begun and can be found in Myro/Pyjama SVN.
The current code is an exploration of some of the underlying infrastructure, including Mono, color syntax high-lighting, and internationalization.
We are using SVN for source code versioning, makefiles, batch files, and Visual Studio 2008. Regardless of what OS and development environment one wants to use, we should have an option that matches.
- Editor - functional
- Internationalization hooks - done
- Color Syntax Highlighting - done
- Function/Method parameter hints
- Config file
- Use a key-based .ini approach
- Save user values, and package defaults (make available with "import myro")
- header for student's programs files
- Pedagogical Hooks/log file
- Dynamic Language Hosting - exploration
- Python/Ruby Evaluation
- Direct Connection To Robots
- Cross-platform Serial Port
- MSRS Connection
- .NET/Python side
- MSRS side
- Scribbler Simulation
- Port existing Myro to IronPython
- A method to get and install cross-platform prototype (zip file)
- A cross-platform installer
- Graphics: images, objects
- Image open/save functionality
- Graphical objects primitives (square, lines) - write in gtk
- Testing: Cross-platform, Unit Tests
Starting May 8, 2008 each week we'll have a developer's conference call. In these meetings we'll discuss accomplishments from the past week, goals for the next, and overall progress. You can find details of these meetings on the Myro3 Development page.
- http://compilerlab.members.winisp.net/ - Compiler DevLab 2007. Meeting of Microsoft's CompilerDev team on the DLR.
- http://www.voidspace.org.uk/ironpython/winforms/index.shtml - Tutorials on Winforms under Mono
- http://www.go-mono.com/mono-downloads/download.html - Mono version 1.9 (Linux user's might want "other unixes" binary)
- http://sourceforge.net/projects/xacc/ - possible starting place
- http://www.mono-project.com/GtkSharp - gtk bindings for Mono's C#
- http://msdn.microsoft.com/robotics/ - Microsoft Robotics Studio
- http://www.roboteducation.org/ - IPRE main page
- http://www.parallax.com/ - Parallax, makers of the Scribbler and the BOE-Bot
- http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython IronPython
- http://PyroRobotics.org/ - Pyro, Python Robotics
- http://fepy.sourceforge.net/ - FePy and the IronPython Community Edition (IPCE)
- http://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=383&SiteID=1 MS Forums for MSRS
- http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/ - One Day of IDLE Toying, tutorial on IDLE
- http://www.bluej.org/about/papers.html - Papers on BlueJ, environment for Java
- http://www.cs.kent.ac.uk/events/conf/2006/icer/ - ICER publications on instrumentation in teaching platforms
- http://www.mono-project.com/I18N_with_Mono.Unix - internationalization of text
- http://tirania.org/blog//texts/cli-plugins.html - Tutorial on .NET plugin (dynamically loadable code)
- http://forge.novell.com/modules/xfmod/project/?gtks-inst4win Gtk SourceView Sharp for Windows (includes Mono.Posix)
- http://www.mono-project.com/Mono:Windows - Mono on Windows
- http://www.go-mono.com/docs/index.aspx?link=N%3AMono.Unix - Mono's documentation on classes
- http://www.ironpython.info/index.php/Hosting_IronPython_2 - Hosting IronPython in C#
- http://compilerlab.members.winisp.net/hosting-tour.doc - Discussion of Nessie, Hosting (old), Colorizing, etc.
- http://code.google.com/p/monopad/source/diff?r=2&format=side&path=/trunk/Source/MonoPad.GladeGUI.cs - Similar codebase
- http://msdn.microsoft.com/en-us/library/bb896703.aspx - Talking to MSRS without dsshost.exe
- http://code.google.com/p/alsing/wiki/SyntaxBox - WPF color syntax highlighting
- AAAI Spring Symposium Series, March 2007, Stanford, CA – Paper titled, Advanced Robotics Projects for Undergraduate Students, by Douglas Blank, Deepak Kumar, James Marshall, and Lisa Meeden. Presented at the Symposium on Robots and Robot Venues: Resources for AI Education.
- AAAI Spring Symposium Series, March 2008, Stanford, CA – Paper titled, Engaging Computing Students with AI and Robotics, by Deepak Kumar, Doug Blank, Tucker Balch, Keith O'Hara, Mark Guzdial, Stewart Tansley. Presented at the Symposium on Using AI to Motivate Greater Participation in Computer Science.
- Communications of the ACM, Volume 49, Issue 12, December 2006, Pages: 25 - 27 - Robots make computer science personal, Douglas Blank.
- DrJava: A lightweight pedagogic environment for Java, by Eric Allen, Robert Cartwright, and Brian Stoler. Rice University, September 7, 2001.