Sunday, December 18, 2016

Here come the drones!

Amazon Prime Air announced this week that they successfully delivered a package to a customer in the UK.


This is exciting news for the package delivery industry.  Drones have already made a mark in other industries like agriculture, construction, oil and gas.  They are very efficient in inspecting power lines or oil and gas lines and even oil tanks.  Those are niche usecases where a drone is perfectly suited. Delivery of goods is one area where lots of companies are trying to make headway.  Drones have been used to deliver medicine, blood, etc.  Healthcare can benefit from drones immensely when it comes to delivering care packages to remote areas.

Possibilities are endless with drones due to their VTOL (Vertical Take Off and Landing) capability as well as stability.  Equipped with a HD camera and a GPS, drones are basically robots on a mission.

Some think that drones are going to replace UPS/Fedex, but that is not going to happen.  Drone delivery is one of the delivery channels for a specific niche. It will never become mainstream and replace USPS or UPS or Fedex, due to its limitations.  Payload is one of the key limitations followed closely by range.

Payload is a limitation that will continue to keep drones to their niche.  But, range limitation can be overcome by several means.

Due to the limited range, drones can only deliver within a small radius from the distribution center (DC).  One way to solve this is by having a mobile DC that moves the products close to the delivery site and uses drones to dispatch the goods.  Imagine a small truck driving into a neighborhood, parking itself and dispatching as many as a dozen drones to deliver a dozen packages in one shot.  The drones will fly line of sight, thus reducing the distance to the target and the time for delivery.  Once the delivery is complete, the drones return back to the truck (mobile DC) and get recharged while the truck moves to another location.  The traveling salesman problem is simplified by a hub and spoke design for the last mile (the truck still needs to solve the TSP).  The hub being the mobile DC and drones making up the spokes.  Large number of deliveries (albeit, small) can quickly be achieved this way.

The next stage of this mobile DC would be larger drones replacing the trucks.  Imagine a large drone (mother ship) carrying the goods as well as smaller drones flying into a neighborhood and landing atop a 'perch'.  The perch could be a flat rooftop or a light pole.  People could rent their rooftops as perches for these mother ships.  The mother ship drone would land and dispatch individual smaller drones to the end point delivery.  Once the deliveries are complete, the drones will return back to the mother ship for recharging and their next assignment.

The beauty of this model is that the mother ships can recharge while waiting for the smaller drones to complete their delivery.  Imagine a rooftop drone perch with a power outlet.  If the perch is on a light pole, a power outlet can be created atop the pole.  This extends the range of the mother ship as well as the drones on board.  The only reason for the mother ship to return to a DC is to gather the next shipment of goods.  Remember, this DC that the mother ship returns to, could be a mobile DC itself!

The research that companies like Amazon are doing in the area of drone delivery can benefit other areas like healthcare, agriculture, power, oil & gas as well.  

Saturday, December 17, 2016

Programming Projects for Beginners - Bubble Sort

This exercise will introduce you to sorting and specifically Bubble Sort.  There are several methods for sorting and bubble sort is one of them.

Note: If you stumbled upon this post and are wondering what this is about, start here.

Bubble Sort makes multiple passes through the list, while comparing adjacent elements.  It compares adjacent elements and swaps them if they are out of order.

Here is how it works:
Input list = [23, 4, 55, 12, 76, 3,41]
First pass:
[4,23,55,12,76,3,41] - Swap
[4,23,55,12,76,3,41] - No swap
[4,23,12,55,76,3,41] - Swap
[4,23,12,55,76,3,41] - No swap
[4,23,12,55,3,76,41] - Swap
[4,23,12,55,3,41,76] - Swap
Note that at the end of the first pass, the largest number is in its final place.  It has 'bubbled' up to its final location.

For the second pass, we can ignore the last element and sort the rest.  At the end of the second pass, the penultimate item will be in its final position.  This way, we keep shrinking the list until there is nothing else to sort.

Here is the usecase:
- Program displays a list of randomly ordered integers
- Program sorts the list using bubble sort
- Program displays the sorted list

