Linux Format - UK (2020-03)

(Antfer) #1
http://www.techradar.com/pro/linux March 2020 LXF260 41

Raspberry Pi projects


borgs) and optionally can be fitted with four ultrasonic
distance sensors, which you can use to practice, say,
safer parking.
The borgs, and many other robots, are sold as build-
it-yourself kits. Depending on the particular kit, this
might be quite an involved process, involving small
parts, soldering and possibly swearing (and sheepishly
having to order replacement parts). Building the Diddy
takes a couple of hours from start to finish.
Having constructed it we wanted to know more
about what it could do. Not content with making
glorious hardware, PiBorg also provides some great
code examples to get you started. These will need some
tweaking to work on other hardware, but they should
give you some idea of how to talk to the hardware in
Python. Robot kits will provide scripts to deal with all the
low-level communication – in our case this is all done
through the ThunderBorg.py file (which you can peruse
at http://bit.ly/LXF260piborg). This handles all the
raw I2C coding, so you don’t need to worry about that,
and provides more human functions, like SetMotor1() ,
which sets the speed of the left-hand-wheels.

Home assistant
We’re pretty cynical about voice assistants here at LXF
Towers. Our (nameless) sister magazines rant and rave
about the latest Alexa additions and how they make
ordering from Amazon even easier. They quietly forgive
the chaos that ensues when Siri’s name is spoken on
the television, as all the fruity phones within earshot
frantically start offering to help. Tech pundits wax lyrical
on the importance of shoving a network stack deep into
every single appliance in your house so that it can be
“smart”, so that the “smart” appliances can all chatter
among themselves about their dumb masters.
But all things have their uses, and much of the
shadier side of voice assistants can be obviated by the
power of open source. The Mycroft (https://mycroft.ai)
Mark 1 (launched in 2016) and Mark 2 (coming soon)
are Raspberry Pi-powered home assistants that we
don’t mind listening to us.
You probably already know that Sherlock Holmes
had an elder brother called Mycroft. You may even be
aware that in Heinlein’s classic The Moon Is A Harsh
Mistress, the HOLMES FOUR computer that accidentally
became self aware was named Mycroft (shortened to
Mike). In case you weren’t, that’s where the Mycroft
home assistant gets its name. Don’t worry though,
despite our best efforts we couldn’t get our Mycroft to
become sentient, and at no point did we feel threatened
by Mycroft.

You don’t need to buy the official hardware to use
Mycroft, as it can run on any good Linux distribution.
Alternatively you can download Picroft (a ready-to-go
image of Mycroft for the Pi) and run that right away.
Voice recognition and intent recognition are
reasonably taxing CPU-wise, so you’ll need at least a Pi
2 to run Picroft. Even that will struggle, though, and the
official word (see https://mycroft.ai/documentation/
picroft) is to use a Pi 3. That way you also won’t have to
worry about getting Wi-Fi working, since Picroft is
(currently) based on Raspbian Stretch that already has
those drivers built in.
Since the Pi’s onboard audio doesn’t have any kind
of analogue input, you’ll need a microphone. We used

the reasonably fancy Seeed ReSpeaker mic array, which
has four microphones so that it can (with some work)
determine the direction of an audio source. You’ll also
need some kind of speaker. This could connect either to
the 3.5mm analogue output or via USB, or via HDMI if
your display has speakers.
Mycroft’s core Skills (as Mycroft’s powers are
known) include a basic Hello World example, which
responds to its title “How are you” and, graciously,
“Thank you”. This is intended to introduce people to
programming their own skills. For fun and games try
asking it to sing a song or tell a joke. You can also ask
it things like how to spell words or to check stock
prices. But thanks to the community, a raft of
other skills are available (further jokes are also
available in the Better Joke skill). One of the
most popular skills for Mycroft is
openHAB (home automation bus),
which is a platform for talking to all
kinds of home appliances under a unified web
interface. It can communicate with a multitude of
different devices, including other smart home platforms
such as Nest.

Mycroft’s glorious
ASCII splash
screen. Yet another
opportunity
for Cool Retro
Term to make an
appearance.

The UltraBorg that connected our ultrasonic sensors can connect
PWM servos too. It communicates over the Pi’s I2C bus

MYCROFT WILL OBEY


“Despite our best efforts we


couldn’t get our Mycroft to become


sentient, and at no point did we


feel threatened by Mycroft.”


3332March 0 h2rSenshSnigtom March 2020LXF260 41


Raspberry Pi projects


borgs) and optionally can be fitted with four ultrasonic
distance sensors, which you can use to practice, say,
safer parking.
The borgs, and many other robots, are sold as build-
it-yourself kits. Depending on the particular kit, this
might be quite an involved process, involving small
parts, soldering and possibly swearing (and sheepishly
having to order replacement parts). Building the Diddy
takes a couple of hours from start to finish.
Having constructed it we wanted to know more
about what it could do. Not content with making
glorious hardware, PiBorg also provides some great
code examples to get you started. These will need some
tweaking to work on other hardware, but they should
giveyousomeideaofhowtotalktothehardwarein
Python.Robotkitswillprovidescriptstodealwithallthe
low-levelcommunication–inourcasethisisalldone
throughtheThunderBorg.pyfile(whichyoucanperuse
athttp://bit.ly/LXF260piborg).Thishandlesallthe
rawI2Ccoding,soyoudon’tneedtoworryaboutthat,
andprovidesmorehumanfunctions,likeSetMotor1() ,
which sets the speed of the left-hand-wheels.


Home assistant
We’re pretty cynical about voice assistants here at LXF
Towers. Our (nameless) sister magazines rant and rave
about the latest Alexa additions and how they make
ordering from Amazon even easier. They quietly forgive
the chaos that ensues when Siri’s name is spoken on
the television, as all the fruity phones within earshot
frantically start offering to help. Tech pundits wax lyrical
on the importance of shoving a network stack deep into
every single appliance in your house so that it can be
“smart”, so that the “smart” appliances can all chatter
among themselves about their dumb masters.
But all things have their uses, and much of the
shadier side of voice assistants can be obviated by the
power of open source. The Mycroft (https://mycroft.ai)
Mark 1 (launched in 2016) and Mark 2 (coming soon)
are Raspberry Pi-powered home assistants that we
don’t mind listening to us.
You probably already know that Sherlock Holmes
had an elder brother called Mycroft. You may even be
aware that in Heinlein’s classic The Moon Is A Harsh
Mistress, the HOLMES FOUR computer that accidentally
became self aware was named Mycroft (shortened to
Mike). In case you weren’t, that’s where the Mycroft
home assistant gets its name. Don’t worry though,
despite our best efforts we couldn’t get our Mycroft to
become sentient, and at no point did we feel threatened
by Mycroft.


You don’t need to buy the official hardware to use
Mycroft, as it can run on any good Linux distribution.
Alternatively you can download Picroft (a ready-to-go
image of Mycroft for the Pi) and run that right away.
Voice recognition and intent recognition are
reasonably taxing CPU-wise, so you’ll need at least a Pi
2 to run Picroft. Even that will struggle, though, and the
official word (see https://mycroft.ai/documentation/
picroft) is to use a Pi 3. That way you also won’t have to
worry about getting Wi-Fi working, since Picroft is
(currently) based on Raspbian Stretch that already has
those drivers built in.
Since the Pi’s onboard audio doesn’t have any kind
ofanalogueinput,you’llneedamicrophone.Weused

thereasonablyfancySeeedReSpeakermicarray,which
has four microphones so that it can (with some work)
determine the direction of an audio source. You’ll also
need some kind of speaker. This could connect either to
the 3.5mm analogue output or via USB, or via HDMI if
your display has speakers.
Mycroft’s core Skills (as Mycroft’s powers are
known) include a basic Hello World example, which
responds to its title “How are you” and, graciously,
“Thank you”. This is intended to introduce people to
programming their own skills. For fun and games try
asking it to sing a song or tell a joke. You can also ask
it things like how to spell words or to check stock
prices. But thanks to the community, a raft of
other skills are available (further jokes are also
available in the Better Joke skill). One of the
most popular skills for Mycroft is
openHAB (home automation bus),
which is a platform for talking to all
kinds of home appliances under a unified web
interface. It can communicate with a multitude of
different devices, including other smart home platforms
such as Nest.

Mycroft’s glorious
ASCII splash
screen. Yet another
opportunity
for Cool Retro
Term to make an
appearance.

The UltraBorg that connected our ultrasonic sensors can connect
PWM servos too. It communicates over the Pi’s I2C bus

MYCROFT WILL OBEY


“Despite our best efforts we


couldn’t get our Mycroft to become


sentient, and at no point did we


feel threatened by Mycroft.”

Free download pdf