Freesteel » Martin
Thursday, August 14th, 2008
Here’s a bit of easy C++ code using a template class with a template member function that compiles and executes with no problems on MS VC8:
#include <iostream>
#include <vector>
using namespace std;
template<class T>
struct A
{
T x;
template
void fun(IT& it1, IT& it2)
{
for(IT i = it1; i != it2; ++i)
cout << (*i + x) << endl;
}
};
int main(int argc, char* argv[])
{
A<int> a;
a.x = 1;
vector<int> b;
b.push_back(10);
a.fun(b.begin(), b.end());
return 0;
}
But try this on a linux machine with gcc (I used “gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)”) and you will get into compilation trouble:
main.cpp: In function âint main(int, char**)â:
main.cpp:27: error: no matching function for call to A<int>::fun(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >)
main.cpp:12: note: candidates are: void A<T>::fun(IT&, IT&) [with IT = __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, T = int]
make: *** [main] Error 1
So, what’s wrong?
If there’s only one candidate, why does the compiler not instatiate that one? Why is there a matching problem, and why does VC8 not spot this?
I could wait until tomorrow with telling you the solution, but I won’t let you racking your brains…
here it is:
replace the declaration of the template member in template struct A with this:
and you get a result. But why is that? You tell me!
And what do you do if you want to code a member that needs pointers, not constant references? Somebody out there who knows the answer?
Friday, May 23rd, 2008
Wednesday, September 19th, 2007
My guess is that this is one of the most used lies in the world of business.
But sometimes it’s true, like yesterday when I called a company a second time to chase up an invoice that was well overdue. On my first phone call I was told that somebody would call back but never did; and on my second call a day later I was told that a “cheque is in the post”… I can’t help but see a connection here, or do you really believe the cheque would have been in the post without my insisting phone calls, after nearly 2 month since I sent the invoice?
Luckily I knew about the late payment legislation and how to word an invoice: If the money is not handed over after 30 days of your invoice date you can claim compensation for debt recovery as well as interest for every day the payment is late.
Funny that the company who owed the money probably know all this from writing their own invoices: They are charging their customers periodically for their products, and I bet you that any overdue payment is dealt with in a swift and efficient way, much more efficient than we are.
Finally the cheque arrived today, and my invoice for debt recovery and interest will go out today as well. I will keep you posted on the next cheque that should be in the post soon.
Thursday, November 23rd, 2006
I have translated the brochure into German, you can download it from here. We will take it to Germany to the trade fair Euromold 2006 next week.
Wednesday, November 15th, 2006
Python programmes can be for mulltiple platforms. If you can get away with not using platform specific packages in theory at least you should be able to run one python script on several different operating systems with the same look and feel.
I recently (last week Friday 10-11-2006) had the pleasure to put this to the test once again: I was asked to programme a psychology experiment where the person experimented on is exposed to a series of 3 letter sylabels on the screen, one of which is red. They have to press a corresponding key and time as well as the correctness of the answer is saved to a file for later statistical analysis. I programmed this in python and used Python Imaging Library and wxwidgets for the graphics and the user interfacey bits. All done on windows xp, and it works fine. Now, making a Mac version should be very easy: you should be able to take the code and run it on the Mac. Some hours later, compiling all sorts of stuff to be able to read and render font files on the Mac, work around the fact that a Mac keyboard has a different layout than a PC keyboard… In short, you still have to do platform specific programming; and the biggest annoyance is that there does not seem to be a very simple sound interface to just do a beep on the Mac. Do I really have to read and play back a wave file to just sound an acoustic warning? And, I have the suspicion that keyboard events are buffered differently on the Mac version of wx than the PC version. This is critical, because i have to filter out multiple key strokes, when the tested person goes maybe into ‘computer game’ mode and starts hammering one key…
Saturday, October 21st, 2006
Friday was a day at the psychology department. I battled with wxwidgets to get a full screen frame without any window decorations on Mac OS X, not with the desired outcome. The best I can get is a screen filling frame, but with a title bar and a ‘close window’ button at the top. Acceptable. Shame that it works as desired under windows. The other thing I looked at was using py2app to wrap up a python application that uses Python Imaging Library and wxwidgets to run on another mac. After some unsuccessful attempts I decided to upgrade python and site packages to newer versions. I upgraded python from version 2.3 to 2.4 and downloaded wxwidgets latest available version. The new site-packages installation meant I had to reinstall py2app. Success, with the latest versions py2app created mac a working application. A lot of these different packages come with their own installation tools. Ever heard of ez_install.py (say eazee(!))? Well, that is used for setuptools and py2app. Or python eggs? Don’t quite know what they are good for, but some got laid in my working directory.
And I had a chat with another scientist at the department about programming some experiments for her.
Thursday, October 19th, 2006
On Tuesday afternoon I went to the engineering department and together with Carl rejigged the python script he uses to control their machine. We now use two python threads, one controls all moves of the motors, updates the user interface edit boxes with the current position and speed data, and also controls buttons that are pressed or unpressed automatically when the machine is rotating. We have a separation of user interface and motor control so that the user interface is always responsive. The UI passes requests for movements through a queue to the motor thread.
In the past we could use just one thread because we always ever had to handle one request for the motors to move. The calls to the DLL for the controller card always return immediately, the controller maintains it’s own motion queue. But we had to implement sequences of movements of different speeds and pauses. The queueing system we have now in place in the python thread allows that now easiy.
Thursday, October 12th, 2006
I did some work in the engineering department of Liverpool University today. Some time ago Carl did a write up of something we had programmed to print undistorted images with one or more rotating print heads, assembled in a row. The inkjet print heads they use are meant for normal printing with paper moving rectangular to the print width. But in their machine the medium to print rotates underneath the print head, with one side of the head closer to the centre of rotation than the other. So, a rectangular bitmap would be distorted to a pie wedge. We wrote a little algorithm that transforms a bitmap into a new bitmap that, when printed on this setup, prints undistorted.
I had read it on the train last night and had a few comments and suggestions to make it clearer what this does.
Then looked into extending the controller of the machine that performs these rotations. In order to shine a light on the same area on the print medium for a specified time they want to be able to stop the rotation, then start it again, and so on. We use a python thread that monitors the machine position and when it has reached the target of the rotation joins the main thread that in turn can sleep for the specified time, then start the motion again.
I had hoped we could use some sort of callback mechanism in the DLL that controls the digital controller card: When a motor has reached it’s target position we get a user specifiable callback. We had found something in the documentation for the DLL and started coding. But we got stuck and had to call the support phone line for the card manufacturer. The friendly support person told us we were following a red herring: The documentation we had used was for a different card, using a different (probably real-time) operating system.
Last week I also spend a day there:
We had looked into rewriting the user interface of the motion controller: The old user interface got out of hand, partly because a master student had used unsuitable GUI code generators on it (python glade). We had decided to shelve this code and write a much simpler new interface. Now that this motion controller has been in use for more than a year we could also reduce the functionality to what was really needed.
Another half day last week was spent in the department of psychology. I am working on a framework to programme visual perception experiments using python, wxwidgets and python image library (PIL) on a mac os x system. More about that some other time.
Friday, October 6th, 2006
For statistical purposes the country has been divided into small blocks of land called Output Areas. These allow us to look in more detail at smaller local areas. Output Areas have been combined to form two layers of Super Output Areas known as Lower Layer Super Output Areas (LSOAs) and Middle Layer Super Output Areas (MSOAs)
Quoted from here
I live in an area of Liverpool that has been a ‘Neighbourhood Renewal Area’ for a number of years now. There’s a long (more than 20 years) history behind it:
The Granby area of Toxteth had it’s share of rioting back in the 1980’s and also later. It was about mainly black youth being fed up with the police harassing them for no other reasons than their skin colour. I don’t know too much about the housing situation back then. One problem must have been that ’slum landlords’ neglected the houses, only interested in the rent they could squeeze from people at the bottom rank of the social ladder. People who cared tried to change this by getting the authorities to use compulsory purchase orders (CPO) against irresponsible landlords to take these houses into public ownership and improve living conditions. CPOs had not been used like this before, they were meant for road building, for airports and so on. Now these houses were given to housing associations who gave them to tennants that needed the social welfare system to find somewhere to live. Houses and living conditions were improved.
But over the years the area became more and more a dumping ground for people who were not wanted in other, more afluent, areas of the city. Eventually plans emerged to demolish the whole area and build something new. The housing associations were all for it and stopped using the houses for tennants. Instead the houses were tinned up, after stripping them of pipes, light fittings, toilets, sinks… things that you need to live in a house. Windows were smashed, roof windows left the inside open to the destructive forces of wind, rain and pigeons.
Deteriortation of the area was sped up and with the empty houses came other problems: Squatters, drug abuse, fly tipping…