Programming constructs used:
- Comparison
- Looping
- Conditional statements

Here is what the output would look like:

Note that I am printing the list at the end of each pass, but you don't need to do that.

You will also note that the sorting algorithm continues with the passes even though there is nothing to sort after the 6th pass.  This is because the algorithm is blindly running through the list once for every item in the list.

Bonus:
Improve the algorithm in such a way that it stops soon after the list is completely sorted.  The output should look like this:


Happy coding!

Programming Projects for Beginners - Hangman

This is the classic hangman game where the user guesses the chosen word in a given number of tries.

Note: If you stumbled upon this post and are wondering what this is about, start here.

Here is the usecase:
- Program asks user to guess a letter that makes up the chosen word
- User enters a letter
- Program checks if that letter is part of the word
- If the letter is not part of the word, the program starts drawing the hangman
- If the letter is part of the word, the program displays that part of the word and asks for the next letter
- If user keeps making guessing incorrect letters, the program continues to draw the hangman
- After several bad guesses, once the hangman drawing is complete, the user loses
- If the user guesses the word, the user wins

Programming constructs used:
- User input
- Comparison
- Looping
- Conditional statements
- Error handling
- Exception handling

Here is what a sample output would look like:

Another sample execution:

Hint:
For the hangman, create a list of the ASCII pictures with increasing degree of completion, and display them accordingly.

Bonus:
Read the list of words from a local file on disk.
Account for words with repeated letters.
Account for user typing an already found letter.

Happy coding!

Programming Projects for Beginners - Email Validator

We have all filled out forms where your email is requested.  In most advanced forms, as soon as you type your email, in case you made a mistake, the form would indicate that something is wrong.  This program does exactly that.  It checks the input text to ensure it is a valid email address.

Note: If you stumbled upon this post and are wondering what this is about, start here.

Here is the usecase:
- Program asks user for email address
- User enters email address
- Program checks validity and tells user if something is incorrect and asks user for the email address once more

Assume valid email addresses look like this:
abc@cde.com
where,
'abc' and 'cde' are alphanumeric text of any length (no special characters or spaces though)
'com' is either a two char or three char alpha string

Programming constructs used:
- User input
- String comparison
- Looping
- Conditional statements
- Error handling
- Exception handling

Here is what a sample output would look like:

Happy coding!

Programming Projects for Beginners - Guess the Number

This is a game where the computer selects a random number (say, between 0 and 10, to keep it simple), and the user guesses the number.

Note: If you stumbled upon this post and are wondering what this is about, start here.

Here is the usecase:
- Program picks a random number
- Program asks user to guess it
- User enters a guess
- Program tells user if (a) it is the correct guess (b) too high [say, if the guessed number is 5+- spaces away](c) too low (d) bit high or (e) bit low
- User guesses again until the answer is found

Programming constructs used:
- User input
- Libraries
- Comparison
- Looping
- Conditional statements
- Error handling

Here is what a sample output would look like:

As you notice above, I ran the program several times to give you a flavor of the output.

Bonus:
Handle invalid input as seen in the example above.
Count the number of tries the user takes and make an appropriate comment about it (as seen in the example).

Happy coding!

Programming Projects for Beginners - Texting Monitor

This was inspired by Shark Tank episode where Trisha Prabhu pitched her app 'ReThink' to stop cyber bullying.  As soon as I saw it, I thought a beginner could write a simple program to mimic what she is doing.

Note: If you stumbled upon this post and are wondering what this is about, start here.

Here is the usecase:
- Program asks user for text
- User types text
- Program analyzes text and if it is offensive, asks user if she really wants to post it
- Program does not send text if user agrees it is offensive
- Program sends text if user still wants to send it, but warns user of consequences

Programming constructs used:
- User input
- String operations
- Looping
- Conditional statements
- Error handling

You can keep a list of 'offensive' words and check if text contains any of them in order to decide if the text is offensive or not.

Here is what a sample output would look like:

In the screenshot above, I have run the program several times to show the different outputs.

