Websocket and MultiWii serial code to control a quadcopter, running on a Raspberry Pi.
PiQuadcopter based Project, running on the Raspberry Pi. Note that I've used the Raspberry Pi 3 but it was originally tested on a Raspberry Pi 2 according to Richard Wendel.
- The first thing to do is to create a hosted Wi-Fi network. To accomplish this we use
isc-dhcp-serverandhostapdisc-dhcp-serverserves as the DHCP server for our Wi-Fi networkhostapdserves as access point management, essentially making a Wi-Fi card into a router
- Now for communication with our MultiWii device. There is the C library with the MSP protocol, and I use a backbone library
libserialportlibserialportis downloaded from their git repository, and installedcMultiWii, my MSP implementation is downloaded from the git repository. This will be compiled later
- Websocket communication is needed next. I use the
websocketpplibrary, implemented in this repo.websocketppis not installed. It is a header-only library (.hpp), and is compiled each time (with the intention of improving performance)
- Compiling websocket.cpp in this repo will build the executable that will recieve commands from a remote control, and then relay them to the MultiWii. It compiles the
websocketpplibrary which takes along time, and thecMultiWiilibrary which is quick to compile.
- Download/clone this repo
- Run
setup_pi_software.sh, which will installlibserialport,isc-dhcp-server,hostapd, and downloadcMultiWii,websocketpp. It will also compile the websocket server- You need to check to see if your MultiWii is
/dev/ttyUSB0. Check the troubleshooting section for more information
- You need to check to see if your MultiWii is
- Since your network configuration and device might be different, your
/etc/network/interfaces,/etc/default/isc-dhcp-server, and/etc/dhcp/dhcpd.conffiles are not automatically modified. - Add the following configuration to your
/etc/network/interfacesfile in order forhostapdto work. Also, remove any reference towpa_supplicant, as it causes issues withhostapd
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.10.1
netmask 255.255.255.0
gateway 192.168.10.1
- Add the following configuration to your
/etc/default/isc-dhcp-serverfile in order forisc-dhcp-serverto know what device to use
INTERFACES="wlan0"
- Add the following configuration to your
/etc/dhcp/dhcpd.conffile in order forisc-dhcp-serverto know what subnet to use
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.1 192.168.10.30;
}
- You need to ensure
wlan0andhostapd.confare correct. Check the troubleshooting section for more information
- I would suggest a reboot after all of the installation process
- To start up the hosted network and the websocket, run
sudo ./piquadserver.sh - To schedule everything to start up automatically on boot, edit
/etc/rc.localwith something like/home/path/to/piquadserver.shbut if that doesn't work as it didn't for me, use a relative path like I did with something like:cd home/pi/PiQuadcopter/ ./piquadserver.sh & exit 0- rc.local is called automatically on startup.
- Check troubleshooting for more help
- To find your wireless interface, run
ifconfig - To find your USB device, run
dmesg | grep ttyUSBand look for what number it is- Once you find your device, you will need to edit line 4 of
configure_port.cwithincMultiWiito reflect the proper device. You will have to recompile.
- Once you find your device, you will need to edit line 4 of
- If your wireless interface is not
wlan0, then you will have to change it in yourinterfacesfile, and inhostapd.conf - Check
/etc/hostapd/hostapd.conffor hostapd configurations, and make sure they match yourinterfacesconfiguration - If
hostapdis throwing errors similar to:n180211: Could not configure driver mode... then you probably need to kill the instance of hostapd already running.- Run
ps -Ato view all active processes - Find the process ID number for
hostapd sudo kill <process ID>will kill hostapd and hopefully resolve the issue
- Run
- If there are any problems with
isc-dhcp-server, try runningsudo journalctl -u isc-dhcp-server.serviceto look for errors - If you need to recompile at any time, just run
makeat the top level of this repository.
- You can find the following Application for your Android Smartphone here.
Should you have any problems, don't hesitate to contact me on my email at:
robertsolomon12@outlook.com
or if you find a bug
open up an issue here
