Ever since I was eight, one of my earliest memories of self-consciousness, I have dreamt of cars that drive themselves, where you could turn your seat towards the center and play a game of cards while travelling (entertainment those days!). I believed that by the time I’d be old enough to take control of the wheel, I would no longer need to.
When I was thirteen, it became pretty clear to me that this would not happen in time, and I began questioning whether we’d actually achieve this in my own lifetime.
Now, a couple of years later, having been astonished by how far Google is with their self-driving Prius (and now Audi TT’s and Lexus RH450h’s as well), empowered by Sebastian Thrun’s Programming a Robotic Car course, and supported by my high school, I have been working a self-driving car of my own.
Taking on passengers might take some more time, though.
Sequences have been lengthened – the actual computation time for updating the probabilities after move and sense is ~6ms each. It’s moving the robot that takes time.
sci-bot: noun A knowing / self-aware robot. From the Latin sciō + Czech robot
iRobot Create (from iheartengineering.com)
The Create is a decently priced platform (about $200) to base a robot on. Given that it is simply a Roomba without the vacuum cleaner guts means that you get a reliable, tested, and complete system (from battery recharging to motors) with a decent programming interface.
Zach Dodds et al. from the Rose-Hulman Institute of Technology has written a brilliant python wrapper for the Create’s serial interface. I use it because it simplifies commands like move forward at 25cm/s rotating at 30°/s from:
to the more intelligible:
The laptop acts as the middle man between the sensors and the robot, the brain some might say, interpreting the sensor data (the robot & LIDAR sensor just plug in over USB) and giving directions to the robot.
Hokuyo URG-04LX URG01 Laser (from Hokuyo)
While not exactly cheap at $1200, a LIDAR (short for Light Detection and Ranging) provides extremely accurate (around ±1 cm, though the URG01 is limited by Hokuyo to ±3 cm) distance information. Measuring distance given the change in phase of a reflected light wave it operates similarly to radar (though radar, using radio waves, is further along the electromagnetic spectrum). Using light rather than sound it is both quicker (after all you hear sound echo, but on a normal human scale don’t see light echo), less prone to interference and works over longer distances (military rangefinders reach 25km!) than say an ultrasound sensor. It may be overkill for a basic robot, but it becomes integral for advancing the robot.
The URG01 provides a 5.6m range over 240° (for reference, the Xbox Kinect sees about 55°) for 683 points along it’s rotation (it’s a laser diode and photo detector that rotate). Rotating at 10Hz (10 times a second) it provides about 6000 data points per second. Weighing 160g, it’s perfect for this application.
right is what the LIDAR sees in our hallway at home, with an outline of the hallway overlayed (one circle is 1m).
Consider it a tiny version of the LIDAR that’s used for Google’s cars and self-driving vehicle research…1.3 million data points / second…Wow!
Velodyne HDL-64E Laser Rangefinder (LIDAR) Pseudo-Disassembled
The robot uses basic Mote-Carlo localization (a histogram filter) to find out where it is at that moment in time. In other words, given a grid based map of the environment, the code will use probabilities to work out in which cell (or part of the map) it is likely to be. Given that this requires there to be a preexisting map of the world in which the robot is, it is not fully autonomous, or able to make decisions when things happen that you do not expect to happen (for example, somebody is standing in the hallway).
Anyway, it starts by having a map of environment, in this case our hallway at home represented by 1m² squares, or cells. Not only does the robot not know where it is, but it also doesn’t know in which direction it is facing – this becomes a big problem if you tell the robot to drive forward because you think its position is aligned with the North map, but it might actually be facing East, so it hit’s a wall… To counter this, there are four maps, one for each direction North, East, South, and West – in the East one, for example, we assume the robot is facing East, in the South one, we assume South, etc.
Since the robot has no idea where it is or what direction is is facing when it starts, each cell begins with the same probability of 2.8% (1 ÷ (9 cells × 4 orientations)):
Next, we take a look at what the sensor sees. In this case, say it it sees a wall to the left, space in front, and a wall to the right (in the code I’ve written, that is represented as [1, 0, 1]). With this new data, we can now cycle through all the cells and if this sensor measurement is what we’d expect at that location and orientation, we increase it’s probability, and if it is not, we decrease it. So this is what we get after the first sense:
And we see that it is unlikely that we’re facing East – after all, there is not a cell (facing east) in which we’d expect such a sensor reading.
Next up, we move the actual robot (after all, what use is it stationary?). The measurements from the LIDAR told us there is space ahead, so we move forward. If we can move to a particular cell, its probability becomes the probability of the cell that we moved from plus the probability that it stays on that cell (the robot’s movement is not perfect, so to factor that in, we add the (unlikely at about 10% – a value that I (somewhat arbitrarily) made up) chance that it doesn’t move). So, probabilities are shifted around and are changed a bit depending on whether we can move to a cell, or whether the robot breaks down. This forward movement then gives us:
Note how the probabilities have shifted and changed slightly.
Once we have a map (the first step, where each cell has a uniform probability) we just loop through sense() and then move() until we’ve either reached our destination or are happy with the result. So next there’s sense again with a reading, say, wall to the left, wall in front, and space to the right or [1, 1, 0]:
So, now there are three points where we’re (equally) likely to be. To improve the accuracy, we continue the loop with a move. This time, however, with the reading from the lidar saying that the only free space is to the right, we need to turn the robot 90° to the right, and then move forward. Since we change orientation, we need to move the maps as well. In this case, we turn right, so all the probabilities of the North map become the East map, all the probabilities of the East map becomes the South map, and so on. After the map turning, we just apply the normal move updating of probabilities – shift them and update them to include the chance of a failed move:
Continuing the loop, there is sense again with say, wall to the left, space in front, and wall to the right or [1, 0, 1] and we get the wonderful result of:
and there, after moving only 2 meters, the robot has a pretty decent idea of where it is and which way it is heading. If only the real world were so easy!
You may notice that the movement in this case was the same as in the video earlier. You might also have noticed that we got slightly different results this time round. The reason for this, is that for some reason (I’m still not sure myself) the robot sensed that there’s nothing in the way or [0, 0, 0] instead of wall to the left, space in front, and a wall to the right or [1, 0, 1] right at the start. Thus, since [0, 0, 0] isn’t something we’d expect so see anywhere in the map, we lost that first piece of information and just moved forward without sense updating the probabilities. It is because of this (the sensor is sometimes wrong), that there’s also a factoring of the sensor data, though it is unlikely (I guessed it at 1%) that this will happen.
In retrospect, I suspect it might be because the LIDAR was still turning on, and since it runs in a separate process (on a separate core), the code didn’t realize that. Something that needs investigating.
Another pattern that you may have picked up, is that while sense adds information, the move function will sometimes make you lose information. This happens when the robot is driving up the straight part of the hallway (again, in the video) and is 83.2% sure that it that cell at the beginning, but by the end of the corridor, this drops to 64.8%. This because moving is far less reliable than sensing, so when we move in a straight corridor we begin to lose information. That’s not to say that move can’t add information, though – for example when turning corners (corners are fantastic for localization!).
Thankfully, computers exist to do all this menial computation for us, and to change this from a theoretical learning task to a practical application one, I’ve written this all up in python (3.2). The full code is available on GitHub: https://github.com/ahrensmalte/scibot and you don’t need a robot, gyroscope, or lidar to run it! (the localisation)
A few notes about the code though:
endnote: To CS373 roboticist’s reading this, the process of physically implementing what we learn (this probably applies to all education) adds a whole new level of understanding to what we do in class – I highly recommend it.
and to those you prefer the names Robo, Robert, Robotina, or Robbie (did I spell that right?): sorry, I used the gender equal and more ambiguous (perhaps derogatory though?) name scibot here instead. To those who enjoy playing cards: sorry, I actually do too.
by Malte Ahrens, 24th September 2012 |
With the London Summit on Family Planning last Wednesday, a flurry of statistics and tweets came my way. Not knowing a great deal about family planning in other regions of the world, or the importance of the $2.6 bilion dollar’s worth of commitments announced, I decided to investigate.
Note: All charts are interactive, so grab your mouse and hover over them! Also, you can download a PDF copy here.
United Nations Statistics Division Gender Info 2007
Countries with a minimum legal age for marriage (women) below 18 years (per UNSD, Gender Info 2007):
That is 46 countries with a legal marriage age under 18 years, but is this illegal under International Law?
Under the Universal Decleration of Human Rights (1948):
and elaborated in the Convention on the Rights of the Child (1990):
the UN clearly recommends the minimum age of marriage to be 18. Individual countries, however, can still set their own age (un.org). So, in a country like Niger where marriage under 18 (minimum age of 15) is allowed, provided the child, the parents, and a judge agree, child marriage is legal.
Unfortunately, in most cases it doesn’t happen that way, and be it due to poverty, tradition, or gender (in)equality (Girls not brides) children are forcibly married.
But, does this just happen in countries with such a low legal minimum age?
United Nations Statistics Division Gender Info 2007 and United Nations Statistics Division Gender Info 2007
There appears to be a correlation between the legal minimum age and the average age of marriage, however it is not necessarily clear whether this is a causation (cum hoc ergo propter hoc). If we limit the data to just Africa, however, a slightly smaller subset of global cultures, we see that this correlation continues, suggesting that the age at marriage is affected by the legal minimum age and not just external factors like tradition or culture.
Once the legal age is above 18, though, this effect is less pronounced.
UNSD Gender Info 2007 and UNSD Gender Info 2007
Interesting to note, is that the countries: Nepal (legal age: 20), Papua New Guinea (legal age: 21), and Sierra Leone (legal age: 21) all have an average age when married below their respective legal ages (19 vs. 20 for Nepal, 20.8 vs 21 for Papua New Guinea, and 19.8 vs 21 for Sierra Leone). There is clearly something going on there…the rule of law does not necessarily play such a guiding force as we might have thought.
Conversely, as the red line (denoting an average age at marriage of 18) suggests with only Niger at 17.6 years (1998) and Saw Tome and Principe at 17.8 years (1997) having an average age under 18 years, regardless of the law, the average marriage age is almost-universally above 18, i.e. not child marriage.
But all these inferences need to be kept in context: we are just looking at the average ages here, something that can very easily be distorted by a couple (relatively speaking) of outliers. There is another statistic, however, that we can look at, the proportion of women now aged 20 to 24 that were married when they were still children.
Combining this dataset (which, admittedly, doesn’t have each country’s figures for 2011 – Liberia’s stats come from 1986!) with data from the US Census for that year, we can work out a rough number of women 20-24 who were married as children.
United Nations Statistics Division Gender Info 2007 and US Census
The Girl Effect and Girls not brides quote that around 10 million girls aged under 18 are married worldwide every year. Staggeringly, even with this limited dataset (both in terms of countries and up-to-dateness) we get a similar figure – with 47.4 million women who were married as kids over 5 years of data (ages 20, 21, … 24), a number that we assume to stay ‘steady’, therefore as every year one ‘year’ leaves this dataset and a new one comes, we can only assume that around 9.54 million girls become new child brides every year.
10 million girls every year.
Originally, we looked at the impact that the legal age has on the average age at marriage, and we found a general trend that a higher legal age brings a higher average age. This new data, however, shows that 71% of these 10 million child brides – that’s 6.8 million girls – live in countries where the minimum legal age for marriage is at or above 18.
The law, clearly, doesn’t have the sort of impact that it should, and that we need it to have. Additionally, even in countries with a legal age under 18, for example Uzbekistan at 13% (2001), Armenia at 19% (2000), or Turkey at 23% (1998), all with a legal age of 17 (2003, 2004, 2007 respectively) the rate of child marriage is acutely lower than that of Bangladesh at 65% (1999) or Nepal at 56% (2001) both with legal age at or above 18 (18 (2003) and 20 (2001) respectively).
Yet with or without law, the horrors still continue.
With child marriage, comes a great difficulty for the child to abstain from sex, or insist on condom use and such, they are exposed to serious health risks such as premature pregnancy, sexually transmitted infections, and increasingly, HIV/AIDS (UNICEF Child Protection Information Sheet).
A trend that is clear when looking at the adolescent fertility rate, the number of births per 1,000 women aged 15 to 19.
World Bank World Development Indicators
If we limit the data to the five countries with the highest rate of child marriage, this relation is definite.
UNSD Gender Info 2007 and World Bank World Development Indicators
Niger, Chad, Guinea, and Mali, all countries with staggeringly high rates of child marriage, make up the four highest rates of adolescent births.
With the asymmetric power complex of a child marriage, it can only amplify any traditional or religious reluctance towards the use of contraceptives, the same contraceptives that would protect against premature pregnancy (which can create health complications in both mother and child, CDC), malaria (the risk increases during pregnancy, especially when the mother is under 19, National Institutes of Health) and sexually transmitted infections. As is shown when looking at contraceptive use around the world.
UNCF The State of the World’s Children 2006-2010
UNSD Millennium Development Goals Database
Countries that have unmet needs for family planning, for contraceptives, are largely those that have the lowest contraceptive prevalence rate. When you sum the rate of use with the unmet needs for family planning, you get the proportion of people that are either using, or would like to use contraceptives. Surprisingly, this number is largely stable throughout different regions in the world, averaging at about 70%.
UNCF The State of the World’s Children 2006-2010 and UNSD Millennium Development Goals Database
Stable, that is, (largely) everywhere except Sub-Saharan Africa (a lot of countries aren’t in the Millennium Development Goals Database for Unmet needs for family planning and such, they aren’t represented in this) where the rate stands around 40%, a lot lower than the average, and even lower than that of developed countries.
This is as we inferred, these Sub-Saharan countries, particularly Mali, Niger, and Chad, the same ones that have high rates of child marriage, and child fertility, dominate as countries with a low use of contraceptives and unmet needs. Right here looks to be one of the places where an increased (education, acceptance, and) use of contraceptives would be most useful in preventing this cascading chain, starting with chain marriage, from continuing.
When girls get married, particularly if they have a child to care for as well, they are likely to drop out of school. Even worse, with this lack of contraceptives, their own children may themselves struggle with their education (Melinda Gates) – with an increase in the number of children, so does the difficulty in feeding them all increase. This continues to be represented in our own data (note the correlation between countries with a low secondary school enrollment (which is around when puberty starts, which is around the age that children are married at – though some are as young as 7 (Washington Post) and a high rate of child marriage).
UNESCO Primary education (ISCED 1) Net enrolment rate
UNESCO Total Secondary Net enrolment rate
UNSD Gender Info 2007 and UNESCO Primary education (ISCED 1) Net enrolment rate, Total Secondary Net enrolment rate
The relation is clear (secondary enrollment is also impacted by poverty and economic issues as well, but child marriage does make a difference); being married as a child, dramatically decreases secondary school enrollment.
And, without a proper education, you likely can’t earn the money that you need to escape poverty, which you need to escape child marriage, which you need to escape child births, which you need to escape dropping out of school.
These numbers, abstract as they may be, show the magnitude of this problem. One that needs to be addressed, and now.
Child marriage, and its implications of an unfinished education, a worsened health, and the removal of one’s liberty, is an abuse of human rights, abusing those most vulnerable in our society. But, what can *we* do about it?
by Malte Ahrens, 17th July 2012 |
I have an old RC (remote controlled) car lying around, that I got a few years ago. The battery, being Ni-Cd (and not too well treated), is dying so it hasn’t seen much use lately. Earlier in the year, while taking part in Sebastian Thrun’s brilliant Programming a Robotic Car class, I got inspired to build my robot-car. Well, at least a model version.
Where I’m currently at – that RC car controlled via an Arduino.
I saw David Singleton’s Neural-Networks Car, blog.davidsingleton.org/nnrccar, and that’s where I decided to start – converting that old RC car into an Arduino controlled one. The key from David Singleton being, controlling the remote via Arduino rather than directly controlling the car via Arduino (which would probably require some a lot of disassembly of the plastic mold).
After taking apart the plastic shell of the remote, I needed to find how to connect up the Ardiuno. The method I used was:
Once you’ve found that connection (you’ll notice that the car begins to move…), that’s (between there and ground) where you’d add the transistor (a transistor is like a tap, with the base being the valve). Setting the Arduino pin (which you connect to the base) to LOW or HIGH then controls whether current can flow through the transistor, in essence, an electronic switch.
After playing around with that for some time, and buying 90cents worth of transistors (the 2N2222A NPN transistor) I was able to get it to work (connecting the Arduino’s ground with the remote’s ground, and having the transistor the right way round, were two things that I learnt in particular).
Image based on Howard Logsdon’s work at wiki.hplogsdon.com/Arduino/. GPL licensed.
by Malte Ahrens, 2nd June 2012 |
A few weeks ago I presented again at our school’s Computer Information Night(s) – annual nights where parents (and some students) come along to learn about the machine that will be purchased the following year, the financing, etc. Our school is a 1:1 school, so each student in year 5 (~10 years old+) and above has their own tablet. As a student, I presented on why we actually use tablets, focusing on Years 5 to 12, and did a few OneNote demos.
OneNote Demos: https://skydrive.live.com/edit.aspx/Public/Demo?cid=a45fe702de180b23
by Malte Ahrens, 28th November 2011 |
Pex4Fun (www.pexforfun.com) lets you program in C#, Visual Basic, and F# from your browser or (Windows) Phone. Created by Microsoft Research , it’s a great tool for learning about programing. Learning is done through solving puzzles, for example working out the nth Hexagonal number or the Factorial of a number. Upon solving a puzzle, you can rate it Fun, Boring, or Fishy, and you get 2 extra points (your score gets put onto the leaderboard).
One challenge however, is a bit strange.
The challenge (ChallengeGeometricSeries) asks you to work out the Geometric Series where the first value is 7, and the sum of the first two values is 21.
by Malte Ahrens, 26th March 2011 |
As with other Microsoft Office applications, you can also create add-ins for OneNote. In OneNote 2007 you wrote add-ins by implementing IOneNoteAddin (see Daniel Escapa’s tutorial – http://blogs.msdn.com/b/descapa/archive/2006/08/31/734298.aspx) and they integrated well with OneNote’s UI, being toolbar based add-ins in a toolbar based UI. With OneNote 2010′s ribbon, however, these ‘toolbar based’ add-ins only show up on a separate Add-Ins tab, and even then only appearing as small icons. Integrating these add-ins with the ribbon / fluent UI is what we want for OneNote 2010, to properly ‘integrate’ them with the UI.
Like this (a custom button in a custom tab in the ribbon):
This is a tutorial / guide on how to do this.
Rather not view this in a web browser? Ok, here’s the pdf and xps documents of this tutorial
by Malte Ahrens, 27th January 2011 |
A few months ago (November 2010) I gave a presentation at our Computer Information Night(s), regarding the effective use of OneNote and Tablet PCs in a school environment. I have used Tablet PCs (primarily the Toshiba M405) for the past 3 years, and OneNote for 2 years and have seen a radical change in the way that I use and organize information.
by Malte Ahrens, 13th January 2011 |