Bonus:
Handle upper and lower case input (Eg: Y, y, yes, Yes,YES) as seen in the example.
Handle invalid input as seen in the example.

Happy coding!

Thursday, December 15, 2016

Programming Projects for Beginners - Python

I had signed up to teach programming as part of the Hour of Code movement to middle/high school kids and was pondering on what would be good and interesting programming exercises for beginners.  That got me thinking about simple programs that beginner students can write and feel proud about learning programming constructs and see them used in constructive ways.

After some thinking, here are five simple programming exercises that I came up with.  Each of these can be completed within an hour.

Note that I have solved these in python and will be including the screenshot of the output to give you an idea of how the program behaves and handles errors.

Python is a simple high level interpreted programming language with a rich set of libraries which makes it easy for beginners to learn. You can learn python here as well as run it in an online interpreter.  I often use repl for an online python interpreter. For some exercises, you will need to install python locally and run your programs.  We will go into the details later.

1. Texting monitor: This was inspired by Shark Tank episode where Trisha Prabhu pitched her app 'ReThink' to stop cyber bullying.  As soon as I saw it, I thought a beginner could write a simple program to mimic what she is doing.

2. Guess the number: This is a game where the computer selects a random number (say, between 1 and 100), and the user guesses the number.

3. Email validator: We have all filled out forms where your email is requested.  In most advanced forms, as soon as you type your email, in case you made a mistake, the form would indicate that something is wrong.  This program does exactly that.  It checks the input text to ensure it is a valid email address.

4. Hangman game: This is the classic hangman game where the user guesses the chosen word in a given number of tries.

5. Bubble sort: This exercise will introduce you to sorting a list of items.  Sorting is the process of placing the elements in a collection in a specific order.  In our case, we will sort a list of random integers into a list that contains the numbers in an ascending order.

I will post more details of each of these exercises in the coming days.  Look for those posts.

Happy coding!

Thursday, November 24, 2016

Robot meets Trolley Problem in an Autonomous Car

Isaac Asimov's Laws of Robotics states that:
  1. A robot may not injure a human being or, through inaction, allow a human being to come to harm.  
  2. A robot must obey orders given it by human beings except where such orders conflict with the First law.
  3. A robot must protect its own existence as long as such protection does not conflict with the First or Second law.
What is an autonomous vehicle but a robot programmed to ferry passengers and cargo around.

The famous Trolley problem is a thought experiment in ethics.  The general form of the problem is:
There is a runaway trolley barreling down the railway tracks.  Ahead, on the tracks, there are five people tied up and unable to move.  The trolley is headed straight for them. You are standing some distance off in the train yard, next to a lever.  If you pull this lever, the trolley will switch to a different set of tracks.  However, you notice that there is one person tied to this track and is unable to move.

What do you do?
Do nothing and kill five people or pull the lever and kill one person.
Which is the most ethical choice?

Ever since Artificial Intelligence (AI) and autonomous vehicles started getting closer to reality, this question of ethics is haunting the designers of autonomous vehicles and the algorithms governing them.  Imagine an autonomous car speeding along when it suddenly encounters a bunch of unexpected pedestrians on the road.  If it continues forward, it will kill the pedestrians.  If it swerves to avoid the pedestrians, it will fall off a bridge killing all its passengers.

Autonomous car meets trolley problem.
Robot meets a situation violating its laws.

How do we program a car to behave in a situation like this?
Eject all the passengers to safety and drive off the bridge.  Wish it was that easy.

There has been a lot of research into this area and MIT has even set up a web site to crowd source the opinion of the masses.  [side note: It will be interesting to go through the judging process as: a) a passenger, b) a pedestrian and c) as a third party onlooker.  I am sure that will skew your answers..]

One way to look at this problem is to equate the autonomous car to a chauffeured car.  In this case, the decisions are driven by the chauffeur.  As a human being, the driver's main motive is to stay alive and this skews the decision making.

The outcome of solving this problem may be that people will hesitate to buy or board a driverless car because of the fact that protecting its passengers may not be in the best interest of the vehicle.  What a dilemma!

