Building BB-8

April 10th, 2017

I’m building BB-8. This should have come before my post about adding an aluminum band to BB-8’s dome, but non-linear writing is good for the soul (or something like that).

The main body and the dome are both made out of foam. The dome also has aluminum and 3D printed parts on it.

I’m using a hamster drive, which (in this case) is a four-wheel drive robot inside the body to drive it. I’m also building a ball-balancing robot to keep the head on the body.

I’ll be posting more about BB-8 as it gets further along.

Using littleBits for robots

April 9th, 2017

littleBits is an electronic building set. It allows you to plug together various electronic parts to quickly build a device.

I’ve been using a littleBits set to build robots. So far, I’ve only built robots involving simple parts–I haven’t used an Arduino, so there’s no programming involved.

The littleBits sets are nice for being able to very quickly put together a robot idea. I can build a robot in a few minutes max, for something complicated (less for simpler robots).

There are multiple sensors: light, temperature, a bend sensor which could be used as a bump sensors, and a sound sensor. For motors, there are both DC motors and servos available.

The kits are lightweight and the connections are made with magnets, so any robot can’t lift or move a great deal of weight, but they are useful for prototyping a design.

They don’t offer a specific robots kit, but the Gear and Gizmos kit is what I used. It has two DC motors plus a servo and some other controls.

Thought experiment: Asimov’s First Law of Robotics

April 8th, 2017

Asimov’s first law of robotics states, “A robot may not injure a human being or, through inaction, allow a human being to come to harm.” This sounds reasonable, so here’s a thought experiment about designing some robots to implement it.

The first robot has a camera and a water pistol, together with the ability to move around. This robot uses the camera to detect when people are smoking and uses the water pistol to put out the cigarette (or whatever the person is smoking). This robot is taking positive action to avoid people harming themselves.

The second robot has a similar design, except the water pistol is filled with a combination of cod liver oil and cayenne pepper. It uses its camera to detect when someone is eating something unhealthy, then it shoots the food with the cod liver oil / cayenne mixture. Again, the robot is taking positive action to prevent people from harming themselves.

These two robots are simple (technically very easy to build), not intelligent (no AI required), follow Asimov’s first law, and yet they are socially unacceptable. Any actual intelligent robot would need to take actions like these and even more intrusive actions to prevent people from harming themselves.

Maybe we need something more like “A robot shouldn’t actively harm people, nor should it interfere with their choices.”

2017 Food Shortage

February 12th, 2017

Regardless of what you think about the ICE raids, they will decrease the available farm labor for 2017. This means we will see food shortages and greatly increased food prices.

Here are some things you can do now:

  • Start stockpiling non-perishable foods (canned, frozen, peanut butter, cereals)
  • Start or improve your garden. If you live in an apartment, you can either do container gardening or look into nearby community gardens
  • If you’re not using coupons, now is a good time to start. The more money you can save now, the more you have left to spend on food later in the year, when it will be more expensive
  • Check out prices at different places like CostCo, WinCo, and Target. Sometimes they have better prices than other grocery stores.
  • Look into Community Supported Agriculture (CSA) in your area. Normally, you can get a CSA box every week for a fixed amount. Be warned–usually a box provides a lot of food. You will need to cook probably 5-7 meals a week to use up a full box.
  • If you have extra food or money, look at making donations to food pantries or to school backpack programs. People will be needing more assistance than usual this year.

Iterative design for 3D printing

January 16th, 2017

Imagine you want to design a two part box (base and lid) to hold a deck of cards.

One approach would be to design the box, add any 3D decorations (label, texturing, etc.), then print everything and hope it all fits. If you know your printer and material well enough (e.g. tolerances, shrinkage), then this can work well.

Another approach is to use iterative design and printing. Instead of doing one print, you do multiple designs and prints:

  1. Design the basic base of the box–no decorations
  2. Print the base at a low fill percentage. Test that the cards fit. Pick up and hold the base to see how it feels in your hand.
  3. Make any changes from the tests in #2, then loop until you’re happy with the base
  4. Add any decorations and reprint at the desired fill percentage
  5. Design the basic shape for the lid
  6. Test print and check the fit with the base. Check the overall feel.
  7. Make any changes from #6 and loop until the design works
  8. Add decorations to the lid and do a final print

Iterative design like this can help you discover designs and features you might not have come up with if you did one big design up front.

Why should children learn 3D printing?

December 31st, 2016

Children should learn 3D printing so they can learn to think and design in 3D. 3D design and printing is being used in more and more industries all the time: architecture, medicine, and manufacturing, to name a few. Children that grow up learning to think in 3D will have a huge advantage in business over children that don’t.

