Little experiments

I try, I share.

SmartRap - Build

After months waiting for it, here comes my 3D printer.
To be precise, I received the parts and needed to build it.
DSC03651DSC03654

Yes, lot of works. But everything looks well prepared.
First steps were quick, no bad surprise.
DSC03660

Until some missing screws.
DSC03661

The creator of the SmartRap is very kind and reactive, and after some new screws from him and my personnal stock, here we go again.
DSC03664

At some point, I even built something I can plug :)
DSC03676

To be honest, this post is just a short version of several weeks.
I spend a lot of time on other tasks, some professionnal, some for the family and some for kids coding event ;)
I hope to post very soon some pictures of my first print !

Gary - Little 2

That’s been a long time since last update. Maybe I should experiment less and finish some projects!
But hey, the blog is about little experiments ;)

I always wanted to add wireless communication to Gary and my Raspberry Pi wants to travel: Deal! I bought a nice RaspiRobot kit, but it comes like this:
Here we go!

First time for me to solder so nice but tiny things :)
I think I got it pretty well:
Everything solderedI think it's acceptable

I adapted the case I have with some little drill game:
Gary got a new brain

I forgot to take a picture with the Pi and the Wifi dongle.
The python code works and I will translate it to Golo-lang or Java.
I also have some camera streaming code working, but the Pi camera is really not a good piece of hardware.
I’ll search another solution.

Gipsy

As seen in my previous post, first attempt to build a quadrupod ended with a jump from the desk.
Hopefully, I learned a lot and I was ready to launch the next experiment.

My wife just received this very nice material from a friend and there’s enough for me too :)
I think the best english trnaslation is paper foam board, but you will see it later.

This time, I choosed to get a step further and build a 3DOF quadrupod.
As usual, as I don’t have 3D software knowledge, I draw my ideas.
Very quickly, thanks to the foam board, I was ready to try real parts:

from thoughts to real

Easy to cut, strong enough, first leg parts were quickly ready:

one leg kit

I had to get back servos and servo horns from the poor Sticky.
Bye Sticky, you were very useful:

good bye sticky

Using the hot glue gun once more, I started to assemble the legs:

new femurs horn glued

When a leg is ready, I thought it my be good to check the 90° position of the servos:

align servo

Quite a lot of work, but that was fun:

4 legs

I quickly cut a platform and here is the first shoot of Gipsy:

structure ready

And there, I learned another lesson: glue is good, but you have to screw horns on the servo.
Until now, I just pushed the horn, but here comes the first true physical constraints.
So, I carefully use my cutter to get back all horns, screw them and glue back.
No true difference to see, but hey, I’ve done it! :)

same structure but horns are screwed now

Then, I started to plug all 12 servos to my DFRobot Romeo board.
Which bring me to my next lesson: always put a proper code on a board before switch on :)

Never plug the board before having initial code

No harm, but I thought I was stupid because I didn’t initialized all the different 12 ports used.
To be honest, I believe there’s also an electrical issue, as I was only USB plugged.
As I didn’t meant to move all servo at the same time for the moment, I thought USB was enough.
Obviously, this is not the case.

Next step will be to determine if this is an electrical issue.
I’ll add an external power source as in Gary

Also, I started to study the way I’ll code the movements. It looks harder to move a 4 legs bot than one with 6.
It’s a matter of balance and you need 3 legs on the floor to keep a stable state.
But I start learning anyway, even if at the end I code an hexapod ;)

Sticky - the Way to Quadrupod

As my 4WD slowly evolves, I wanted to think on my next platform.

One of the form that fascinate me is hexapod robots. They quite always looks organics in their moves and it seems that they can be easier to build than full crazy out of price humanoids ;)

Once more, the final push came from Let’s make robot. To be precise, Chopstick junior’s page.
The author, Lumi, has real good tips and tutorials, always finding nice solutions and allows me to think that any material can be used ;)

So it was: I will create some kind of quadrupod, using balsa wood, polymorph and hotglue!

Let’s call it Sticky! I started to cut some light balsa sticks.

first cut the feet segmentsthis is precise enough

Then came the use of polymorph. It’s a bunch of small grains that you first put in hot water.

polymorph before and begin to melt

After a little moment, it became a translucid block.

polymorph ready to mold

I just had to mold around sticks to create what I could call tibia for the robot. Polymorph can be modeled again and again: just put it back in hot water.

feet ready (will be improved)

Of course, I will have to cut some polymorph to allow Sticky to have nicer feet.