Again, these are extreme end cases we are talking about.  Maybe, we should use a crowd sourced decision tree and apply it to all autonomous vehicles.  Today, the driver takes responsibility to the actions of the vehicle.  Tomorrow, we should not be blaming the manufacturer for the actions.  The actions should be governed by a set of rules appointed by a global body.

The reality is that millions of people are killed by vehicles manned by people.  This would dramatically reduce with autonomous vehicles and that fact will pivot people into accepting this new transport.  Similar to how horses made the decisions for us while we rode buggies, and when cars came around, no one wanted to trust a human being to make these decisions.  And, look where we are now.  One thing you have to give to the horses, though, is that they don't drink and pull carriages.

All along, designers of vehicles had been concentrating on protecting the passengers by installing seat belts, airbags and other safety equipment in vehicles.  Because of this new ethical dilemma, the designers of autonomous vehicles will have to start thinking of not only protecting the inhabitants of the vehicle, but also those in its vicinity in case an unfortunate event was to occur.  Designers are currently concentrating on the algorithm that powers these vehicles and assists in decision making.  That is all fine and good, but we need to start thinking outside the box to find the solution.

Thinking outside the box could lead into external airbags for vehicles which deploy when they detect an apparent (planned) collision with a living being.  It could also lead to apparel manufacturers designing safety wearables like jackets with airbags.  These could be for people who have high exposure to autonomous vehicle traffic, like construction workers.

But again, these are extreme edge cases we are talking about. 

Tuesday, October 11, 2016

Driverless pizza ovens

You order a pizza from your local pizzeria and a half hour later, a driverless car pulls up in front of your door and pings you to come out and pick up your pizza.  You go to the car, scan a code from your phone and a small door opens revealing your pizza box.  We all know this is bound to happen, or already happening in certain cities.



On a busy day, it can take up to a half hour for a pizza to be prepared and then transportation time is added on top of that.  This could easily add up to almost an hour, depending on how far you live from a pizzeria.  In general, a pizza takes about 3-4 minutes to prepare and 8-10 mins to bake.  Once baked, it tastes its best if consumed immediately.  Depending on the contents of the pizza, it starts to age and get soggy by the minute.

This is where the driverless oven comes into picture.

A pizzeria gets its order.  The order contains not only the products purchased, but also the address to be delivered to.  Software can easily categorize orders based on the product as well as distance to be transported.  For those orders within closer reaches, the pizza can be baked in the store and loaded for delivery.  For those orders which have a larger travel time, the chef can prepare the pizza and load it into the delivery vehicle.  The pizza is baked in the vehicle's oven, and packaged once fully baked and readied for delivery automatically.  This would need an automated vehicle with an automated pizza oven inside it.  The oven could be designed to handle several pizzas which will be baked based on the distance to the destination.  Material handling robots would package the pizzas as they are cooked.  The vehicle decides when to start baking depending on the distance as well as traffic conditions.

This optimizes the baking and delivery of the pizza.  Delivering fresh baked pizzas would become a reality.  This can also free up the store over to service in-store customers.
PC: Dominos Pizza

Sunday, September 25, 2016

Maximizing store productivity

The other day I was at the mall and visited a clothing store.  Walking inside I noticed a line formed in front of the dressing rooms.  Here we had a bunch of customers who were wasting their time waiting to get into the dressing room rather than perusing the clothes and accessories being sold by the retailer.  What a great wasted opportunity.


What if they had an app that customers could download and use it to reserve the dressing room.  If no room was available, they would be put on a waiting list and pinged when one came available.  This would allow the customer to roam around and shop for more things.  Once the retailer's app is installed on the customer's mobile device, and once the customer logs into the app, the retailer will have all the customer's information so the app can provide tips or sales information to the customer based on her/his taste.



This would not only provide a pleasant experience to the shopper but also help the retailer maximize the customer's time in the store.  Which retailer would want a shopper standing in line rather than browsing the aisles and picking up products to purchase?  

Saturday, September 17, 2016

Alexa in the Enterprise

