Friday, February 12, 2010

PEAK CAN Linux drivers

PEAK system provide a number of CAN cards with open-source drivers, and so far they have been working fine for us. (Unlike some other CAN cards!).

Installing the drivers is relatively straight-foward on a clean linux system (a fair bit more complicated with a Xenomai based system), but there are still a few quirks that can get in your way. I've described a simple way that works for us.

Starting with a fresh install of linux, the first thing you probably want to do is add some new users, eg:
adduser (name)
And perhaps add the user to admin group:
sudo usermod -a -G admin (name)
Then you need to make sure gcc, g++ have been installed, and the system is up to date. Having wget and a browser are always handy too. With ubuntu we can use apt:
sudo apt-get update
sudo apt-get install lynx
sudo apt-get install gcc
sudo apt-get install g++
Next, we need to ensure we have our linux header files. Find out your linux version:
uname -r
And install the linux headers, eg:
sudo apt-get install linux-headers-$(uname -r)
Now we need a symbolic link to this for the CAN driver to compile.
So you need to find your linux 'version.h' file. (You can try whereis/locate). eg, mine is at:
/usr/src/linux-headers-2.6.31-14-generic-pae/include/linux/version.h
So you need to make a new symbolic link there:
cd /usr/src
sudo ln -s linux-headers-2.6.31-14-generic-pae linux

We are now ready to compile the driver, but first, we need to get it. Go back to your home directory and download the driver:
cd ~/
wget http://www.peak-system.com/fileadmin/media/linux/files/peak-linux-driver.6.15.tar.gz
Then extract:
tar -xvf peak-linux-driver.6.15.tar.gz
cd peak-linux-driver-6.15
Now we are ready to compile! (and install the libraries)
make clean
make NET=NO

