May 19, 2009

A very quick, easy to embed, web management interface for Java

I've been trying to come up with a very simple way of managing a Java-based server application i've written.

My first port of call was JMX, which worked very well locally (using JConsole)  but it seems RMI requires ports both-ways and this limits it's usefulness over the internet, as i'd ideally like to manage the server (should the need arise) from my G1.

Next step was to try using the HttpAdaptor from MX4J, which worked fairly well but meant I really needed to code up a web interface to connect to it and that was a little more work than i'd anticipated.

On a side note, an awful lot of projects dealing with JMX seem to have been discontinued or abandoned. Even Sun's own OpenDMK seems to have been last released in 2007.

With those options discarded, I present, Trivial Manager!

It's designed to be very easy to embed (the servlet is a single Java class). Essentially, you create two things:

# A Java Interface to describe the methods you wish to present in the management app
# A Java class implementing the above management app

You then create the Servlet, passing the interface and an instance of the object to it in the constructor.

You may ask, how is embedding a servlet in to your application a quick solution? That's where Jetty comes to the rescue.

As an example of embedding Jetty and using TrivialManager, here is a few bits of code:

public interface TestInterface
   public void doSomething() throws Exception;
   public Collection<String> getSomethings();
   public int startParty(String name);
   public void countPeople(int whiskers);
   public Map<String,Integer> getIDs();

public class TestClass implements TestInterface
   public void countPeople(int whiskers)
       System.out.println("Whiskers: " + whiskers);

   public void doSomething() throws Exception
       System.out.println("Call to doSomething");
       throw new Exception();

   public Collection<String> getSomethings()
       List<String> vals = Arrays.asList("Testing", "Lalala", "1231223523", "Foomoo");
       return vals;

   public int startParty(String name)
       return 42;

   public Map<String, Integer> getIDs()
       Map<String,Integer> map = new HashMap<String,Integer>();
       map.put("foo", 123);
       map.put("rgaehre", 426432643);
       return map;

and finally, here's what goes in to your main code:

Server server = new Server(8080);
Context root = new Context(server, "/", Context.SESSIONS);
root.addServlet(new ServletHolder(new TrivialManagerServlet<TestInterface>(TestInterface.class, new TestClass())), "/*");

The end result is:

Trivial Manager screenshot

TrivialManager currently supports taking Integer, Double and String parameters.. and returning anything with a String representation, as well as Maps and Collections, which it renders as tables. I leave security and authorisation as an exercise to the reader.

The code is available:

You'll want to grab Jetty too (jetty.jar and jetty-uti.jar will need to be in your classpath).

The TrivialManager code is under MIT. Enjoy.

January 22, 2007

The tropical fish post

I thought i’d break briefly from robots.

I keep tropical fish in my flat, two Guppies, six Albino Corys and two Apple Snails in two tanks (one 56L and one 12L). At the moment, all but one of the snails is in the big tank.

Today I finally found some cory eggs in my big tank (they’d have to be, guppies are live bearers) in the corners. I’ve been trying to get them to mate for a while, with small water changes and lowering the temperature of the tank slightly. It seems to have worked.

My only dilemma now is what to do with the eggs. If I leave the fish in the tank, the fry will probably be eaten. I may buy a plant for the corner and try to give them some cover, i’m not sure.

Anyhow, I thought i’d ‘share’ a few photos.

My main tank (you can see my male guppy in the picture, above the castle):
Tropical fish tank

Corys at play:
Corys at play!

A few corys and one of my apple snails:
Corys and snail

More corys at play under the heater and filter:
More corys at play

Fish eggs:
Albino cory eggs

That’s probably more than enough about fish for one day..

January 18, 2007

Optical tracking

We took the lawnmowers out for a run a couple of days ago to collect some test data for analysis.

We attached a camera (A Panasonic NV-GS11) to each of the lawnmowers using a ‘magic arm’ and then took them for a drive around on the patch of grass just outside the IMC (next to DCS).

At first glance the images are interesting, there’s far more motion blur than I had anticipated though this is largely down to the NV-GS11 being a consumer camera and not designed for machine vision. We do intend to eventually use a proper machine vision camera which will give us control over shutter speeds but deciding what we need in terms of performance requires some pre-requisite work.

For an idea of the images:


Optical tracking image


Optical tracking

I’m hoping to adapt an implementation of the Kanade-Lucas-Tomasi feature tracker to provide tracking between frames which should allow the extraction of movement data.

If anyone’s looking to play around with this kind of stuff there’s a great public-domain KLT implementation at . You essentially feed in an image, it selects N features to track and then lets you find out their movement frame-to-frame. Quite useful.

January 04, 2007

Introducing the mowers

Seems like my plan to blog my PhD progress stumbled a bit. Here’s an attempt to restart it.

The mowers

We’ve now got two mowers in the project, both of which we hope to turn in to autonomous robots.

The first is the Ransomes Spider, a remote control mower:

Ransomes Spider
Ransomes Spider

The second is the newest addition, the Jacobsen E-Plex II. The E-Plex is a ride-on mower.

Jacobsoen E-Plex II
Jacobsoen E-Plex II

We’re hoping to mount a Sick PLS devices to them. These are proximity laser scanners, you hook up to them via RS232 (serial) and get two sets of 180 values every second, representing the distance for each degree of their view, along their 2D plane.

Sick PLS

Well, that’s all for now. My first task this week is to get familiarised with the E-Plex II and then figure out how to mount the Sick PLS scanners.

November 07, 2006


I guess my promise of writing up things on the 1st of November didn’t really materialise but I thought i’d take a stab at it now.