Then, I prepared the plate for the arduino board. Places for the servos were marked.

plan some space for servo

The servos on the platform were fixed using hot glue: quick, strong, fun :)

servo in placeI know, hot glue is devil ;)

Next part were the femur of the quadrupod. Some balsa wood, hot glue to fix servo horns.

legs

Then fix the femur servo on this.

you get the idea ?

Once every pieces of legs assembled, I thought the femur was too long. Balsa wood is a little bit too flexible.

first assembly to have a look

The second issue was that the tibia servo horns were not glued and polymorph was not keeping it under light effort.

nicely printed, but need some glue

So I asked my junior assistant to shorten the femur while I was glueing the tibia horns.

my assistant at work ;)

The result was really better:

new leg size

Unfortunately, I used past all along this post because Sticky had an accident.

One night, with no apparent reason, Sticky decided he had to try thrilling experience: he jumped from the desk. Two femurs were broken, one tibia horn broke the polymorph during the fall.

Am I sad?

You will know it… on my next blog post ;)

Full gallery on flickr as usual.

Tilt Pan

First of all: I wish you a happy 2014!

Lot of projects, lots of fun and everything will be good :)

Here, I now need to put down every project I started and try to do minimal plannings to have something cool to show ;)

Today, let me show my little experiment on pan tilt feature. I plan to use it somehow with Gary but I had first to see what I can do.

As it is already done, let me show you the little prototype I made:

la bêêête

I used wood to quickly see what needs to be done. The pan is a simple servo I had, glued on wood:

pan

The tilt is the same kind of servo, with a screw:

tilt

The main issue at the end, is even if balsa wood is quick to cut and glue, it is a very bad idea to have two parts sliding on each other.

It works, but use those servos is a bit too much for my plans (moving a small Raspberry Cam).

My next model will use smaller servos and maybe plastic cardboard, or printed part as soon as I get my 3D printer ;)

See you soon…

Pig 5 - Golo Lcd

Once more, I’m back!

Thanks to Golo Comunnity my little tech issue was quickly solved.

Below, you will find the Golo version of the previous posts.
It’s even downloadable here

To launch the golo samples, use the command:

