Hacking an IKEA mirror [part 1]

In a recent trip to IKEA, I found an interesting and very “hackable ” item: the TYNSES mirror:

hackable mirror from IKEA

hackable mirror from IKEA

[link to IKEA]

I wasn’t really interested in the actual mirror. I was after the nice metal frame. I removed the mirror, which was held in place by 6 stickers and I’m planning on making it a panel on which I will add 8 buttons connected to a raspberry pi. Then the panel will be clamped on my desk, allowing me to run things by pressing a combination of the buttons.

The buttons will be at the bottom part, in two rows. I’m thinking of having an old Nexus at the top, as a mini screen connected to the Raspberry Pi.

I will post more on this later on, as I build it.

Python and PDF

Here is an example of how to merge the first pages of a number of pdf pages into a single file.

I wrote this script, because I needed to print the first page of 200 individual files and I didn’t really want to open each one manually…

 

import os.path, pyPdf
from os import walk
 
output = pyPdf.PdfFileWriter()
original = "c:\\original\\folder\\"
f = []
 
for (dirpath, dirnames, filenames) in walk(original): f.extend(filenames)
 
for eachfile in filenames: 
	ffile = original + "\\" + eachfile
 
	if "pdf" in eachfile:
		pdf = pyPdf.PdfFileReader(open(ffile, "rb"))
		output.addPage(pdf.getPage(0))
	print ffile
 
outputStream = open("c:\\out.pdf", "wb")
output.write(outputStream)
outputStream.close()

Raspberry Pi Samba Share

My RPi is the brain of my ARK-AV-01 robot. As I currently am in the programming phase, I found myself programming it from the command line. I wanted something easier, with no login/password, so I activated samba with the following samba.conf file:

[global]
workgroup = mygroup
interfaces = wlan
bind interfaces only = yes
server string = Arkadian's ARK-AV-01
security = share
guest account = nobody
log file = /var/log/samba.%m

[Robot]
comment = Robot Control Center
path = /robot/
available = yes
browseable = yes
public = yes
writable = yes
read only = no
guest ok = yes

The above configuration allows you to connect to the /robot/ folder from any windows or linux machine.

I had to also run the following commands

sudo chown nobody /robot

and

sudo chmod 777 /robot -R

to ensure the folder is owned by user nobody and is writable.

then, just restart the samba service:

sudo service samba restart

And now you can mount the folder /robot to your windows or linux machine!
if everything works ok, make sure to add samba to the startup script:

sudo update-rc.d samba defaults

Robot Challenge 007

I had a productive couple of days. Arkadian AV-1 is now operational as a remote control vehicle.

Arduino
I’m using the StandardFirmata library on the Arduino Mega 2560, with no modifications whatsoever. It was by far the easiest way to get RaspberryPi to control the 4 motors, receive feedback from the 4 sensors (on order from Sparkfun, should be here soon) and have the ability to switch on and off the lights on the robot.

RaspberryPi
The RaspberryPi is loaded with Ladyada’s RPi distro, as it had the latest python library and a few other things that I’m planning on using later on. I have added the PyFirmata library (to control the Arduino) and the OSC library (as described previously) to receive instructions from the OSC pad.

TouchOSC
I have been using TouchOSC to create the remote control interface. My original plan was to use the Nexus tablet to control the robot. The problem is that TouchOSC is a bit behind when it comes to Android. The app is available to buy, but you cannot upload your own templates, which makes it pretty useless. I’ll be using an iPad for now, but I hope they get the android version sorted soon.

Here is my latest layout (first page):
OSC_Control_Panel_004

The two buttons under the “Quest”, are for clockwise and anti-clockwise rotation.

Vehicle is very responsive and drives really well. Orientation gets a bit tricky for the human brain if the rotation buttons are not used, but for the “Quest Mode” this will really be ideal.

I’ll post the code, photos and a video tomorrow.

Next week, I’ll finish off the sensors (proximity and compass), tidy up the cables and put everything in a more permanent position. My code needs a bit of tidying up too; it’s really a mess right now (but, hey, it works!).

Robot Challenge 005

Today I have quite a bit of work to do on this project. By the end of the day, I should have a fully functional remote control vehicle.

Earlier this morning, I finished the joystick. I will be using a Nexus 7 with touchOSC as my joystick and I put together the following layout:

OSC_Control_Panel

Rotating the “Start” icon to “Full” will wake up the robot.

The three toggle switches underneath will simply be switching between RC mode, Auto mode (just avoiding stuff) and Quest mode (which I will be able to finetune a bit better, for our competition).

The navigation buttons on the right will be doing what you expect: North, East, South, West and their combinations. The red button in the middle will be the stop button.

When the robot is ready, I will add additional pages to the remote control to increase the number of options available to the user (e.g. speech, reactions, specific moves, etc).

There is a great OSC Python library (PyOSC) which makes interfacing the Nexus with python very easy. While OSC was created to control music, you can make it do whatever you want in Python, which is really cool.

By the way, while I’ll be using a Nexus 7 tablet, it’s worth mentioning that TouchOSC works on iPhones and iPads too. Excellent app! :)