Robot Control Software through Player / Stage
by Findarato on May.01, 2012, under Development, Java / Android
This semester, we had to write some Robot Control Software for a Vacuum cleaning robot based on the Player / Stage environment.
The robot is :
- Dynamically mapping the environment
- Cleaning the area while it moves along
- Avoiding obstacles when it finds them on it’s path
Everything is written in Java and pretty well documented. (Code to be added soon)
Here is a quick video of the final software running :
Android voice control
by Findarato on May.01, 2012, under Development, Java / Android
I have been playing with Android development for quite a while, but two weeks ago I finally finished my first Application. I thought that Text-to-Speech and Speech-to-Text were pretty amazingly easy to integrate and thought I could make everyone benefit from a few snippits, so here is my code (it was almost all done in a single class) :
package com.findarato.cyanide;
import java.util.ArrayList;
import java.util.HashMap;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.speech.tts.TextToSpeech.OnUtteranceCompletedListener;
import android.view.*;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class CyanideRobotActivity extends Activity implements OnClickListener, OnInitListener, OnUtteranceCompletedListener {
private static final int VOICE_RECOGNITION_REQUEST_CODE = 12345;
EditText server = null;
EditText port = null;
TextToSpeech tts = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
final Button buttonStart = (Button) findViewById(R.id.button_start);
final Button buttonStop = (Button) findViewById(R.id.button_stop);
final Button buttonSpeech = (Button) findViewById(R.id.button_speech);
tts = new TextToSpeech(this, this);
tts.setOnUtteranceCompletedListener(this);
server = (EditText) findViewById(R.id.text_ip);
port = (EditText) findViewById(R.id.text_port);
port.setText("9002");
buttonStart.setOnClickListener(this);
buttonStop.setOnClickListener(this);
buttonSpeech.setOnClickListener(this);
}
private void startVoiceRecognitionActivity() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass().getPackage().getName());
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Please tell the robot what to do.");
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 20);
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String serverString = server.getText().toString();
int portInt = Integer.parseInt(port.getText().toString());
if(requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
for(String match : matches) {
if(match.equalsIgnoreCase("start robot") || match.equalsIgnoreCase("start") || match.equalsIgnoreCase("start cleaning")) {
tts.speak("Starting cleaning now", TextToSpeech.QUEUE_FLUSH, null);
new networkRequest(serverString, portInt, "START").execute();
}
else if(match.equalsIgnoreCase("stop robot") || match.equalsIgnoreCase("stop") || match.equalsIgnoreCase("stop cleaning")) {
tts.speak("Stopping cleaning now, returning to my charging dock.", TextToSpeech.QUEUE_FLUSH, null);
new networkRequest(serverString, portInt, "STOP", true).execute();
}
}
super.onActivityResult(requestCode, resultCode, data);
}
}
@Override
public void onClick(View v) {
String serverString = server.getText().toString();
int portInt = Integer.parseInt(port.getText().toString());
switch(v.getId()) {
case R.id.button_start :
new networkRequest(serverString, portInt, "START").execute();
break;
case R.id.button_stop :
new networkRequest(serverString, portInt, "STOP").execute();
break;
case R.id.button_speech :
HashMap<String, String> extra = new HashMap<String, String>();
extra.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "start voice recognition");
tts.speak("Hello master, what would you like me to do ?", TextToSpeech.QUEUE_ADD, extra);
break;
default:
break;
}
}
@Override
public void onInit(int status) {
// TODO Auto-generated method stub
}
@Override
public void onUtteranceCompleted(String utteranceId) {
if(utteranceId.equals("start voice recognition"))
startVoiceRecognitionActivity();
}
}
The interesting parts are the methods startVoiceRecognitionActivity() and onClick(View v) -> switch statement R.id.button_speech
Clean up your files (Linux)
by Findarato on Apr.14, 2012, under Uncategorized
Today I wanted to clean up my computer a bit and decided to finally tackle my files.
Over time, I have accumulated duplicated files and empty folders and it was starting to irritate me to “think” I had saved something (because I saw the folder), only to realise the folder was empty (bad backup over the years, didn’t restore the files within it for example). So I decided to get rid of all duplicate files and empty folders. Here is how I did it :
Delete empty folders
find ~/ -type d -empty -delete
Find duplicate files
fdupes ~/ -r >> duplicate_files.txt or fdupes ~/ -r -d (to get prompted to delete the found files)
Hope this is useful to someone.
London Java Community and user groups in general
by Findarato on Mar.18, 2012, under Business management, Development, Life in London, Technology
A couple of weeks back, I made my way to my first user group ever. As I had attended some more business-oriented user-groups in the past, I was hoping it wasn’t going to be the same kind of boring network-only type of event. I went there because I had some spare time and I had heard a lot about these user groups and wanted to check it out for myself, but didn’t expect much of it : I was wrong.
I was in a period where I was considering the best routes I could take to further my career development (the famous education vs experience debate) and really needed some external views to help me decide. From the organizers of the events to the actual users, everyone was completely available. I found that the value of the events depend on your own actions, daring to approach person XYZ to simply have a chat with them.
After having attended 3 events, I can surely say that I have already benefited a lot from everyone present, their advice and simply their company. I will definitely turn up to many of them in the coming years and invite all skeptics to try it out at least once rather sooner then later !
Start-up weekend Geneva 2011
by Findarato on Nov.21, 2011, under Business management
I am currently at the airport, after a pretty intense weekend in Geneva : start-up weekend.
The idea is that for 54 hours, you do nothing but work on new ideas with a group. You develop them to get to a stage where you think they might be viable and you come up with ways to make them work. At the end of the weekend, you present your project to a jury through a small presentation and see what others think of it.
I ended up with a project that looks into last-minute hotel deals. I developed a prototype Android app (I was surprised I got this running within 2 days, but for some magical reason, it worked during our presentation), while others were working on the business model, the marketing plan and the development strategy.
The whole experience has been wonderful to me. You meet many entrepreneurs and like-minded people that want to make a difference and create their own jobs out there. I would definitely recommend it to anyone who thinks of him / herself as an entrepreneur !
Installing Player / Stage and development tools on Fedora 15 through Virtualbox
by Findarato on Nov.01, 2011, under Development, Linux
After quite some struggles, I finally managed to get the Player / Stage stack installed exactly the way I wanted it. It gave me quite a headache, so I thought it would be a good thing to share (so other people don’t have to go through the same thing).
First of all, my perfect setting was to set my environement up through VirtualBox. This is because Player / Stage is still quite rough and requires packets and tinkering I did not want to occur on my stable work machine. However, I wanted to develop through my normal Eclipse (in my host operating system) as that was already all set-up and I didn’t want to get into performance issues through the Virtual Machine. Knowing all of that, I made the following choices :
- Virtualbox
Easy to install, widespread and I knew it already - Fedora 15
This was an easy choice, as it was recommended on the player / stage download page – Fedora already has the player / stage packets in it’s official repositories, making things a lot easier. - OpenJDK
I wasn’t 100% sure it would all work on OpenJDK, but I wanted to try and… it all worked out for the best
(so no need to install the Oracle Java dependencies) - Shared folder of my Eclipse workspace that could be accessed directly through the virtual machine
That was my perfect setting and it turned out not too hard to set up.
Further along this article, I explain what problems I had. This can be helpful if you have specific questions, but here is the full set of instructions to get everything working :
- Download the Fedora 15 CD image from their website and install a clean virtual machine
Be sure to allocate enough space to the root partition for installation of different packages (I allocated 3.5 GB) - Prepare fedora to install VirtualBox Guest Additions
yum install kernel-headers kernel-devel - Reboot
- Install gcc : yum install gcc
- Install VirtualBox Guest Additions
- Install player / stage
yum install player player-devel player-doc player-examples player-python player-ruby
yum install stage stage-devel stage-playerplugin
For more information on this step, see here : http://playerstage.sourceforge.net/wiki/Download - Install OpenJDK and all Java utils you will need (through “Add software GUI)
- Shut down machine
- Go to “settings” in your Fedora VirtualBox and add your workspace as a shared folder. Select “auto-mount”
- Start your Fedora VirtualBox
(You can now find your folder under /media) - Run “system-config-users” and add your local user to the “vboxsf” group
- Done !
The problems I encountered
- Player wouldn’t show my robot
It was really weird when everything seemed to work, but for some reason Player wouldn’t show my robot (a little red thing driving around). This was very easily fixed by installing the VirtualBox Guest Additions - Guest Additions wouldn’t install properly
I needed to install kernel-headers and kernel-devel first, for Guest Additions to install correctly (‘yum install kernel-headers kernel-devel’ -> reboot) - I couldn’t access my shared folder
I needed to add my personal user (under the fedora virtualbox) to the vboxsf user group
The hidden truth behind the iPhone 4s Sales
by Findarato on Oct.21, 2011, under Business management, Technology
The last couple of days, everyone I know of and anything I read on the internet is about “how great the iPhone 4s sales are”. People are taking a number of “4 million iPhones sold” and make it look like this is a huge number compared to the sales of the iPhone 4, implying some sort of improvement on apple’s side, getting peopple even more interested in it’s phone. However, people forget that it is so easy to lie or to fool with statistics and that, in economics (and any science for that matter) you can only compare numbers “everything else being equal” and that’s just what I’m going to do here.
There are multiple factors we should take into account to really compare the launch sales of the iPhone 4 and those of the iPhone 4s :
- The growth of the smartphone market
The smartphone market grew by between 50% and 70% from mid 2010 to mid 2011. For the two launches to be compared, this has to be taken into account (there are more people interested in smartphones in general, making it a lot easier to sell them). This number becomes even more impressive if you combine it with point 2 -> it didn’t take a year, but 16 months to get the new iPhone 4s, so the smartphone market grew between 66.5% and 93.1% in that time. - The gap between the iPhone 4 and the iPhone 4s
When the iPhone 4 came out, it was 1 year after the iPhone 3s. The iPhone 4s, however, came out 16 months after the iPhone 4. This means that 33% more people came to a natural end of their 2 year contract. These are people that naturally waited for the new iPhone to come out before signing a new contract. - The countries in which the phone was available on launch
The iPhone 4 was only available in Britain, France, Germany, Japan and the U.S. upon launch. This is a total population of 641M people. The iPhone 4s, however, was available in the same countries plus Canada and Australia, adding another 56M people (8.7% more)
Now that we have all of those factors that have nothing to do with the iPhone 4s itself, we can go ahead to really compare it’s sales with the iPhone 4.
- Sales of the iPhone 4 on launch (first weekend) : 1.7M
- Taking into account factor 1 (smartphone growth) the sales, if they were to be kept equally popular, should be : 1.7 * 1.665 (I am playing it safe here, going with the smallest estimate) = 2.83M
- Taking into account factor 2, the additional people with a new contract to sign : 2.83M * 1.33 = 3.76M
- Taking into account factor 3, the additional people available due to the fact the phone got launched in more countries : 3.76M * 1.087 = 4.09M
This means that, if you factor in all the external developments of the smartphone market development, the iPhone 4s sales were actually less then what they would be if the iPhone 4s was as big a success as it’s predecessor. By taking into account all of these factors, we can easily define that the iPhone 4s was definitely less of a success then the iPhone 4 on it’s launch and that is without waiting to see what the sales numbers are in the first months. If the pre-orders are this much, but people are not buying them directly in the stores anymore, the total sales might be even worse…
I really don’t get why nobody has taken the time to actually analyse these numbers and blindly take the fact that “the iPhone 4s was such a success, it sold more then doubled the iPhone 4 sales”… Yes, it’s mathematically true, but economically, the picture is a very different one…
Sources :
- http://gigaom.com/apple/1-7m-iphone-4s-sold-in-first-weekend-most-successful-apple-product-launch-ever/
- http://www.ft.com/cms/s/2/0aa2a7a6-f8de-11e0-a5f7-00144feab49a.html#axzz1bOvFaIN2
- http://mashable.com/2011/05/06/samsung-htc-apple-smartphone-market/
- http://www.engadget.com/2011/05/06/idc-smartphone-market-grows-80-percent-year-on-year-samsung-sh
Ubuntu Broadcom Wireless problem (specifically with Samsung 900x3a)
by Findarato on Oct.17, 2011, under Ubuntu
I have had quite some problems with my Samsung 900x3a and it’s wireless adapter. For some reason, it showed up the wireless connections fine, but it wouldn’t connect to encrypted networks. Sometimes, if I tried a couple of times, it would suddenly manage to go through. However, I now have a solution which seems better (not perfect, but better) which was mentioned on the Ubuntu help pages : switch off and back on your wireless card !
I had tried everything from uninstalling, re-installing the proprietary driver, downloading a new version, etc. but this simple solution did it in the end…
This helps me get around the problems and everything is working now. Hope this helps someone else out that is having the same problem I was
.
Edit : I just found out another thing that was a problem for me : IPv6 ! For some reason I couldn’t figure out, my laptop would now connect to every network, except for my home wifi (BT Home Hub). By going to Network Manager -> IPv6 Settings and selecting “Ignore”, I have NO MORE WIRELESS PROBLEMS
.
Joomla permissions fix script
by Findarato on Oct.16, 2011, under Development, Joomla, Linux, Ubuntu, Uncategorized
As I’m doing quite some Joomla development, I wrote this small script that could be used for multiple purposes. It takes 1 parameter which is the directory of your joomla installation (I restrained it within the “/var/www/” directory, as a precaution, but you can get rid of this) and then goes through folders and files to change their permissions. Hope it’s useful to someone :
#! /bin/bash
# This script simply fixes the permissions on a Joomla install to be perfectly $
# Need at least 1 parameter, which is the joomla root directory
MINPARAMS=1
DIRECTORYPARAM=$1
if [ ${DIRECTORYPARAM:0:9} == "/var/www/" ];
then
if [ $DIRECTORYPARAM == "/var/www/" ];
then
echo "The directory CANNOT be /var/www/ itself"
else
find $DIRECTORYPARAM -type d -exec chmod 755 {} \;
find $DIRECTORYPARAM -type f -exec chmod 644 {} \;
fi
else
echo "The directory can ONLY be in /var/www/"
fi
First impressions on Ubuntu 11.10
by Findarato on Oct.16, 2011, under Linux, Open Source, Ubuntu
Two days ago, I decided I would give Ubuntu 11.10 a try as my full-time desktop. As I was already running 11.04, I started the update process hoping it would go without a problem. Of course, I was wrong…
Luckily, I made a backup of my files and proceeded to a clean install of Ubuntu 11.10. However, to my big surprise, WIFI wasn’t working at all suddenly… It took some figuring-out, but I now have a working instance of the new OS and am pretty happy with it. Here are some of the features I like most :
- Thunderbird over Evolution. This is a major step in the right direction. Evolution was starting to become very slow and searching wasn’t very effective. This is the kind of change that makes my day a lot easier
- Gnome 3. I have been a major fan of the new Gnome 3 and have tried to install it multiple times under Ubuntu 11.04, without real success (there was always something wrong). Now it comes out-of-the-box, it works and all I have to do is install the “gnome-shell” for my lovely new interface to appear !
- Login-screen. I know this is not necessary, but it’s simply nice. For once, the Ubuntu design team have done a really good job here.
- The Ubuntu Software Center. It has had a major overhaul and is a lot clearer to navigate, rate, install, remove and everything else you would want to do with it.
- New PhpMyAdmin in official repositories. I konw this is not a direct feature of the Ubuntu team, but as a web developer, this surprised me in a good way. A new and clean user-interface to deal with, finally making the old one obsolete.
The things I don’t like :
- The Ubuntu Software center. I know, I also put this in “the things I like”, but that is because it does come with one MAJOR drawback : speed. For some reason the Ubuntu Software Center is starting to become very slow for me and they should pay real good attention to that (I mean, I am running on a fairly new computer that should have no problem running this at all, and it still takes a couple of seconds to load -> more then ANY other application on my computer).
I will continue to add to this list over time and hope it helps you decide if Ubuntu 11.10 might be your cup of tea