1
golo golo --classpath /opt/pi4j/lib/*.jar --files <your golo file>
LcdSimple.golo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
module PiG.gpio.LcdSimple

# inspired by https://github.com/Pi4J/pi4j/blob/master/pi4j-example/src/main/java/LcdExample.java
# which is
# Copyright (C) 2012 - 2013 Pi4J
# Licensed under the Apache License, Version 2.0 (the "License")
#
# Golo version by Thierry Chantier
# Copyright (C) 2013 PiG
# Licensed under the Apache License, Version 2.0 (the "License")

import java.text.SimpleDateFormat
import java.util.Date
import java.lang.Thread

import com.pi4j.component.lcd.LCDTextAlignment
import com.pi4j.component.lcd.impl.GpioLcdDisplay
import com.pi4j.io.gpio.GpioController
import com.pi4j.io.gpio.GpioFactory
import com.pi4j.io.gpio.GpioPinDigitalInput
import com.pi4j.io.gpio.PinPullResistance
import com.pi4j.io.gpio.PinState
import com.pi4j.io.gpio.RaspiPin
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent
import com.pi4j.io.gpio.event.GpioPinListenerDigital

function main = |args| {

    let LCD_ROWS = 2
    let LCD_ROW_1 = 0
    let LCD_ROW_2 = 1
    let LCD_COLUMNS = 16

    println("<--Pi4J--> GPIO 4 bit LCD example program")

    # create gpio controller
    let gpioInstance = GpioFactory.getInstance()

    # initialize LCD
    let lcd = GpioLcdDisplay(LCD_ROWS, # number of row supported by LCD
                            LCD_COLUMNS,       # number of columns supported by LCD
                            RaspiPin.GPIO_11(),  # LCD RS pin
                            RaspiPin.GPIO_10(),  # LCD strobe pin
                            RaspiPin.GPIO_06(),  # LCD data bit 1
                            RaspiPin.GPIO_05(),  # LCD data bit 2
                            RaspiPin.GPIO_04(),  # LCD data bit 3
                            RaspiPin.GPIO_01())  # LCD data bit 4

    # clear LCD
    lcd:clear()
    Thread.sleep(1000_L)

    # write line 1 to LCD
    lcd:write(LCD_ROW_1, "PiG is great!")

    # stop all GPIO activity/threads by shutting down the GPIO controller
    # (this method will forcefully shutdown all GPIO monitoring threads and scheduled tasks)
    gpioInstance: shutdown()
}

Among the several goals I have around those little experiments, I need to be able to show the IP address of my Raspi on the LCD.
This way, it will be easy to use it anywhere and reach it.

The code is available there, even if it looks ugly ;)

LcdSimple.golo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
module PiG.gpio.LcdSimple

# inspired by https://github.com/Pi4J/pi4j/blob/master/pi4j-example/src/main/java/LcdExample.java
# which is
# Copyright (C) 2012 - 2013 Pi4J
# Licensed under the Apache License, Version 2.0 (the "License")
#
# Golo version by Thierry Chantier
# Copyright (C) 2013 PiG
# Licensed under the Apache License, Version 2.0 (the "License")

import java.text.SimpleDateFormat
import java.util.Date
import java.lang.Thread
import java.net.NetworkInterface
import java.net.InetAddress

import com.pi4j.component.lcd.LCDTextAlignment
import com.pi4j.component.lcd.impl.GpioLcdDisplay
import com.pi4j.io.gpio.GpioController
import com.pi4j.io.gpio.GpioFactory
import com.pi4j.io.gpio.GpioPinDigitalInput
import com.pi4j.io.gpio.PinPullResistance
import com.pi4j.io.gpio.PinState
import com.pi4j.io.gpio.RaspiPin
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent
import com.pi4j.io.gpio.event.GpioPinListenerDigital

function main = |args| {

    let LCD_ROWS = 2
    let LCD_ROW_1 = 0
    let LCD_ROW_2 = 1
    let LCD_COLUMNS = 16

    println("<--Pi4J--> GPIO 4 bit LCD example program")

    # create gpio controller
    let gpioInstance = GpioFactory.getInstance()

    # initialize LCD
    let lcd = GpioLcdDisplay(LCD_ROWS, # number of row supported by LCD
                            LCD_COLUMNS,       # number of columns supported by LCD
                            RaspiPin.GPIO_11(),  # LCD RS pin
                            RaspiPin.GPIO_10(),  # LCD strobe pin
                            RaspiPin.GPIO_06(),  # LCD data bit 1
                            RaspiPin.GPIO_05(),  # LCD data bit 2
                            RaspiPin.GPIO_04(),  # LCD data bit 3
                            RaspiPin.GPIO_01())  # LCD data bit 4

    for (var i = 0, i < 10, i = i + 1) {
        let e = NetworkInterface.getNetworkInterfaces()
        while (e: hasMoreElements()) {
            let n = e: nextElement()
            let inets = n: getInetAddresses()
            while(inets: hasMoreElements()) {
                lcd:clear()
                Thread.sleep(1000_L)
                let addr = inets: nextElement()
                lcd:write(LCD_ROW_1, " "+addr: getHostAddress())
                Thread.sleep(1000_L)
            }
        }
    }

    # stop all GPIO activity/threads by shutting down the GPIO controller
    # (this method will forcefully shutdown all GPIO monitoring threads and scheduled tasks)
    gpioInstance: shutdown()
}

I’m happy! :)

PiG 4 - Lcd and Java

The plan was to deliver you the Golo version of the previous post code to allow you to write on the LCD.

But it looks like I’ve done too much Java those months and not enough Golo. I’m currently stucked on a technical issue.
I’ll find a way but in the meantime and to keep the new goal to publish more often, I’ll share with you the Java version.

First, you have of course to follow the instruction on the second PiG article

Then, I used two command lines.
First, I compiled the source:

Compile
1
javac -source 7 -target 7 -classpath .:classes:/opt/pi4j/lib/'*' -d . LcdExample.java 

Then I ran it:

Run
1
sudo java -classpath .:classes:/opt/pi4j/lib/'*' LcdExample

You need root permissions to access the GPIO pins.

And finally, the Java code you need:

Download Here!

LcdExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* adapted from https://github.com/Pi4J/pi4j/blob/master/pi4j-example/src/main/java/LcdExample.java
* which is 
* Copyright (C) 2012 - 2013 Pi4J
* Licensed under the Apache License, Version 2.0 (the "License")
*
* Modified version by Thierry Chantier
* Copyright (C) 2013 PiG
* Licensed under the Apache License, Version 2.0 (the "License")
*
* compile with: javac -source 7 -target 7 -classpath .:classes:/opt/pi4j/lib/'*' -d . LcdExample.java 
* run with: sudo java -classpath .:classes:/opt/pi4j/lib/'*' LcdExample
*/
import java.text.SimpleDateFormat;
import java.util.Date;

import com.pi4j.component.lcd.LCDTextAlignment;
import com.pi4j.component.lcd.impl.GpioLcdDisplay;
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalInput;
import com.pi4j.io.gpio.PinPullResistance;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent;
import com.pi4j.io.gpio.event.GpioPinListenerDigital;

public class LcdExample {

    public final static int LCD_ROWS = 2;
    public final static int LCD_ROW_1 = 0;
    public final static int LCD_ROW_2 = 1;
    public final static int LCD_COLUMNS = 16;
    public final static int LCD_BITS = 4;

    public static void main(String args[]) throws InterruptedException {

        System.out.println("<--Pi4J--> GPIO 4 bit LCD example program");

        // create gpio controller
        final GpioController gpio = GpioFactory.getInstance();

        // initialize LCD
        final GpioLcdDisplay lcd = new GpioLcdDisplay(LCD_ROWS,          // number of row supported by LCD
                                                LCD_COLUMNS,       // number of columns supported by LCD
                                                RaspiPin.GPIO_11,  // LCD RS pin 
                                                RaspiPin.GPIO_10,  // LCD strobe pin
                                                RaspiPin.GPIO_06,  // LCD data bit 1
                                                RaspiPin.GPIO_05,  // LCD data bit 2
                                                RaspiPin.GPIO_04,  // LCD data bit 3
                                                RaspiPin.GPIO_01); // LCD data bit 4

        // clear LCD
        lcd.clear();
        Thread.sleep(1000);

        // write line 1 to LCD
        lcd.write(LCD_ROW_1, "Pi4J is great!");



        // stop all GPIO activity/threads by shutting down the GPIO controller
        // (this method will forcefully shutdown all GPIO monitoring threads and scheduled tasks)
        // gpio.shutdown();   <--- implement this method call if you wish to terminate the Pi4J GPIO controller                
    }
}

I’m going to practice basics of Golo again, my brain is not on full steam those days ;)

See you soon!

PiG 3 - LCD Use

Last time, I explained how to use you Pi to interact with a LED using Golo. Let’s see something a bit stronger.

As I told you in my first Raspberry post, I bought a bunch of HD44780U LCD.

Those little LCD can be controled in 2 modes: 4 or 8 bits.
To minimize the number of GPIO pins used, I choosed the 4 bits mode.
It uses only 6 pins to write to the LCD instead of 11 with 8 bits mode.
The only drawbacks is that you have to write the 4 most significant bits first, use a validation impulse on LCD pin 6 (enable pin), then write the 4 least significant bits.

So first, use one of the existing schema on internet to wire your LCD to the GPIO. I used one from Zem.fr

This schema is working, clear… and show a pot to define contrast!

If you read french, take some time to read the full article there, first part has a good introduction to Raspberry GPIO and this LCD.

Here is my wiring:
Lots of wiresMy good old fellow: my breadboard

The next step was to test this wiring and I used the python script provided once more in this article. Just be careful that you use tabs in your python code after copy/paste

Use LCD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/python

import RPi.GPIO as GPIO
from time import sleep
class HD44780:

  def __init__(self, pin_rs=7, pin_e=8, pins_db=[25, 24, 23, 18]):

      self.pin_rs=pin_rs
      self.pin_e=pin_e
      self.pins_db=pins_db

      GPIO.setmode(GPIO.BCM)
      GPIO.setup(self.pin_e, GPIO.OUT)
      GPIO.setup(self.pin_rs, GPIO.OUT)
      for pin in self.pins_db:
          GPIO.setup(pin, GPIO.OUT)

      self.clear()

  def clear(self):
      """ Blank / Reset LCD """

      self.cmd(0x33) # $33 8-bit mode
      self.cmd(0x32) # $32 8-bit mode
      self.cmd(0x28) # $28 8-bit mode
      self.cmd(0x0C) # $0C 8-bit mode
      self.cmd(0x06) # $06 8-bit mode
      self.cmd(0x01) # $01 8-bit mode

  def cmd(self, bits, char_mode=False):
      """ Send command to LCD """

      sleep(0.001)
      bits=bin(bits)[2:].zfill(8)

      GPIO.output(self.pin_rs, char_mode)

      for pin in self.pins_db:
          GPIO.output(pin, False)

      for i in range(4):
          if bits[i] == "1":
              GPIO.output(self.pins_db[::-1][i], True)

      GPIO.output(self.pin_e, True)
      GPIO.output(self.pin_e, False)

      for pin in self.pins_db:
          GPIO.output(pin, False)

      for i in range(4,8):
          if bits[i] == "1":
              GPIO.output(self.pins_db[::-1][i-4], True)


      GPIO.output(self.pin_e, True)
      GPIO.output(self.pin_e, False)

  def message(self, text):
      """ Send string to LCD. Newline wraps to second line"""

      for char in text:
          if char == '\n':
              self.cmd(0xC0) # next line
          else:
              self.cmd(ord(char),True)

