Skip to content

Instantly share code, notes, and snippets.

@geri-m
Last active January 29, 2020 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geri-m/c101044e7d7da2e725f712f2f28a7fb1 to your computer and use it in GitHub Desktop.
Save geri-m/c101044e7d7da2e725f712f2f28a7fb1 to your computer and use it in GitHub Desktop.
Setup for Working with 4tronix's Initio Robot Kit

Goal

4tronic's Initio Robot Kit is a nice way to get started with robotics, sensors and working with Python on an embedded device.

We are uisng PiRoCon and NOT RoboHAT as Shield on Raspberry Pi to Connect to the Rover

Various Tutorials from 4Tronix

Create SD Card

  1. Download Raspbian to create an SD Card for Raspberry Pi (Take the "lite" Version without Desktop
  2. Unzip File to get the .IMG for putting on the SD Card (4 GB SD Card is good, not more memory required)
  3. Create an SD Card with the Image File.
  4. Connect Keyboards & HDMI Screen and login to the Raspberry PI (User: pi, Password: raspberry - Attention: English Keyboard Layout! 'z' vs. 'y'!)

Connect to Network & SSH

  1. Enable SSH, SPI and I2C
    1. sudo raspi-config
    2. Go to 5. Interfacing Options and enable these three one by one. (P2, P4, P5)
  2. Optional - setup WIFI (if you raspberry PI support Wifi or if there is a Wifi Dongle Connected)
    1. Set IPs to IPv4a as they more easy to read.
    2. sudo nano /etc/sysctl.conf
    3. Add net.ipv6.conf.all.disable_ipv6=1
    4. Setup Wifi wpa_passphrase "<ssid>" "<password>" >> /etc/wpa_supplicant/wpa_supplicant.conf (Attention: special Characters need to be escaped!)
    5. Check if data is correctly stored sudo less /etc/wpa_supplicant/wpa_supplicant.conf
    6. Connect to Wifi wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0 (Info: '-i' is the device to connect the network)
    7. Type ifconfig to see, if everything is fine and get the IP address of the adapter
  3. Try a ping 8.8.8.8 to see if there is connectivity to the outside internet.
  4. Try ssh into Raspberry ssh pi@<your-ip-address> (Password is still "raspberry"; Host and Client must be in the same Network/Subnet and not firewall must block connection)
  5. You should run apt-get dist-upgrade to get patched and updated for libs.
  6. Make your IP Static: https://raspberrypi.stackexchange.com/questions/37920/how-do-i-set-up-networking-wifi-static-ip-address
  7. Set your Team name in /etc/hostname so you can connect more easily to your RoboCar.

Setup PiRoCon (Robo Shield for Raspberry Pi)

  1. First we are going to install some tooling we need to control the pHat (see in detail https://4tronix.co.uk/blog/?cat=4) curl -sS https://get.pimoroni.com/unicornhat | bash
  2. We also need a Pythn Library to connect to SPI: pip install spidev
  3. Get a Script to fetch some tests for Initio `wget http://4tronix.co.uk/initio.sh -O initio.sh``
  4. And run the Script bash initio.sh (see https://4tronix.co.uk/blog/?p=505)
  5. The folder ./initio you find various scripts to test the features of the rover.

Controlling the Servos for the Ultra Sonic Head

Servo Blaster

Communication with the Servos is not done via GPIOs (although it would be possibile), see https://github.com/4tronix/PiRoCon/blob/master/python/servo.py

Instead communication is done via a the [ServoBlaster Daemon] (https://github.com/richardghirst/PiBits/tree/master/ServoBlaster). If you use intio.py to communicate with the Servos, this Library is starting the Daemon via os.system and shutting it down at the end.

For manual Testing you can do this on your own as well:

  1. Start Daemon: ./servod --pcm --idle-timeout=20000 --p1pins="18,22"
  2. Sen Commands echo P1-18=120 > /dev/servoblaster
  3. Don't forget to kill your process again.

If you have trouble this the binary of ServoBlaster provided, you might want to Build this one yourself.

mkdir -p ~/servoblaster/ 
cd ~/servoblaster/
git clone https://github.com/richardghirst/PiBits
mv PiBits/ServoBlaster/ . &amp;&amp; rm -rf PiBits
cd ServoBlaster/user
sudo make install

The new version will be stored in /usr/local/sbin (!) so you have to adapted initio.py to not use the local, but this globale binary of servod.

This are the Specifications of the Tower Pro SG90 Servos.

  • 1 - 2 ms Duty Cycle
  • 20 ms (50 Hz) PWM Periode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment