Featured

Kaladin-bot and me

Why am I building a robot and other questions…

 

In April 2019, my mom’s great friend Gabriela Gallegos came home. She lives in Cambridge and she’s an expert in robotics. Also, she loves spreading the word: she encourages kids and young people to learn programming and robotics. When she came, she brought with her a small kit (a Tiny 4WD Robot Kit) for me to build my first robot ever. With it, an amazing device: a Raspberry Pi to control and program it.

Ever since, I’ve been learning bits and bits of programming. I’ve been digging Python and it was so amazing: like learning to think or to speak another language all over again.

Also, I’ve been touching and retouching the robot, in order to learn how to make it work.

With Gabriela, we have video-conferences in which she helps me to put things together and to understand what I’m doing. Then, my mom helps me to read instructions and posts in websites, and she stays by my side while I experiment a bit with my robot.

And talking about my robot, its name is Kaladin. And in my head, I call it Kaladin-bot. The name Kaladin comes from an amazing epic fantasy series: “The Stormlight Archive”. When I learned 2020 PiWars theme was “Disaster Zone” and helping victims on desaster zones, I immediatly thought about this character. He has a soft spot for helping everybody and saving them if possible. He has awesome abilities and he’s charming and sweet. Since I think the idea behind robotics is to help humankind to live better lives, it seemed fitting to choose Kaladin as my robot’s name.

If you’re into fantasy reading, please go and pick book one of the “Stormlight Archive” by Brandon Sanderson, you won’t regret it. (Here’s a picture of me meeting Brandon Sanderson).

smart

I’m also a big gamer. I have a big brother (he’s fifteen years old) and we have a great relationship. So obviously, we fight all the time. But we also play a lot of games together. We own an Xbox one, and that’s why I chose to use my Xbox One controller with my robot. I’m having a hard time with it, but if I wasn’t, where would the challenge be?

I spoke with my Technology teacher about PiWars and my robot. She immediatly sent me a link to learn Python (in French), that has been incredibly useful. There’s a lot of information in English, but I haven’t read anything in French. It’s easier for my brain. Also, I’m visiting with her my town’s Fablab, where I will personalize my robot and learn more on programming.

My following posts will be more technic, but I’ll keep sharing anecdotes. A story is made with a lot of pieces, much like a robot.

Camera Module

Another quick step into learning how the Raspberry Pi and the robot work together is installing the Camera Module.

Best guide to install it is obviouslly in the Raspberry Pi projects (link here).

The only problem I found is that I was not fixing it correctly so it plugged-unplugged for some time. I restarted the process and then, it worked perfectly.

I took pictures, and then video (and for watching it, I downloaded VLC media player). I played with the camera changing parameters and trying some Python code. It was so satisfying (in sight of my troubles with the controller) to go true some steps and succeed.

Some screencaptures of my Terminal while working in the Camera Module:

Putty

While I’m still struggling to have my Xbox One controller working with my robot, I decided to keep learning and experimenting with other tools to really know how the robot (and obviouslly, the Raspberry Pi) work.

So, I installed Putty in my computer. My PC is a regular Windows 10 computer, but luckly, in the Putty official website, instructions were pretty simple and easy to follow. Putty is an easy to use and install tool that allows Raspberry Pi users to open the Terminal window in an external computer.

Once installed in the computer (the download link is here), the process to connect computer and Raspberry Pi is quite simple:

a. Enable SSH (this can be made in the Configuration menu)

b. Find the Raspberry Pi IP adress, checking it out in the Configuration. For that, as usual, we type:

 sudo ifconfig 

And in the displayed info, we copy the internet adress (innet adr).

c. Connect computer and Raspberry Pi. For that, we open Putty in our PC, and give it the IP adress of our Raspberry Pi. Then, when the Terminal opens, if we have not changed user and password, we use the standard ones: user: pi password: raspberry

It is really neat to work from the computer, it allows me to unplug screen/mouse/keyboard and so the robot is free.

XBox-One S Controller Configuration

I chose to use my XBox-One Controller to use with my robot.

It is a XBox One S controller, so it can be used without any dongles. The thing is, in this case, there are certain kind of changes to the bluetooth configuration that have to be done.

The first time around I only looked for instructions online, and I overlooked the steps required to unable the Enhanced Re-Transmission Mode (ERTM) for short, a bluetooth feature that doesn’t allow the devices to sync. I had only tried:

echo 'options bluetooth disable_ertm=Y' | sudo tee -a /etc/modprobe.d/bluetooth.conf

And then proceeded with the rest of several tutorials guiding me to sync my controll with the Raspberry Pi. No success. When I arrived to the last steps, the controll connected in a very unstable way, giving messages of connected/disconnected like this:

smart

Then, I had a videochat with Gaby, my coach, and she made me follow another different set of steps. In these, there was a much deeper explanation of how to unable the ERTM. The key was creating a file in /etc/modprobe.d/. For doing so, I had to go root. The file has just this one line:

options bluetooth disable_ertm=Y

After that, I reboothed the Raspberry Pi.

Then, I followed the nexts steps (from the Approximate Engineering site):

Just in case, it’s never too much to install the proper bluetooth stack (even if normally it’s already there):

sudo apt-get install bluetooth libbluetooth3 libusb-dev
sudo systemctl enable bluetooth.service
sudo usermod -G bluetooth -a pi

Then, I went straight to work in the bluetooth with this line, (no need to root):

bluetoothctl

Once there, every command I used was straightly directed to the bluetooth stack. So, first thing there, enabling the default agent:

#agent on
#default-agent

Once that done, the response was:

Default agent request successful

Up to here, everything was ok, so I kept following the steps, the next one being performing a bluetooth scan:

# scan on

When performing the scan, the response is:

Discovery started

And then:

[CHG] Device EC:83:50:C8:9C:B2 Discovering: yes

The sequence of 12 letters and numbers is the specific IP adress of my controller, as discovered by the Raspberry Pi.

Everything was working! So I kept following the steps. After the discovery was done, it was time for connecting. For that, I used:

connect EC:83:50:C8:9C:B2

Normally, after that the message would have been:

[CHG] Device EC:83:50:C8:9C:B2 Connected: yes

But I still had the connected/disconnected messages, and I couldn’t arrive to do the trust. I repeated the process several times, with no sucess. After trying to understand why, I remembered that I was using the same device adress that the scan had given me before downloading the stack, and before properly disabling the ERTM, so I erased the device using:

remove EC:83:50:C8:9C:B2 

And then, I restarted the process since the discovery part.

This time, It worked. The connected message was stable, and so lastly I trusted the device using

trust EC:83:50:C8:9C:B2 

This time, I had a very reasuring screen:

smart

So, now it was time to test the connection. For that, I used:

sudo apt-get install joystick   
sudo jstest /dev/input/js0 

And then, it worked:

In the meanwhile, I had installed the Explorer Hat and so, I was eager to try and move my robot. The thing is, again I may be lacking a library, because it doesn’t work using the controller.

I get this screen:

But, nonetheless, I succeeded in moving my robot creating a Python File with these lines:

import explorerhat as eh
import time
eh.motor.one.forwards(100)
eh.motor.two.forwards(100)
time.sleep(20)
eh.motor.stop()

This gave me the time to unplug mouse, screen and finally keyboard to observe my robot spinning wildly for the first time.

So, today I’m going to try and fix the missing library problem to properly use the Explorer Hat with the controller and move in a less chaotic way my little Kaladin-bot.

Work in progress 😉

Design a site like this with WordPress.com
Get started