Sugar is the Fedora Linux based operating system used by OLPC on their XO laptops and now maintained by SugarLabs.
Issue: (Team Awesome + Team PuffAdder)
Porting games from pygame and python to the OLPC and creating activity bundles
Description:
The wrapper for pygames (OLPCGames-1.6) and the instructions for how to use it from the OLPC wiki are not usable
Approaches Tried:
Solved:
1/15/09
Cut and Paste the code to a website or email
Cut and paste from there to Pippy
Save from pippy as an activity bundle
Additional Thoughts:
1/16/09
While this works, it may not be the best way to do and we may need to figure out how to get OLPC-Games to wrap correctly. Why? When you open up your new pippy-made activity, it will open two windows. One is the window actually made by pippy, and the other is your pygame. Now, no other activities work like that which leads me to believe that ultimately the way we have it set up is wrong. Very sad, yes, I know. I'm wondering if OLPC-Games, if we were able to get it to work, will wrap (which to my understanding is what its supposed to do) the pygame into the sugar activity window.
Issue: (Team Awesome)
Getting Glade GUI designer to work on a mac
Description:
Glade does not have a package installer for mac and very sparse instructions for getting it working on a mac
Approaches Tried:
Solved:
1/16/09
install XQuartz version of x11 before glade3
Issue: (Team Awesome)
best virtual machine to run the OLPC image in
Description:
was looking for an easy to use, reliable VM
Approaches Tried:
looked at the ones recomended by OLPC
Solved:
1/16/09
settled on using Virtual Box instead
Issue: (Team PuffAdder)
Touchpad being very hard to use
Description:
Very hard to use the touchpad
Approaches Tried:
Pushing hard on the touchpad
Solved:
1/16/09
You need to recalibrate the touchpad! Do this by pressing the buttons in the four corners of the keyboard (right arrow “end” key, the frame key, the escape key, the function key). However, make sure that you press the function key LAST and make sure there is nothing on the touchpad.
Another thing that sometimes works is to open or close the frame or change to home view (Team Awesome)
Issue: (Team Meow)
Unable to get use wget to retrieve from the wiki
Description
If you try to use wget in order to retrieve files form the wiki it actually copies the formatting of a wiki page instead of the file
Approaches Tried
We attempted to change the colons in the filepath to backslashes however this gives the same result. The reccomended solution atthis time is to post code you need for the olpc to your website on copland or some other web page in order to use the wget command.
Partially Solved:
The current solution is more of a work around. This appears to be more of a problem on the wiki end rather than the olpc end.
Python
# apt-get install python
# yum install python
# emerge -av python
# apt-get install emacs21
Pygame
# apt-get install python-pygame
Development Environment
These are general ideas of things you should do and understand before trying to program for the XO
Have you ever went into the terminal and typed “emacs activity.py” and been confronted with a horrible error? A horrible error saying something similar to “emacs command not found”? Then this is the tutorial for you! And it is only two or three easy steps…
The first thing you should do is install emacs, so open a terminal. Make sure you’re connected to wifi because it’s going to download all of the files:
su yum install emacs
Wonderful! Now you have emacs with just two simple commands in the terminal.
However, you’ll soon notice when you try to open it that you get an error saying
"Font `-adobe-courier-medium-r-*-*-12-120-75-75-*-*-*-*' is not defined"
No problem! If you follow the instructions on OLPC’s emacs page, they say to delete the adobe-courier-medium line from a file. However, if you do that, when the window opens the font is unbearably small to read. So, I suggest doing this instead in the terminal:
emacs -nw ~/.bashrc
And add the following line to the end of the file:
alias emacs='emacs -nw'
What you just did was told bash (your shell) to run the command ‘emacs -nw’ every time you type ‘emacs’. This opens emacs within the terminal instead of a window, and looks much better.
Note: This won’t work until you restart your shell. So you can either restart the terminal or just type ‘source ~/.bashrc’.
Familiarity with the Linux family of operating systems can be useful when dealing with the XO. If you haven't done so before, you might consider installing Linux on a machine you have access to. Ubuntu is a distribution that is particularly suited for beginners, and Fedora (the basis for the XO operating system) is good for intermediate users. The Gentoo installation process is considerably more involved, but upon completion you will have a better understanding and appreciation for Linux. For Windows users, the Ubuntu CD provides Wubi, a Windows program that allows Ubuntu to be installed without re-partitioning your computer. Sun Microsystem's VirtualBox provides Windows and Mac OS X users the ability to install any flavor of Linux as a virtual machine inside their existing OS, free of charge.
Some usefull links related to Linux:
Install the sugar package that comes with Ubuntu to use their Sugar Emulator. You can actually open up two different emulators and have them act as two different XOs. This will help with testing mesh networking on your laptop.
Open two different emulators using these two seperate commands:
ubuntu-prompt$ SUGAR_PROFILE=cat sugar-emulator ubuntu-prompt$ SUGAR_PROFILE=dog sugar-emulator
Note that cat and dog can be anything, as long as they are different.
The use of a SVN is highly recommended. Emailing code will get very tedious and causes problems when multiple people are making changes at the same time.
Reading the Subversion books will allow you to better understand the mechanics of version control with SVN. It is available at: Subversion Book
The most important chapters are Basic Usage and Branching and Merging.
Repositories hosted with the ECE/CIS Dept. for use with class projects will be provided to each group.
UD CIS students will require an ECE/CIS “acad” account to access the repositories. If you do not have an acad account, you can apply here.
The EECIS Subversion documenatation page provides additional information about using the ECE/CIS subversion servers.
All software for the OLPC project is supposed to be open source and allow for the community to build upon each others work.
The following links are resources from the ACM Digital Library related to the development of educational games. You will need to be on the campus network to access them.
These papers are published in the IEEE Xplore Library, and will also need a UD network connection to access.
Recursion
For those new to python, the following links can be of great benefit:
Some Slides from previous classes:
A separate page has been created that contains example python programs and games made by previous classes.
Python Example Programs
When an application is ready for deployment on the XO, the source code is packaged into a .xo file which can be natively imported by the XO laptop. If you need to obtain the source code for an XO application, there are 2 possible ways to do it:
If the program has been imported as an XO activity:
If you have access to the .xo file:
Pygame provides a relatively simple API for programming games in python, and is incredibly usefull for animations. It does not however, provide GUI elements such as buttons/text fields/menus/etc. These must be created by hand when using pygame.
Pygame Tips
Vista and PyGame Instructions
If you have Python (2.5 or higher) and PyGame 1.8 installed, you should be good to go. I've tested crashRun on both MacOS X and Windows and I hope it'll run on Linux, too.
If you need Python, you can download it from: http://python.org/download/
And PyGame is available here: http://pygame.org/download.shtml
Vista users note: when I tried the python installer on a Vista machine, the installer didn't modify the PATH to include Python (it appeared to on XP). You can set this variable by right-clicking My Computer in the Start menu, selecting Properties, Advanced, and then pressing the Environment Variables button. You'll need to append “;C:\Python25\” to the end of the PATH variable.
Issue : The Frame does not display anything or freezes (Team Meow)
Description: So the code brings up a window however nothing changes or updates in it or it freezes.
Solution: Chances are you forgot the pygame.display.flip() command. This should go at the end of any code that makes changes to the screen. The command works by updating the screen or other display you are using.
Issue: pygame window stays all black on windows XP in eclipse
Description: pygame window stays black until window is minimize and then re-opened
Approaches Tried: none, it works on windows vista
Solved: use pygame.display.flip() after draw function
Issue: Can’t get sound files to work properly
Description: Using the pygame.mixer.Sound() function alone will not produce sound
Solution: Using the pygame.mixer.Sound() function requires a larger wrapper function written around it. We wrote this function that makes using sound really easy.
#This function will play a specified sound file for a given #amount of time #@param: sound_file (string) - the path to the file to play #@param: ticks (int) - the length of time to play the file (in ticks) #@note: This function must be used in conjunction with some type of event handling def play(sound_file, ticks = 1): sound = pygame.mixer.Sound(sound_file) clock = pygame.time.Clock() sound.play() while pygame.mixer.get_busy(): clock.tick(ticks)
Changing the ticks seems to have no effect on the sound, however, not including the ticking did not produce sound.
Here is a representation of the default directory structure for XO
/ '- activities '- boot '- etc '- lib '- media '- ofw '- proc '- sbin '- selinux '- sys '- usr '- bin '- dev '- home '- olpc (AKA ~) '- OLPCGames-1.6 '- Skeleton '- Your Home Made Acitvities end up in here '- mnt '- opt '- root '- security '- srv
Some Links regarding the Mesh Network:
The XO-1's can be projected if they are upgraded to Sugar 10.1.3 (build 860) using a USB2VGA connector. We have tested this using Startech's connector.
The XO runs slower when projecting, will only display an image on the remote screen, and the connector must be plugged in before the XO is started.
See this page which describes how to check your XO version. The information is most likely found under “Control Panel : About my XO”.
Build, release, and update information.
CCCS has XO-1's with build 802.
“OLPC is not the only one making XO-1 operating system builds. You can also obtain builds from others in the wider community” (link).
How to differentiate between XO-1 and XO-1.5?
Success with getting to the OK prompt by holding the “X” game button when powering on, and then hitting ESC when prompted to halt the normal startup. So, the laptops at CCCS all appear to be unsecured, and that we will not need a developer key.
import pygame.version print "PyGame version:", pygame.version.ver
Reflashing will restore the XO to its factory settings. This process can be used for upgrading or downgrading the XO. Directions can be found in the Floss manual. While off, insert a USB stick with the image to reflash with, and while holding down the four game buttons, power on the XO.
With Sugar on a Stick (SOAS), you can boot directly to the Sugar OS on any machine without the need virtualizing or emulating Sugar. Students can use the journal on the stick to save their work.
Versions:
We have a virtual machine set up for our server needs. An acad
account is required for access.
Host: cisc367.acad.cis.udel.edu
Log in instructions:
acad
credentials (Note: you will first be placed into your normal working directory.) eecis_su cisc367
”. (This will change you to user cisc367
if you have the correct permissions, and change your working directory to /home/cisc367
.)
The www docs (public_html
) directory is: /home/www/htdocs/
We have a mysql database on our virtual machine.
Database name: cisc367
Username: cisc367
(full privileges)
password: g0Ah3Ad!
Username: ROcisc367
(read-only user)
password: mAk3mydAy!
A firewall allow rule has been added to allow the entire Internet to connect to the mysql database server on cisc367.acad
.
This file passes data via the POST method to the server. The server will log all data passed by $_POST[“data”]. So in this example, “test data from python again” will be passed.
The server script post-server.php catches this string and appends it to an output file test-output.txt.
Try it out, and run this python script from your local machine!
''' Richard Burns November 28, 2010 Test script which passes information to the class apache server via the POST method. The server script currently captures this information and appends it to a testing output file, demonstrating one way that we can pass data to the server for it to record. Taken from: http://docs.python.org/library/httplib.html TODO: test size limitations of the POST ''' import httplib, urllib #params = urllib.urlencode({'milk': 1, 'eggs': 2, 'bacon': 0}) params = urllib.urlencode({'data': "test data from python again"}); headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} conn = httplib.HTTPConnection("cisc367.acad.cis.udel.edu:80") #conn.request("POST", "/cgi-bin/query", params, headers) conn.request("POST", "/post-server.php", params, headers) response = conn.getresponse() print response.status, response.reason data = response.read() conn.close()
The htdocs directory is publicly viewable at cisc367.acad.cis.udel.edu.
The form.html file can be used to test the php server-side script without the need for the python client.