Skip to content

Latest commit

 

History

History
147 lines (102 loc) · 7.98 KB

README.md

File metadata and controls

147 lines (102 loc) · 7.98 KB

SailingBot

Project repository for the development of the main firmware of my open-source sailing robot. More documentation about this project is to be made on a dedicated website in the future. For now, the project is just an embryo and not functionning as expected.

Purpose

The aim of this project is to developped an automatic sailing boat model, which is capable of going from waypoints to waypoints on a flat water, by automatically adapting its trajectory, sails and direction in function of the wind direction and wind force. All data will be saved to a file, and remotely transfered to a graphic interface on a computer for real-time monitoring of all parameters and manual control of the boat model through Wifi.

Parts

The hardware of the boast is composed of:

Wiring

  • The raspberry Pi PWM HAT is soldered and mounted as indicated by adafruit
  • The tiller servo is plugged on the first PWM connector (Number 0)
  • The main sheet servo is connected on the 2nd PWM connector (Number 1)
  • The GPS is connected on the USB plug of the Raspberry Pi
  • The 3 color led is connected on pin 19-20-21 of the HAT breakout. Ground is connected to ground of this breakout.
  • The BNO055 is soldered using adapters on the top breadboard of the Adafruit Servo Hat.
    • RST pin of BNO055 is connected on GPIO 1.
    • SDA pin of BNO055 is connected to GPIO 16 which act as an emulated serial UART RX.
    • SCL pin of BNO055 is connected to GPIO 15 which act as an emulated serial UART TX.
    • GND pin of BNO055 is connected to GRND.
    • 3.3V from the Rpi (Pin 1) is connected to both VCC and PS1 (which enable serial interface on the BNO055).
  • The I2C rotary encoder is connected to the SDA, SCL, 5V and GND of the Adafruit Servo Hat of the breakout.
  • The press button is connected to a 10k resistor, between the ground and GPIO 16of the Adafruit Servo Hat of the breakout.
  • The mast led is connected in serie with a 220 ohm resistor between the GPIO 18 and the ground.

Configure the Pi

Configure raspbian

Install a fresh Raspbian Stretch Lite on a 16 or 32 GB SD card. Look at this tutorial if your don't know how to proceed.

Activate the SSH tunnel by mounting the sdcard and touch ssh or using the mouse and keyboard and the raspi-config tool (Interfacing options > SSH). See this tutorial for more details on how to enable ssh.

Connect the ethernet cable, search for the IP address of the Pi on your network, and you can now connect to your pi using the appropriate ssh command:

$ ssh pi@my-IP-adress

At your first login, don't forget to change the default password and upgrade all packages with sudo apt-get update and sudo apt-get upgrade.

Enable I2C and Serial support for parts

Still in raspi-config disable serial console ("5 Interfacing Options" > "P6 Serial" | and then ) and enable IC2 ("5 Interfacing Options" > "P5 I2C") , and reboot.

Set-up the wifi of the Pi as a wifi access point

After searching around and trying without success different tutorial that turned not to work with Raspbian Stretch, I have found this solution that is simple and work great!

Simply type in

curl -sSL https://gist.github.com/Lewiscowles1986/fecd4de0b45b2029c390/raw/0c8b3af3530a35db9ab958defe9629cb5ea99972/rPi3-ap-setup.sh | sudo bash $0 <your-password> SailingBot-AP
sudo wget -q https://gist.githubusercontent.com/Lewiscowles1986/390d4d423a08c4663c0ada0adfe04cdb/raw/5b41bc95d1d483b48e119db64e0603eefaec57ff/dhcpcd.sh -O /usr/lib/dhcpcd5/dhcpcd
sudo chmod +x /usr/lib/dhcpcd5/dhcpcd
sudo reboot

where <your-password> is going to be your wifi access point. Thanks to Lewiscowles1986 for this elegant, simple and efficient solution.

Then use your laptop wifi to connect to SailingBot-AP. Your Pi IP address should be 10.0.0.1 and you can connect to it over wifi through ssh [email protected]. After all cloning steps are done, you can just unplug the ethernet cable.

Install the main program and dependencies

Install the Pi Adafruit Servo Hat driver

Following the Adafruit tutorial you can install the Adafruit Servo Hat driver by typing the following commands

$ cd ~
$ sudo apt-get install -y git build-essential python-dev python-smbus python-pip
$ git clone https://github.com/adafruit/Adafruit_Python_PCA9685.git
$ cd Adafruit_Python_PCA9685
$ sudo python setup.py install

Install the Adafruit BNO055 driver

Following the Adafruit BNO055 tutorial, type the following commands.

$ cd ~
$ git clone https://github.com/adafruit/Adafruit_Python_BNO055.git
$ cd Adafruit_Python_BNO055
$ sudo python setup.py install

Cloning SailingBot repository

Install this repository by typing

$ cd ~
$ git clone https://github.com/cyrpaut/sailingbot.git

Test your parts & connection

Test parts individually

The sailingbot/test_parts folder contains standalone python script to test component one by one. Before you continue executing the script, I strongly encourage you to tests your parts one by one by running the appropriate script.

$ python test_XXXXX.py 

If your part is not working properly, please check you wiring and debug further with the toys examples until all your parts works! Your I2C adresses may not be the same as mine, for instance. Work part by parts until they all worked. In case you changed GPIO or change I2C adresses, modify them in the main code before running it.

Test your wiki connection to the controlling laptop

MORE TO COME

Run the code

When the main code will be available, you can run it by typing

$ python main.py

and add this program launched on startup using crontab -e

Acknowledgements

Many thanks to the people I got inspiration from, including:

  • Adafruit PWM libraries and BNO055 raspberry library, under BSD licence
  • To Red Hunter, who made the absolute orientation encoder and sell it on tindies
  • TheMagPi for its tutorial on GPS tracer(FR) I inspired from
  • To BlueDot peoples for making this cool sensor available !!
  • To the many people in the forums, and the large python and raspberry pi community