Both 3D design and the actual printing itself are important to learn. Printing existing designs doesn’t improve children’s ability to think and reason about 3D objects. Designing objects without printing them doesn’t allow children to experience their designs tangibly, so they don’t get a real sense of what works and what doesn’t.

Learning through 3D printing, especially at a young age, can make it easier to understand math, especially geometry. 3D design and printing bridges the gap between visual learning (spatial reasoning) and kinesthetic learning.

Automation for developers

December 21st, 2016

As developers, especially on large or long-term projects, automation allows us to get more done. The more of the boring, repetitive stuff we automate, the more time there is for doing the creative and fun parts of development.

A few things we can automate:

  • Builds
  • Unit tests
  • System level tests
  • Code formatting (especially if there’s more than one developer)
  • Code reviews (some types of checklists, but even automated help for posting and commenting on code reviews is useful)
  • Putting commands (or other type of data) into a parseable format for automated code generation, automated help generation, etc.
  • More sophisticated error checking (e.g. turning appropriate warnings into errors, additional static code analyzers)
  • Memory testing (e.g. running valgrind over unit or system level tests)
  • Generating status messages or work logs from version-control logs
  • Bisecting versions for tracking down bugs (e.g. git bisect)

None of these will increase your productivity by 10x, but the more things you automate, the faster you can develop software. Little things like these do add up. It pays to look at what you do that’s repetitive enough to automate.

Big O Notation

December 16th, 2016

Optimizing code can generally get you 10-20%. If you really need to speed up code, you need to compare the performance of the algorithm against other algorithms. Big O notation was invented to compare the performance of algorithms over a large data set. Big O notation uses “n” to represent the number of data items.

To analyze a function, we look at how many operations we perform in terms of n. Generally, we don’t make a distinction between integer, floating point, string, or boolean operations. Each operation costs 1. We drop all constants unless there are only constant factors, in which case we call it O(1). This represents any constant-time function, regardless of how large a dataset is passed to it. This could be a fairly complicated function with lots of operations, as long as it doesn’t depend on the size of the data.

A simple loop over the data gives us O(n). We drop any coefficients on n and any constants (because we have an “n” term). A nested loop, with both loops from 1 to n, gives O(n^2). In this case, we would drop anything smaller than n^2 (e.g. n, 1, etc.) because for large n, the algorithm is dominated by the n^2 term.

Recursive functions work the same way. A standard recursive factorial function would be O(n) where n is actually the number the function is computing the factorial for. An iterative factorial is also O(n), but might be faster depending on the language and compiler.
Some common algorithms and their performance:

  • Binary search of sorted list: O(log n)
  • Linear search: O(n)
  • Bubble sort: O(n^2)
  • Quicksort: O(n log n)
  • Median of a sorted list: O(1)
  • Mean of a sorted list: O(n)

Some languages provide Big O bounds on the performance of their standard libraries (or portions of the libraries). For example, the C++ Standard Template Library provides bounds on many functions.

Open Letter to Electors

December 5th, 2016

In the past few days, Mr. Trump has worked on destabilizing the world.

He called the president of Taiwan and referred to her as “the President of Taiwan” in a Twitter post, which is a reversal of a 40-year old U.S. policy towards Taiwan. The U.S. government (and China and Taiwan itself) agree that there is only one China and do not officially recognize Taiwan as a separate country. He then doubled down with tweets provoking China. At the very least, this is going to raise tensions with China, if not lead to economic or other forms of war.

Mr. Trump called Pakistan’s Prime Minister Sharif and promised to “play any role you want me to play”. I expect Pakistan to interpret this as support for taking over Kashmir, which will lead to war with India. India and Pakistan are both nuclear powers, so we may have a nuclear war breaking out soon after Mr. Trump takes office.

Europe is hanging by a thread. The UK is working on leaving the European Union. Italy voted against constitutional reforms. Greece is struggling under the austerity measures imposed by Germany. All of Europe is dealing with the refugee crisis.

Between Mr. Trump’s admiration for Putin and rejecting NATO, it’s likely the Baltic nations and Ukraine will fall to Russia. Poland is also worried about a Russian invasion.

What kind of future do you want to leave for our children and grandchildren?

Please consider your vote carefully.

Scott MacHaffie

Makers are a force for good

November 12th, 2016

When you make something, it brings joy to you. If you share it with your friends, they get excited too. If you share it with a wider audience, via a blog or showing it at a Maker Faire, then more people get excited–either excited to make what you did, or excited to make a project of their own.

If you take your project commercial, then you can share it with people who aren’t makers, and you can help make their lives better.

Create. Share. Make the world better.