Today I've been coding a bit on my KSP Control Center project. It's so far just 11 buttons, three SPI-controlled LED-displays and an analouge gauge, but it's getting closer to something more "real" every day.

It's for playing Kerbal Space Program, one of my favourite games. Heres a video of me showing of some of the new displays.

The three position switch in the video is for going between surface, target and orbital velocity. The code's on my github for anyone interested.

I store all my photos on my Fileserver. I am using an android application called Foldersync to sync all my photos as soon as I connect to my homes wifi.
This means I've got a huge folder filled with photos that rarely gets sorted properly.
This is about to change, I've created a script which can find which date the photo was taken and move it to the corresponding folder. It's a fairly simple program, it uses Identify along with awk and friends to figure out the date. I will most likely rewrite it in some other language in the future since this script is a bit barebones.
This script runs as a cronjob each night.

#!/usr/bin/env bash
/usr/local/bin/sort-jpeg.sh /export/Mnt/Photos/sort /export/Mnt/Photos/. &> /root/sortphoto.log

I still need to figure out how to make my camera autoupload photos to that folder though.

I'm redoing my whole blog-thing(again) because logging in to the server, firing up vim and writing HTML is too much of a hassle. Jekyll seems cool and I don't know ruby, so why not? This is the post-recieve-hook I'm using

 #!/usr/bin/env bash
    GIT_REPO=$HOME/blag.git
    TMP_GIT_CLONE=$HOME/tmp/git/blag/
    TMP_WWW=$HOME/tmp/www/
    PUBLIC_WWW=/www/docs/hax0r.se

    git clone $GIT_REPO $TMP_GIT_CLONE
    jekyll build --source $TMP_GIT_CLONE --destination $TMP_WWW
    cp -r $TMP_WWW $PUBLIC_WWW
    rm -Rf $TMP_WWW
    rm -Rf $TMP_GIT_CLONE
    exit

At first it didn't work and I couldn't figure out why... this is like the easiest script in the world, right? Spelling is not my thing today, although I'm usually quite good at it. post-recieve != post-receive(I even misspelled it when I wrote it just now).

My minisumo for Robot SM is getting close to done. Here's a nice little GIF-image showing the assembly process of Perfected Titan.

. All the code can be found at my Gitweb.
I've also filmed a short video of Perfected Titan which you can see below. I'll probably add another video when I've "optimized" the target finding code a bit. It's a finite state machine which reads the front sensors and decides on state from that.
It has got seven states and seven "behaviours".
One thing I did differently with the code on this robot is that I did a function for setting the "heading" of the robot as opposed to setting individual motorspeeds. This gives you some interesting "effects" for free. For example; the "search"-behaviour is this;
set_heading(FULL_SPEED,(ad_value[0] - ad_value[1])*2);
Set_heading works by taking speed and then using the second argument, heading, to calculate individual motorspeeds. In this particular case it works great because if ad_value[1] is larger than ad_value[0] heading will be negative, and the robot will weer to the left, if it's positive it'll weer to the right.

void set_heading(int16_t speed, uint16_t difference) {

        // Set heading, left = speed + diff, right = speed - diff

        int left = speed + difference;

        left = constrain(255,-255,left);

        int right = speed - difference;

        right = constrain(255,-255,right);

        set_motors(left,right);

}

The constrain() is a function that keeps a value between x, y. Nothing fancy. Set_motors() just sets motorspeed on a -255 to 255 scale, where 255 is full speed forward and -255 is full reverse.
Another interesting part of the code is the ADC-reading code. It doesn't do any Kalman filtering or anything, but it constantly reads the ADC-values in an interrupt, roughly 125kHz. It works like this



// ad_value is an array that contains all the ad values

volatile uint16_t ad_value[NR_AD_CHANNEL];

// Local values

volatile unsigned char ad_count=0;



void init_adc(void) {

        //5V AREF

        ADMUX |= (1<<REFS0);



        //AD enable, AD interrupt enable and clk/128 prescaling

        ADCSRA |= (<<ADEN) | (1<<ADIE) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);

        

        // Prepares first ad channel

        ADMUX &= 0b11110000;



        // Disable digital on the ADC-pins

        DIDR0 = 0x01;



        //Starts the first conversion

        ADCSRA |= (1<<ADSC);

}



ISR(ADC_vect){

        ad_value[ad_count]=ADC;



        if(ad_count<(NR_AD_CHANNEL-1))

                ad_count++;

        else

                ad_count=0;



        // Select ADC channel with safety mask

        ADMUX = (ADMUX & 0b11110000) | ad_count;

        

        ADCSRA |= (1<<ADSC);

}


Neat huh?

The PCB of version 2 of Perfect Titan is finished, the new robot is named Perfected Titan, since I fixed some placement issues on the PCB this time over. I also added a protection diode and "proper" connectors for LEDs. I have one pin left actually, didn't end up using three Sharp-sensors as I had originally planned, don't know where to put the third one to be honest. I'm considering putting 10 cm sensor in the back for it, haven't decided yet.
Here's the schematic
Click for a larger version
And the pcb layout
Click for a larger version
The chassi is almost finished, there will be some build log pictures up later.
I've started doing some small work on the code and realised I need a finite state machine. All computer programs is in some way a finite state machine, but using it as a design from the start is very well suited for robotics.
I looked around quite a bit for something to draw the state machine up in. The best alternative I found was Qfsm. I encourage you to try it out, a really nice piece of software. Aur-package will be avaliable, later.