My PhD’s in the Warwick Automation Research group, we’re on the second floor of the International Manufacturing Centre, overlooking Computer Science and Maths.

One of our projects and the area i’m involved in is the design of autonomous robots.

At the moment we’ve got one of these:

Ransomes Spider lawnmower

and we’re getting a ride-on purely electrical lawnmower (EPlex II) courtesy of Ransomes in a fortnight’s time.

The aim is to turn both in to autonomous robot platforms that can then be adapted to perform specific tasks like keeping a golf course cut and helping farmers with pasture management.

To start with, we’ve got four of these (though one’s refusing to work properly):

Sick PLS

They are proximity laser sensors. Nifty devices, not little or light though. They scan the 180 degrees in front of them and return you sets of 180 values (one for each degree) twice a second over rs232. Each value represents the distance at that position. It only functions in an x-y plane but gives enough information to make a reasonable last-ditch safety system preventing the robot from colliding with obstacles.

We are toying with the idea of using a single Sick PLS sensor to map out the ground ahead of the robot. This could be used to aid the eventual vision system.

The first problem i’m focussing on is that of getting accurate positioning information for the robot. While GPS can give us a rough position (assuming we can see a couple of satelites) as we can’t rely on having differential gps correction signals available, we need to incorporate other methods.

One of the possible methods is to attach magnetic strips and sensors to the Spider’s wheels and drive chain in order to get odometry information that can be used to ‘fill in the gaps’ (or be used with a Kalman filter) to better calculate the robot’s position.

Another possibility is borrowing an idea from the world of computer mice. Modern optical mice are pretty neat little devices. Wikipedia have a little section on optical mice . Essentially, they involve tiny cameras (normally only 15-20 pixels square) at very high frame-rates (1000fps+). They compare successive pictures from the cameras to figure out how far and in which direction you’ve moved.

I’m currently investigating doing just that but with a high-speed camera mounted perpendicular to the ground off to the side of the robot. This has the advantage that it, as a sensor, could be move from one platform to the other with ease. At the moment, i’m looking in to methods such as optical flow in order to work out movement.

I went to Abbey Fields this afternoon to take lots of photos of grass. That got some odd looks.

I’ll let people know how experiments are going at the end of the week.

October 31, 2006

Last week

A quick recap over the past week.


First up there was the Linux User Group (LUG) trip to LinuxWorld on Wednesday. After a few major unfortunate hiccups with transport organisation a few of us drove down to the event.

LinuxWorld seems to have grown in size significantly since last year and it was good to see lots more smaller businesses with actual Linux focus attending rather than bigger companies with obviously no real interest trying to ride the wave.

Just a note to any businesses planning to have stands at exhibitions any time soon. Make sure the people at the stand understand what your business is actually trying to sell (and if you don’t, stop attending exhibitions and start coming up with a business model). Giving a free soft toy goat to anyone querying what exactly your company provides and shoo-ing them away doesn’t fool anyone. That and turning up to LinuxWorld with a massive plasma screen and an XP machine running IE and Powerpoint is just asking for trouble. You know who you are.

Compsoc LAN

The second event of the week was the Computing Society’s twice-termly LAN gaming events. Generally they involve everyone bringing their computers over to Lib1/Lib2 for the 48 hours over a weekend. The first one of the 06/07 took place last weekend and, as nearly every LAN in recent memory, was over-subscribed with about 50 members in attendance.

A nice change for this LAN was the increased gaming on consoles. If it were possible to play too much Pro Evo, then the LAN may have started to approach that limit. Mario Party and Super Monkey ball mini-games on the Gamecube were a good laugh.

On a related note I bought Pro Evo 6 for the PS2 on Friday. Review to follow soon.

Today was spent investigating CPLDs. I’ll post an update on PhD project progress tomorrow.

October 23, 2006

The library

Today involved raiding Warwick’s library for anything relating to mobile robots, autonomous robots and robot vision.

It’s wierd, as an undergraduate I used to despise trips to the library. This could possibly have been down to me visiting the library only when badly in need of some text books to help with a mental block or in the month before exams for revision.

When I went around today, I found myself gleefully looking at the row after row of interesting books just asking to be read.

I also need to get a telephone for my desk, unfortunately the best way of contacting the person responsible for that is via the telephone. Oh well.

October 22, 2006


Despite trying to tweak every setting in BlogBuilder to avoid doing so, i’ve managed to actually to start writing my first blog entry this year.

I’ve deleted most of the older posts relating to my undergraduate course as they were a rather jumbled bunch and didn’t make much sense and thought i’d start afresh.

First off, introductions. My name is Sadiq Jaffer, I studied for an MEng in Computer Systems Engineering at Warwick between 2002-2006 and am now starting a PhD under Dr. Ken Young in the Warwick Manufacturing Group.

The PhD is focused on the area of agricultural automation through the use of autonomous robots, which in itself is a fairly large area and I imagine it’s going to be a little while before I can actually pin down a small area for my thesis. Given my background i’d imagine it will involve vision.

I’ve decided to start blogging about my thoughts and progress along my PhD in the vague hope that it will keep things on track and on schedule.

In my spare time, I run an online business selling geeky t-shirts, develop computer games and breed tropical fish.

Most recent comments

  • yeah agree with jules need some cover may b some plants or rock work or those fry will quickly b eat… by carl on this entry
  • well by the time u get this they should of hatched lol …. id put some cover in ur tank looks abit … by Jules on this entry

Blog archive

Not signed in
Sign in

Powered by BlogBuilder