if __name__ == '__main__':

  lcd = HD44780()
  lcd.message(" Sure it works! ")

Just for your eyes, a picture from what Zem.fr script is providing.

It works!

Now we are all set!

Wait? What? Where’s PiG?

I know, I know, this is my goal here.
But let’s meditate a moment: is it better to blog once every 6 months when a project is complete or post each little experiment steps?

See you soon ;)

Gary - Little 1

Nope! This blog is not dead!

In those months, apart from kids and work, I started to play with a lot more electronics and robotics things.

The first thing I’d like to show you is my mobile platform.

base montée et cablée

Nice, isn’t it ? ;)

As I wanted to digg a little deeper in robotics world, I needed 2 things:

  • a long term goal, some dream project that I don’t know if it’s doable, no planning and such
  • sub goals of short projects that will help me in the larger picture.

In a far far away future, I’d like to have a mobile robot wandering in the house (ooops, stairs :) ) avoiding obstacles and able to launch an alert in case of unwanted presence (picture snapshot? video stream?).

And I lied… I have a second long term project, something already done by others: a Pixar Luxo lamp with minimal facial recognition and IA behaviours.

To achieve those goals, I decided to run little experiments in the meantime.
(yes, that’s the blog title and purpose ;) )

What I already started:

  • a simple 4WD robot
  • learn or remember electronics ;)
  • a webcam on a pan/tilt that I can control from computer
  • learn to use OpenCv
  • control a 2 lines LCD from my Raspberry

What is planned:

  • add IR and/or ultrasonic sensor to implement obstacle avoidance
  • control a 2.8” touch screen from Pi and/or the Arduino
  • add JY-MCU to Arduino and have communication with a computer
  • control the Arduino from the Raspberry
  • stream video from the Pi to a computer

What is just in my mind:

  • experiment with plastic polymorph
  • build some quadri or hexa pod
  • play with 2.4Ghz R/C transmitter/receiver

That’s a lot and I’ll go deeper in each of those in later, but closer, blog posts.

As the subject of this post was Gary, I’ll finish with little details on it.

It is based on a DFRobot kit called 4WD Mobile Platform
The brain is a compatible Arduino board with motor bridge already on it called Romeo

I took some pictures during the assembly of the kit.

If french is not a problem, I had some details already in a forum where I got help.

This remind me that I need to push everything in a nice project page on Let’s make robots

As I already started to play with it, expect a IR sensor on Gary very soon. Next I’ll add the ultrasonic I just received.

See ya!

Why Golo?

As I only receive emails and no comments, I have to post some explanations here ;)

When I first heard of Golo, I didn’t needed a new language. At least, I was satisfied with my daily use of Java or Groovy.

Then a little twitt from Julien Ponge mentionned something coming, something that will be linked to the JVM, something called… Golo

Because I already knew a little bit this crazy man who love explaining black magic voodoo with JVM bytecode, I decided to look at it.
It could have stopped there. The official release was planned in a few month ahead and I will wait.

Wait? Philippe Charrière couldn’t ! He started to ask for an early release.
It looks funny, so I followed him, saying all the wonderful things to try with this language I didn’t knew :)

That’s how I became a beta tester of Golo, coding a http server and chatting with people writing framework with Golo for fun!

Maybe I didn’t accomplish huge things as Fast framework or Graddle plugin, but I already had great moments.

For sure, I learn every day new things.
Using Golo pushed me to question myself.
For example, as I discovered Java and object languages on the field, I never took time to look at the concepts behind. Trying to understand something with Golo bring me to a moment of thinking on inheritance versus composition.

Belive me: give a try to new languages! You will learn new ways of coding, thinking and having fun!

This article is in fact a lame excuse to thanks Julien and Philippe at least: thanks mates to give me such enthusiastic moments!