Tuesday, 17 May 2011

Very Simple Fractal

On my way to geek martyrdom (PhD viva approaching) I'm finding myself becoming increasingly interested in fractal functions.

Here's my first attempt at coding a fractal in Matlab, which was done on my lunchbreak today.



It's based on a tiny part of the Mandelbrot set, which I've still not fully read into yet (I'm impatient!).

Here's the code, I told you it was simple! So simple in fact that it..soon...becomes.....pretty..........slow.............

clc         % clear command window
clf         % clear figure

z_old = 0-0i;   % Some random value to initialise z_old

for (seed = 0.01:0.005:0.2) % For all these values
   
    disp(seed)   % Display seed (not the right term)
   
    z0 = -seed - 0.54i; % The juicy bit
    z = 0;              % Start here
   
    rndclr=[rand, rand, rand];  % random line colour
   
    for (i = 1:1:50)   % number of iterations per seed
        z = z^2 + z0;   % iteration for the nation
        %disp(z);
       
        figure(1)
        hold on     % don't delete old lines
        title(i)    % display iteration
        plot(z,'.','color',[0,0.1,0]);  % draw a point
       
        if (i>1) % if point has a predecessor, connect them together
            line([real(z),real(z_old)],[imag(z),imag(z_old)],'Linesmoothing','on','color',rndclr)
        end
       
        z_old = z;  % Store last point
       
    end

end
   

Friday, 6 May 2011

3D Graph, meet 3D Printer

So awhile back I ran a stand on robotics and my PhD resarch at a Bristol University public engagement event Changing Perspectives.

One of the most visually assertive parts of my research in robotic movment have been the 3 dimensional plots I use to represent effort considerations in reaching motions. The idea is that the workspace of the robot makes up 2 axis on the graph, while the other axis represents the effort (a combination of graviational and muscular considerations). When planning movements to vertical targets, the robot can aim to keep it's trajectory in the lower parts of the graph, thus reducing effort during movement, as in casual human motion.

Some people find the concept of a 3D graph quite hard to grasp, which is fair enough, so I decided that a nice way to engage the public would be to make the graph tangible. Hence I had it 3D printed.


To make it more inutitive  I then created a contour 'heat' map of the simulation, which I projected onto the surface. This meant that points of high effort were highlighted with 'hot' colours, while low regions were coloured with colder shades of blue. Really this could of done with some projection mapping, but I didn't have much time.


Finally, I simulated the robot moving accross the surface in real-time to give the whole thing some motion and context. Unfortunately I was too busy chatting to the visitors to get a video of the projection on the graph, so here's the raw video:

The Question in Disability Now

Despite many things happening in the last few months (such as handing in my thesis), I've been very poor at updating this blog.

Here's a link to an article on The Question I just discovered in the magazine Disability Now. The Question was a collaborative piece I did with Extant last summer, where we developed the Haptic Lotus.

Here's a snippet from the full story:

Arguably one of Extant’s most breathtaking (and currently on-going) works to date, The Question (2009/2010) utilises the Live Art concept with open arms. It has everything: the tactile audience experience, the walk-through installation, the use of audio and live performers.

Monday, 14 March 2011

Generative Triangle Patterns

Inspired by the creations of my friend Soulwire, I spent a couple of hours last night coding up a simple algorithm that generates patterns from joined equilateral triangles. A random variable acts on the hypoteneuse of the triangles in 10% of cases, making the triangles shrink in size and lean, occasionally.

I've written it in Matlab for now (great for prototyping algorithms) but will probably switch to something more visually elegant (e.g. Processing / Open Frameworks) later.

It needs work but here are some initial images. Click to view larger.


Friday, 11 March 2011

Dynamixel Master / Slave network with Matlab

Following my last post I've now got two dynamixels working on the same network with Matlab. The flexibility of these servos means that one can be used just as a position sensor. This lets you do some cool stuff, like this simple tracking controller, where one servo follows the other. This is known as a master / slave network. The moving one is the slave as it obeys the master.



To make this work you need to set the ID of each dynamixel differently. This is obvious, but without the Dynamixel Wizard from Robotis (which didn't work on my machine) I had a hard time trying to figure out how to make this happen. In the end I discovered that by using the following command with an ID of 254 you can broadcast a new ID to every servo on the network.

(calllib('dynamixel','dxl_write_byte',254,3,new_ID))

So, just connect one servo to the network and broadcast it a new ID!

The Matlab source code for the master slave demo can be downloaded here.

IMPORTANT! - You won't feel the forces from the slave servo on the master. Do not stick your finger or anything else in the way to check!

Monday, 7 March 2011

Simple Dynamixel / Matlab Example Code

Recently I started working with a some Dynamixel RX-28 servos from Robotis. Unlike standard hobby servos, these actuators can provide position, current and velocity feedback and also have various modes of control, including compliance. They also work on a RX485 network, meaning that they can be chained together. These features make the servos a popular choice for building small humanoids, such as the Bioloid (also from Robotis).

Though a MATLAB API is available, I found the on-line examples lacking somewhat, especially when all I wanted to do was drive the servo and log its position. The following code does just that, moving the servo 90 degrees clockwise and anti-clockwise, then displaying a log of the 'present position' and 'moving' registers from the servo EEPROM.
The 'Moving' register is set to '1' when the servo is in motion. This is a bit buggy though as you need a delay in the code for it to read anything other than '1' and it doesn't exactly stop on time. Matlab isn't hard real-time so this pause seems to affect the data logging somewhat (the motion is actually really smooth, unlike what is shown above). Take the 'pause(0.01) out of the code below and you'll see what I mean

Note that you'll need to download and register the dynamixel API with Matlab before using this code.
Here are the instruction from ROBOTIS:
http://support.robotis.com/en/software/dynamixel_sdk/usb2dynamixel/windows/matlab.htm
These instructions from Agave Robotics are also useful
http://www.agaverobotics.com/products/servos/robotis/ax12/docs/Dynamixel-AX12-Matlab.pdf
Note that I had to change the 'open  device' code from the examples given above. They just wouldn't work!

I hope this is useful to someone, I spent some time searching for an example like this but couldn't find one. Of course the dynamixel servos can do much more than this but this is a nice place to start.

The source code can be downloaded from Google Docs here.

Thursday, 24 February 2011

Changing Perspectives

My PhD research (on natural reaching in humanoid robots) is going to be presented at a University of Bristol public engagment event in late March featuring live acrobats from Circomedia!

Image from http://www.circomedia.com/

Here's the blurb:

Come along to a free, interactive exhibition for families. Watch aerial circus performers, learn about how they accomplish their extraordinary feats and discover how your body works with TV presenter Alice Roberts. Take part in body painting and talk to local researchers from the University of Bristol about cutting edge research – in anatomy and physiology, neuroscience, robotics and biomechanics – happening in your city.

More information to follow. Here is the website of the event:

http://www.bris.ac.uk/changingperspectives/projects/experience/