Thu Apr 11 13:13:58 CEST 2013
Minisumo; Perfected Titan
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;
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
Neat huh?

. 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?
Mon Feb 18 23:46:11 CET 2013
Perfected Titans PCB
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
And the pcb layout
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.
And the pcb layout
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.
Fri Jan 18 03:30:40 CET 2013
Film of my robot at SRC 2012
It's a bit late, but here's a film of my robot, Perfect Titan, at Stockholm
Robot championship 2012, I'll do a proper write up about it later when I've
finished my current build.
It's powered by two FingerTech
Gold Spark 63:1 motors with FingerTech
Cobra wheels. They're a fantastic combo, my next build; Perfected
Titan(since it's sort of like v2.0 of Perfect titan) will have the 50:1 Gold
Spark motors and Cobra wheels. Crazy grip in those wheels.
Here's a picture of Perfect Titan:
The big blob in the front is a bunch of sinkers made for fishing I bought
for cheap at Överskottsbolaget held together with shrink tube and tape.
The big blob in the front is a bunch of sinkers made for fishing I bought
for cheap at Överskottsbolaget held together with shrink tube and tape.
Thu Sep 27 06:03:14 CEST 2012
A Makefile template for working with the Arduino Uno
I've more and more started using plain C on my Arduino, because timers etc.
One big caveat I encountered was writing a good Makefile.
Therefore I'll share my own makefile with you.
Tue Sep 18 20:04:45 CEST 2012
Setting up a personal wiki
My current notetaking and information system consists of assorted postit-notes
in my jackets pockets and textfiles with names like "hej", "file123" and
"notes_lol". This is (for obvious reasons) not a very good system. So I've
decided to set up a personal wiki. I first tried Zim which seemed quite good
but didn't suit my needs very well. I've decided on DokuWiki as the wiki engine and
Lightttpd as the webserver.
The first thing we need to do is installing both the packages, this is done
with the command
You also need to set open_basedir to include your dokuwiki-install-folder. After that, you should have nice wiki running at http://localhost:80
$ sudo pacman -Syu dokuwiki lighttpd php-cgiAfter this is done we need to configure lighttpd. Add these lines to fastcgi.conf
server.modules += ( "mod_fastcgi" )
#server.indexfiles += ( "index.php" ) #this is deprecated
index-file.names += ( "index.php" )
fastcgi.server = (
".php" => (
"localhost" => (
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/run/lighttpd/php-fastcgi.sock",
"max-procs" => 4, # default value
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "1", # default value
),
"broken-scriptfilename" => "enable"
))
)
And then in lighttpd.conf add this line:
include "conf.d/fastcgi.conf"
You also need to set open_basedir to include your dokuwiki-install-folder. After that, you should have nice wiki running at http://localhost:80
Sun Aug 26 03:47:35 CEST 2012
Minisumo fights from Robot-SM 2012
I've had this video uploaded for about a week, just forgot to write about it
here.
Some mini-sumo matches to get you warmed up before Stockholm Robot Championship 2012. I
hope to see a lot of people there. I'm going to participate in minisumo,
linefollowing and possibly the "Folkrace", we'll see if I find the time.
Sun Aug 26 03:41:06 CEST 2012
Automatic comment insertion with vim
Always wanted to have that cool IDE-feature of automatic comments in your
newly created source-files but can't stop using vim as your IDE? Now you can
have both!
First; create a file named c_template that you put somewhere(I put mine in
~/.vim/templates) that contains the following
:insert /* * File Name : * Purpose : * Creation Date : * Last Modified : * Created By : * */ .Then, in your ~/.vimrc insert the following somewhere
" To automatically put a comment in a new c-file
autocmd bufnewfile *.c so /home/yourusernamehere/.vim/templates/c_header.txt
autocmd bufnewfile *.c exe "1," . 8 . "g/File Name :.*/s//File Name : " .expand("%")
autocmd bufnewfile *.c exe "1," . 8 . "g/Creation Date :.*/s//Creation Date : " .strftime("%d-%m-%Y")
autocmd Bufwritepre,filewritepre *.c execute "normal ma"
autocmd Bufwritepre,filewritepre *.c exe "1," . 10 . "g/Last Modified :.*/s/Last Modified :.*/Last Modified : " .strftime("%c")
autocmd bufwritepost,filewritepost *.c execute "normal `a"
Now, open a new file called test.c, neat huh? Write some text in it, save it and reopen. Now the Last-Modified : should be right as well, it's like magic!
Sun Aug 12 15:08:12 CEST 2012
Finally!
I've pulled my thumb out from my arse and put together a video with "Super
Sumo" fights from this years Robot SM.
The Super sumo fights are mostly Horus Lambda. Enjoy!
3kg sumo or Super sumo:
Wed Jun 13 22:31:54 CEST 2012
Arduino code!
I've finally added all my Arduino-code to my git-web.
There's quite a bit off "odd" code there that I've used for testing various
things, but there's some interesting code there too, the things I'm most
satisfied with are the Maze-solving
code and the Line-following
code.
Enjoy!