Recording high quality videos from Matlab plots

To record high quality video use export_fig method to generate antialiased bitmap out of the current plot and construct a video frame out of it. To render any size of plot hide the plot window and set the window size. To prevent plot cropping use -nocrop option for export_fig.

Example code:

aviObject = avifile('myVideo.avi');
writerObj.FrameRate = 20; % Optional
for i=0:100
    set(gcf,'Visible', 'off', 'color', [1,1,1], 'Position', [1, 1, 1024,768]); 
    F = im2frame(I);
    aviObject = addframe(aviObject,F);
aviObject = close(aviObject);

Remote backup using rsync

To backup files on a remote server with sudo priviledges (on the server) first add the following into the /etc/sudoers file:

ALL= NOPASSWD:/usr/bin/rsync

Then backup the files from the local machine using:

rsync -atz -e "ssh" --rsync-path="sudo rsync" ./local_directory user@server:/path_to_backup

Cheap small cameras for robots

The cheapest source of cameras for robots are broken laptops. In most cases the built-in web camera of a broken laptop is functional and can be easily extracted. Furthermore, most laptops use USB cameras. It is therefore just a matter of replacing the connector and using the camera on a robot (see image below).

I have used a camera from a Sony Vaio on a KUKA YouBot rear bumper.

PS: The laptop speakers are also useful for making the robot talk.

Robots, smoke and lasers

As a part of a proposal for a project about improving accuracy of radiotherapy delivery system using a dexterous robot I got to perform an experiment with KUKA LWR 3 arm and a laser inside a smoke chamber. The aim of this experiment was to show we can use a dexterous robot to track a moving target while optimising the exposure to radiation by exploiting the working envelope of the robot. The robot is using Approximate Inference Control (AICO) to track the moving target while following a sample trajectory around the body. The motion of the target is a recording of respiratory motion of a real patient. During the experiment on the real hardware a respiratory motion simulator (phantom) has been used (courtesy of the Edinburgh Cancer Centre at Western General Hospital). The experiment was a success (see video below).

The biggest issue was to stop the smoke from triggering the fire alarm in the building. A smoke chamber was therefore built around the robot.

Unfortunately the respiratory motion simulator has a acrylic body which cased severe refraction and reflection of the laser beam (see image below). Fortunately the thick atmosphere inside the smoke chamber made the incident laser beam visible so the tracking behaviour can still be confirmed visually. This pilot study/experiment has been conducted under severe time constraints. The actual experiments validating our method will involve placing a light sensitive array on a moving tray (removing the acrylic body and thus the undesired optical phenomena).

Adding objects with a custom label into a ListBox in C#/.Net

A .Net ListBox can contain elements of any class by using the template collection class List<>.

The ListBox will display labels by iterating through the list and calling the ToString() method of each element.

You might want to change this label for your own classes by overriding ToString() method, otherwise you end up with labels such as “Namespace_name.Object_name”.

Exporting high quality matlab figures

Download export_fig toolbox/source from

Export current active figure using:

set(gcf, 'Visible', 'off', 'Position', [1, 1, width, height]); % 'width' and 'height' are the desided size in pixels
export_fig('pdf', 'transparent', filename, gcf);

or change output format:

export_fig('eps', 'transparent', filename, gcf);