Stefano Costa

There's more than potsherds out here

Faccio l’archeologo e vivo a Genova

  • Total stations and GNU/Linux, part 2

    In this off-line weekend, I went on investigating the output from the Zeiss Elta R55 total station.

    First of all, it turns out that the file was not binary. A simple

    $ file downloaded_data
    downloaded_data: Non-ISO extended-ASCII text

    could have revealed this simple truth. My error was due mainly to the fact that most of the content in the file was made by non-printable characters. But my guess about the lines that contained the point coordinates was right. Probably due to a wrong download procedure, there were some problems with that file. All characters with code > 128 (hex 80) had to be translated shifting their code by 128. I used this simple Python script for this task:

    >>> read_file = open("downloaded_data", 'r')
    >>> des = read_file.read()
    >>> for i in des:
    ...     if ord(i) > 127:
    ...         print chr(ord(i)-128)
    ...     else:
    ...         print chr(ord(i))
    

    Probably this could be done in a better way, but I’m no hexpert at all. And I think this can be completely avoided by downloading from the serial port with the right connection parameters. I think I’m going to use the pySerial library for this task.

    Obviously, I’m solving the problem for one model of one manufacturer, but there are many models and many brands. With my short experience, the best solution I can think of is a modular approach, with an abstract connection class that can be subclassed, with the connection parameters for each model.

    The second part of the story comes when it’s time to process the downloaded data. First of all, take a look at the clean file contents:

       0001 OR.COOR
       0002                   0S        X        0.000 Y         0.000 Z     0.000
       0003                                            Om     397.0370
       0004 POLAR
       0005 INPUT                       th       1.500 ih        0.000
       0006 INPUT                       th       0.000 ih        0.000 Z     0.000
       0007                   1         X       -0.472 Y         1.576 Z     0.004
    END
    E
    E

    Let’s comment it, line by line:

    1. the first line contains the OR.COOR string, but I’m not sure about the other possible values it can take; the line starts with 0001 like all other lines, except the last one
    2. the second line contains the X Y Z coordinates of the origin point (maybe represented by the string 0S?); please note that it uses the same format as for normal points, except that instead of the id number there is this special string
    3. the third line contains information about the orientation angle, but I can’t tell anything more specific about this
    4. the fourth line contains the POLAR string, that is probably referred to the orientation method; I’m not sure about the other values this field can take
    5. the fifth and sixth lines both start with an INPUT string, that should refer to the height of the reflector prism: 1.500 m is in fact the usual height of the reflector
    6. the seventh line contains our only recorded point, with its id (an integer number) and the X Y X coordinates with precision 3
    7. the eighth line indicates that there are no more points to download, and starts with the END string: when downloading, the program should stop here, otherwise the device emits an error (and also a noisy beep), that is represented by the E string on the following lines
    8. attempts to let the download go on even if the device emits the error simply result in more E lines

    Part 3 will follow soon.

  • cat /dev/total_station > file

    This post is one of the “dear lazyweb” ones.

    Here at the department we have a Zeiss Elta R55 total station. This device has its own software for downloading recorded data, but, as usual, it’s a Windows-only, non-free application.

    Is it possible to download data from such a device using a GNU/Linux machine? Nobody knows. I have asked a number of people and no one has ever tried to do this. 🙁 With some good advice from Frankie, today I made my first test.

    With substantial help from Elisa, I recorded 1 point. This point has coordinates:

    X    -0.472
    Y     1.576
    Z     0.004

    I downloaded from the device using this simple command (it’s ttyUSB0 because my laptop has no serial port)

    cat /dev/ttyUSB0 > data

    The total number of points is 7. Points 1-6 contain information about the origin point and other parameters. For now, I’m ignoring them. The resulting data file is binary. You can see it here. I am no expert of binary files, so I used GHex to see its contents. Its dumped form looks like this:

    ...000.....................
    ...........................
    ...........................
    ...000....................0
    S.................0.000.Y..
    .......0.000.Z.....0.000...
    ...0003....................
    ...........................
    ....39..03.0...............
    ...000..P..A...............
    ...........................
    ...........................
    ...0005..NPU...............
    .........t..........500.i..
    .......0.000...............
    ...0006..NPU...............
    .........t........0.000.i..
    .......0.000.Z.....0.000...
    ...000.....................
    .................-0.....Y..
    .........5.6.Z.....0.00....
    .ND........................
    ...........................
    ...........................
    ...............

    Some comments about this first test:

    • anything after the ND means there are no more data.
    • the recorded point seems to be in the part immediately before ND

    If anyone has any other suggestions about this test, please tell me.

  • hg record

    steko@cycnus:~/code/murature-hg$ hg help record
    hg record [OPTION]... [FILE]...
    
    interactively select changes to commit
    

    I have been using mercurial for 2 months now, and I never noticed it had this great feature. It was the only thing that I missed about leaving darcs.

    For a chaotic person like I am, it’s a must.

  • 9000

    Due giorni fa ho superato quota 9000.

    Non mi sono dato all’alpinismo estremo, sto solo invecchiando!

    steko@cycnus:~$ age.py
    ste ha 9002 giorni.
    ste ha 321 lune.
    ste ha 24 anni.
    

    Qui c’è il codice (stupidissimo) per scoprire quanti giorni avete.

  • meno 3

    E anche un altro esame è stato superato…

    Poteva andare meglio, ma sinceramente a questo punto del mio cursus studiorum non mi interessano tanto i numeri quanto le cose che faccio, e cerco di fare quelle che mi interessano.

    E poi quando finirò gli esami potrò iniziare la tesi, e lavorarci con calma, metodo… perché voglio fare un bel lavoro, qualcosa di cui essere orgoglioso (ogni tanto anche io ne ho bisogno…) e che magari mi sia utile in seguito per aprirmi nuove strade.

    .

    Mi rimetto a studiare, dai…

  • Ti rendi minimamente conto di come si sente un disabile…

    … quando giri per stazioni e marciapiedi con una borsa pesante a rotelle, e:

    • bestemmi ogni scalino
    • benedici ogni rampa o piano inclinato di qualunque genere (purché non eccessivamente ripidi), ringraziando gli illuminati responsabili della amministrazione della cosa pubblica per averti concesso il diritto di muoverti

    Minimamente…

  • Python PEPS always with you

    AFAICT, in Debian we have no python-doc-peps package (probably due to license issues?)

    For all those who aren’t online 24/7, having the PEPS with you is as simple as:

    $ svn co http://svn.python.org/projects/peps/trunk/ peps

    followed by an eventual

    $ cd peps
    $ ./pep2html.py 

    And you’re done!

  • Creative Commons and Flickr, or my 2 minutes of glory

    One of my photos taken in Vienna when I went there for the 11th “Computer & Archäologie” workshop (2006) has been selected for the Schmap Vienna Guide!

    A photograph of the Albertina in Wien
    The Albertina in Wien

    The photo had been published on Flickr, with a Creative Commons – Attribution – ShareAlike license. The editors contacted me by e-mail, asking for my permission before the picture was inserted on the website. And now it’s there with my name below. 🙂

  • hg meme: hours of the day I work

    I started using Mercurial for a new IOSA subproject. Our public repository is hosted at sharesource.

    In a geeky moment, I wrote this one-liner (splitted in two lines for your browsing pleasure):

    LC_ALL=C hg log | grep date: | awk '{ print($5) }' | \
    awk -F ":" '{print($1)}' | sort | uniq -c

    Update: added LC_ALL=C which forces hg commands to English, so you don’t have to change "date" to your language.

    It should print out the hours of the day you work most on your code (at least if you are the compulsive edit/commit type), like this:

           4 00
           2 16
          11 17
           1 18
           2 19
           1 20
           1 21
           3 22
           8 23

    (hours are on the right)

    BTW sharesource is the fastest source hosting service ever. In half an hour my project was accepted and I was pushing and pulling from the public repository. Try it if you need Mercurial hosting (but they give also SVN).

  • Feyerabend

    Qualcuno di tutti quelli che stanno blaterando su questa vicenda del papa alla sapienza ha mai letto Feyerabend? (a partire dagli “scienziati” fedeli alla ragione?)

    Credo di no. (Forse solo il papa). L’affermazione di Feyerabend a proposito di Galileo, che deriva da uno studio attento e preciso (mi verrebbe da dire “scientifico”) della reale vicenda storica, è del tutto condivisibile da chi sia dotato di buon senso. Se citare Feyerabend (un ateo, anarchico) è un reato dentro le mura di un ateneo… sarei già stato arrestato decine di volte, e volentieri. Fa sorridere che la chiesa si riduca a usare le sue argomentazioni per attaccare il mondo della scienza (o difendersi da essa): Feyerabend infatti pone le due sullo stesso piano, mettendo in guardia dalla “religionizzazione” della scienza…

    Che gli scienziati si dichiarino “fedeli alla ragione” è la dimostrazione migliore del fatto che Feyerabend avesse (purtroppo) ragione: la scienza intende sostituire la religione portandosi al suo stesso livello. Se volete un esempio di come un grande scienziato possa tranquillamente essere “infedele” alla ragione, leggetevi “Ballando nudi nel campo della mente”, del premio Nobel per la Chimica Kary Mullis. E poi riparliamo di scienza e ragione.

    Chi si scandalizza per il papa che va a parlare nelle università dovrebbe anche tenere conto degli altri scandali, ben più gravi, che avvengono nelle stesse mura: lauree comprate e vendute, gente che non fa assolutamente niente e viene pagata con le tasse nostre, gente che potrebbe fare tantissimo e va all’estero perché in Italia non viene minimamente cagata, cattedre trasmesse per via ereditaria, nepotismo, studenti che non imparano niente, docenti che devono fare anche contemporaneamente i ricercatori e i manager con mezzo stipendo, o con 7 stipendi fanno mezzo mestiere..

    Tutto questo per farti capire che, sì, la laicità è importante, la chiesa dovrebbe scomparire del tutto dalla vita pubblica italiana, il papa ha rotto il cazzo, ma non ho bisogno dell’UAAR, di Odifreddi, dell’Arcigay o di qualche altra associazione anti-clericale per essere anti-clericale, laico, ateo, e quello che voglio essere.