Tuesday, February 24, 2009

Thank you Elvis

"Elvis" returns to pick up more water

A big thank you to the CFA and the fire bomber "Elvis". I was watchful but not particularly concerned yesterday, 4 km downwind from the Upwey bushfires, under the smoke plume, the light had turned that orange colour. Then there was a second column of smoke and much closer, 200 metres from the house. Was it a spot fire? There had been no sign of embers or ash falling from the sky.

Then "Elvis" the big helicopter arrived dumping 10 tonnes of water at a time. It dumped 5 or so loads, passing directly over the house at treetop height till the fire was out, or at least manageable by ground crews.

Today, no sign of smoke, just burnt trees


Thursday, February 12, 2009

Using Python blocks in TurtleArt

The Python block and file tamyblock.py
There is the facility to insert a block of Python code into TurtleArt in its current experimental fork, TurtleArtPortfolio on the OLPC. (This feature is now in Turtle Art from V44) Thanks Walter for the following help.

As of TurtleArtPortfolio V17
, when TA is first run, it creates a copy of tamyblock.py in the journal.

This code can be opened with Pippy and edited. There are some example blocks of code there which are commented out with #

The Python code can be loaded into TA using the Save/Load menu tab.

Replacing a deleted tamyblock.py
If you delete tamyblock.py from the journal, you need to manually replace it (this may change with later versions). In terminal go to directory
and use the copy-to-journal command, note you need to supply the MIME (see also) type for the file, text/x-python:
copy-to-journal tamyblock.py -m text/x-python
Error messages
Errors executing the code and the output of any print statements are directed to the (TAPortfolioActivity ??) log file The log files are at ~/.sugar/default/logs and can be viewed with the Log activity

Rainbow security
Currently having problems with Rainbow security settings, follow this link to Rainbow for how to disable it.

Version 19 update
Rainbow problem circumvented V19. tamyblock not required, cannot do imports

Labels: , , ,

Monday, February 09, 2009

Turtle Lander

For TurtleArt in its current experimental fork, TurtleArtPortfolio on the OLPC. Use the a s d keys to fire the thrusters. Keys do not auto-repeat.

Execution speed is becoming an issue, each block adds 2-5 mS, the print adds 25mS, the wait 1, which is necessary to see the turtle, adds 10mS.
The area of the canvas limits how big a program you can create, is it worth adding scroll bars?
Dragging the stack of blocks is starting to become slow.
It is not possible to test if a key is held down.

Timing program execution
I used the following TA program to time the execution time of each block. It uses the clock() Python function from the time library.

block milliseconds
nothing** 0.21ms
clean 20*
forward 0 3.37
left 0 2.5
arc 0 0 4.99
setxy 0 0 3.35
seth 0 2.3
store in box1 xcor 1.49
text 16 5.23
pen down 0.82
set pen size 0 1.27
set color 0 1.47
set text color 0 1.42
fill screen 0 0 20*
store in box1 pensize 1.5
store in box1 0+0 2.36
store in box1 1/1 2.33
store in box1 random 0 100 3.09
query kyb 1.0
store in box 1 keyboard 1.56
store in box 1 x x=1 2.85
store in box 1 volume 7*
repeat 1 2.02
if 1=1 3.74
hor or vert spacers 0.8
variable = 1 1.61
push 0 1.23
store in box1 pop 1.6
show heap 23
empty heap 0.9
hide blocks 300

*timer unreliable
**timer overhead-subtract from others

Labels: , , ,

Saturday, February 07, 2009

Using the insert function block in TurtleArt

TurtleArt in its current experimental fork, TurtleArtPortfolio , allows students to use Python functions in a special block.
The intention of this feature is to provide a "higher ceiling" for open ended learning. I decided to try this function to do an analogue clock , a task that I had previously done in Gamemaker.

It turned out to be a trivial exercise for some learning goals because trigonometric functions of sin() cos() and pi() were not required, I could just use set heading.

I required the time library functions from Python which had not been imported, this meant I had to hack the TurtleArt source file talogo.py adding the line
from time import localtime
(as of V13, this is not required)

The programmming in TA visual blocks is shown in the picture below.

The code to the right draws 12 hour marks from radius 200 to 220. The code to the left draws the second, minute and hour hand. The heading for the second hand, for example, is calculated as
seth=localtime().tm_sec * 6
for the minute and hour use tm_min and tm_hour respectively.

The output:
What I found hard
The time function that I required was not already imported into TurtleArt. Can you use the insert function block to import a library? Apparently not because import does not return a value. Could the block be reprogrammed so that it does not need to return a value? If all likely imports are already programmed in, does TurtleArt become clumsy, slow to load and a memory hog? If students can't access all functions they don't have a sufficiently high ceiling.

Finding the correct syntax for time . There was a lack of documentation or programming examples that explained that localtime() returns a structure with elements including tm_hour. Also the correct syntax depending on whether one function or the whole library was imported. Specifically, it was hard to discover that the correct syntax could be:

import time

from time import localtime
and that the two lines of code above could be combined, eliminating the need for the temporary structure variable mytime
from time import localtime
It either needs better documentation, more code examples or both.

What didn't work

The block has insufficient space to type in long expressions, you can't edit an expression, you have to retype it, when dragging a block containing a long expression, it leaves bits of text on the canvas.

Labels: , , ,