Amazon Echo has been the face of Alexa all these days and it is a hands-free speaker that you control with your voice.  It also acts as a virtual voice-controlled assistant with limited capabilities.

 

Amazon released Alexa API to developers for free and developers are flocking to it.  This is a great move by Amazon and this will herald a new wave of applications that make use of Alexa.  And the Alexa Champions Program was put in place to recognize creative and outstanding contributions to the ecosystem.

Alexa has been seen as a way to enter into everyone's living room and as an assistant for the home.  Even the Alexa Home Kit is geared towards helping create home based custom skills.  This is all good.  But, the next generation of skills are going to empower the enterprise.

Imagine walking into a sporting goods store and wondering where to find running shoes.  You walk up to a virtual assistant installed strategically on every pillar/corner and speak to it and ask your question.  It can then reply with the exact location of the running shoes.  A custom skill could be created to go into the store database and check the location of the product in question, verify its location on the store planogram and return the location for the virtual assistant to voice.  The database and its information should be store specific.


Taking it to the next level, imagine a virtual assistant answering questions about a product.  All the information about the product, its reviews, etc. are available and can be piped into the assistant without any human intervention.  Custom skills can be built to work with the store database.  In cases where the answer is not found or the question is not understood, the virtual assistant can page for a human assistant.

The next generation of Human Computer Interaction is already here: It is voice based.  We still have a long way to go before computers can read our minds (think, Firefox, the movie).  We do live in interesting times.

Update: With Echo Show, the enterprise use case is strengthened.  In the above sports store scenario, Echo Show can display the store planogram/plan and show the user how to reach the product of interest.  It can also display additional information (choices, etc.) on the product as well. 
Image Courtesy: Amazon.com

Saturday, May 14, 2016

Amazon IOT

Amazon has finally done it.  They have created a generic IOT Dash button.  Last year I wrote about how the Dash button was super specific to not only actions but also products, and they needed to make a generic programmable button.
Last year, the Dash button was first hacked to order pizza from Dominos.  Later, people started hacking the button and using it as an IOT device to perform various tasks.  This was the right direction for the button.  Amazon realized the potential and has taken a step in the right direction  The AWS IOT button is a generic device that can be programmed to do anything one wishes to accomplish.  The price point ($20) seems steep for the device.  The original Dash price point of $5 was perfect.

Amazon how has a IOT button (touch).  The next step would be for Amazon to create MEMS sensors to sense sight, sound, pressure, acceleration, etc..  This will give developers all the needed sensor capability for IOT.  Amazon could then expand their IOT ecosystem.  

Wednesday, March 9, 2016

Devil is in the details

We all love products that are designed well.  A well designed pair of shoes don't even seem to be there.  A well designed corkscrew works exactly how you think it will work.  A well designed user interface is intuitive and feels second nature. 

Some designs are so bad that you immediately notice the flaw.  Like a video camera lens that whines as you zoom in and out.  Some are not so obvious.  It is when the design misses the mark to deliver on the promise that you notice the flaw. 

This is where good usecases come into picture.  The set of usecases for a product should be mutually exclusive and collectively exhaustive (MECE).  If any usecase is missed, usability suffers and the customer fails to be delighted.

BMWs are well designed cars, inside and out.  They are beautiful to look at; they are fun to drive; they are comfortable.  There is a lot of room for improvement on the user interface on the inside, though.  That is another blog post.  Today, we are looking at the exterior body design. 


As you can notice in the photo above, there is a lot of dust and dirt on the top of the rear bumper (arrow) whereas the entire car is clean and shiny.  All the surfaces of the car are slanting downwards at some angle, whereas the bumper top is not.  Because of this, dirt and rain water collect on top of the bumper rather than being washed away.  Angling the bumper slightly down (0.5 - 1 deg) could have easily done the job.  But, they missed it.  Maybe, the designer thought that a flat bumper top would let the user keep things on it while opening the trunk or when the trunk is open.  You can still do it with a slight angle.

This is an example of missing one of the key usecases.  It is important to list out all possible usecases for a product and test for it.  That is when you make a delightful product.