sudo make install
Now we can load the driver (if it isn't already):
cd driver
sudo /sbin/modprobe pcan
And we are all done!

Now, we can check if it is ok:
cat /proc/pcan 
cat /dev/pcan0
cat /dev/pcan1

If you have the dual-channel version you can try sending some data with a terminated CAN cable between the hardware modules. Example:
console1: cat /dev/pcan32
console2: echo "m s 0x111 2 0x12 0x34">/dev/pcan0
console1 will receive:
m s 0x00000111 2  0x12 0x34       310146 619

Enjoy!

Thursday, February 11, 2010

Drishti

Drishti is a real-time interactive volume rendering and animation tool. Paul Bourke
organized a tutorial at WASP/iVEC. The tool is developed by Ajay, a very friendly guy, and very open to user feature-requests.

Drishti has three parts, the renderer, the importer, and the painter. We only covered the renderer and importer.


The importer can import from various file formats, including standard image stacks and raw data. (unsigned characters, Z=1 .. ns
, Y=1 .. wd, 
X=1 .. ht)

To use the importer you just
 drag and drop (raw) data
, then you can adjust the top slider nob to alter contrast
, and left click to add an additional point that you can move to compress the range. You can view the data in different color spaces, and use the sliders to inspect the data. When you save you have a number of additional options including sub-sampling and filtering.



Once you have finished with importing your data and generated the pvl.nc you can drag and drop this into the renderer. Pressing F2 swaps you between high and low-resolution mode.

You can edit the transfer functions to explore the volume. The 2D version depicts the gradients of the data set, and takes a bit of playing around with before you get used to it. You can left/right click to shift the points, add points, make curves, etc throughout the selected volume. Space will bring up additional color maps. You can add new transfer functions to highlight different parts of the volume. The two sliders on the side can be used to set the alpha, and 0.5 each for a gaussian influence instead.

In low-resolution mode you can alter the bounds for the volume by draging on the sides of the box, or using the arrow keys for fine change movements.

Under the preferences tab you can set the step size (ie: quality of the render), or add an axis and labels, etc. Strange things seem to happen when you set the steps too low (< 0.2).

The final thing we discussed was creating keyframe animations. Selecting View, Keyframe editor displays the dialog. You can then click anywhere on the keyframe line, and set the viewport however you like (ie: rotate/zoom) and then click 'add keyframe'. Select another keyframe position, move the camera and add another keyframe, etc, etc. until you have the animation you like. You can move individual keyframes, or shift-left mouse to select an entire region and drag/reposition a whole group of keyframes.



To rotate the camera in another axis or to manually modify the camera positions, etc. use the brick-editor. Press 'a' to show the axis, and you can modify the axis of rotation (eg: alter 1,0,0 to 0,0,1, etc.).

Thats a fast-short introduction to Drishti. Take a look at the gallery for more screenshots and videos - unfortunately few of the fanciest features have videos.

Wednesday, February 10, 2010

Interzone Games - No more!


It is finally official. Interzone Games / Interzone Futebol is
(almost) dead
. After having heard the various horror stories for years, it is finally all out in the open. (Sumea also re-covered the story)

And with Staring Man/Spinfast loosing their lead programmer things don't look too great for the Interzone legacy right now. Still the ex-Interzoners are hardly alone, computer games have had it tough in Australia recently, Melbourne-based Transmission Games fired most of their employees, and closed its doors, Krome and Fuzzyeyes also had bad times. Seems reminiscent of the Ratbag games fiasco.

It is a shame it had to be such a public end. I still think it has helped nurture a WA-based games industry and given a lot of people some valuable experience. (Although actually RELEASING the game would have been a much more rewarding experience).

Hopefully it won't hurt future attempts - it seems WA independent game developers are doing well with a few good recent releases such as square-off, surf prodigy, and former-interzoners releasing Space Crash, pools of blood, etc..

Tuesday, February 09, 2010

Vortex Slides

Michel Carignan from CM Labs Vortex has kindly provided me with the slides to his presentation on Vortex.

edit: update, CM Labs can not publicly distribute the slides, but they are still available upon request.

Monday, February 08, 2010

4K programs

One of my favourite programming tasks is to create a program in under 4k.  This is something the Demoscene excel at (see scene.org awards).
Some of my favourites are:
Of course, achieving this seems impossible, however a few tools make this easier. I used many of these tools and tricks to create my 3kb entry to the global game jam.  First of all a drop/compression tool. Crinkler has eliminated the need for com/cob droppers and gives excellent compression. This little tool has made most of my 4k productions possible. IN4K has plenty of tools and code examples to help you learn the trade, but Iñigo Quilez has an excellent set of beginner projects. (Not the most optimized ones out there, but still a fantastic starting point).  FIT have an excellent set of demoscene resources, including source code to some fantastic 4k intros (plus synthesizers!). Ryg/Farbrausch has some interesting reads as well. The other thing that you will find when making 4K intros is the lack of maths functions (which you can get around by using intrinsics /QIfist in MSVC, or something like that), and by writing them yourself in assembly.  The next problem is often getting rid of the C standard library, in particular rand(). This is where Linear congruential generator (LCG) come in handy. This is where IQ comes handy again with a 'better, smaller and faster random number generator'. And again, this isn't the fastest or most optimal, but it will do. Finally you will probably want to allocate memory dynamically, and on Windows you can simply use: GlobalAlloc instead. (Feel free to overide operator new and use your standard C++ coding style). If your really looking to crunch size, then stick to values that will compress well (ie: powers of 2), but the latest crinkler can drop floating precision for you anyway, so I'm not sure how much you save with this trick these days...

Thursday, February 04, 2010

Catchup Post

A short collection of interesting links/articles recently:
Finally, a video of the top Tron AI from the Google AI Challenge:

Monday, February 01, 2010

Game Jam

I entered the 2010 Perth Game Jam again this year, but only had about 6 hours to put together an entry. Simon Wittber did a great job of organizing it again this year.

Simon has put up photos from Perth Game Jam, and ofcourse the Perth 2010 Game Jam games.

I put together a very simple multiplayer game for OSX, with the aim of making it into a 4k game. I managed to bring it in at around 3.5kb, but it was quite unstable.
You can download the game (Puggle) for Windows/OSX.

Below is a time-laps video of the event, I arrive at around 2:30..