But times have changed and my neighbourhood is trying to leave the bad reputation it still has, not just in Liverpool, behind. The few neighbours left are really nice people, there is a sense of community. We have window boxes with flowers in front of the houses, including the empty ones. We even won an award in the North West in Bloom competition for Improvement. My neighbour from opposite goes round and clandestinely paints butterflies on to the boarded up windows of empty houses. She calls the tinned up houses voids.
There are now four streets left, and the latest scheme to take away the houses is called Housing Market Renewal Initiative. The people who live here, including me, want to keep their houses. We have to fight the plans of a developer called Lovell, a company liked by Liverpool City Council and chosen to be their preferred developer for Granby Toxteth. The other day was a meeting of the ‘Three Parks Neighbourhood Committee’ where the residents organised in the Granby Residents Association were allowed to make a presentation about the effects the plans already have and will have on us. While trying to find what this committee actually does I came across the quote on top. The meeting went well, we got applause and the councillors present made the right noises signalling that they are sympathetic to our cause. But the decisions are made somewhere higher up, we are waiting for the executive board of the council to approve the plans Lovell has presented. Then the next stage in the fight to keep our houses will start.
Tuesday, June 6th, 2006
I keep a simple logbook of IPs using the web interface and roughly what people are doing. So far we had users from all continents but Africa. Somebody in Brazil used it a few times, we have users in India, Australia, Canada, USA, all over Europe. Most people only spend a short amount of time, never change to another STL file and don’t seem to use the interactive rotation/zoom/pan. (Could these be bots? I don’t think so, because their IP are often pointing to broadband service providers, and a bot would have to pretend it is a mozilla firefox browser to come as far as seeing a STL file). Others come back regularly, uploading STL files and calcluating toolpaths on them. I think we should invite our users to fill out a survey of how they found out about us, what they use the web interface for, what they don’t like about it … that kind of stuff. Given that people from virtually all corners of the world find us, I find it a little disappointing that we get so few comments in this blog.