ErleBrain2
Raspberry Pi + PXF2 in a 3D printed case.
Basic Configuration
# Stop X.org using raspi-config
sudo raspi-config
vi /boot/config.txt
vi /boot/cmdline.txt
vi ~/apm.sh
Basic Commands
# To start, stop, restart ArduPilot
# Ultimately, ~/apm.sh gets called
sudo systemctl start apm.service
sudo systemctl stop apm.service
sudo systemctl restart apm.service
ArduCopter Settings
launch script
vi ~/apm.sh
# -B option sets the GPS port
/home/erle/ArduCopter.elf -A udp:10.0.0.2:6000 -B /dev/ttyAMA0 -l home/erle/APM/logs -t /home/erle/APM/terrain/
Compass
Apparently, you shouldn't use an external compass on ErleBrain2?
NOTE: When there's an external GPS/Compass module attached, your "compass 1" is the external, and ErleBrain's internal compass is "compass 2"
COMPASS_PRIMARY = 1 # set it to the internal compass
COMPASS_USE = 0 # don't use the external compass
COMPASS_USE2 = 1 # use internal compass
GPS
Apparently, you need to setup your GPS certain way in order for it to work with ErleBrains?
NOTE: No need to do this (upload the Erle GPS Config file to GPS module) with auto config in AC3.4
- http://forum.erlerobotics.com/t/gps-tutorial-how-to-address-a-no-fix/1009
- http://forum.erlerobotics.com/t/cant-get-gps-fix/1474/48
- http://forum.erlerobotics.com/t/solved-cannot-acquire-gps-lock/88
- http://forum.erlerobotics.com/t/pxfmini-raspberry-pi-3-no-gps-fix/1608/7
If you don't see the following messages on MAVLink messages window in your GCS after booting ErleBrain, yet you can see NMEA or ublox sentences on /dev/ttyAMA0
and blue LED on the GPS module flashes every second (meaning it's catching GPS satellites), then GPS related parameters in ArduPilot are probably not set correctly.
GPS 0: detected as u-blox at 115200 baud
u-blox 0 HW: 00070000 SW: 1.00 (59842)
Make sure you reboot EB2 after accelerometer and compass calibration.
Check the following parameters:
SERIAL3_PROTOCOL = 5 # must be set to GPS eventhough on Linux, you specify GPS device on the command line
SERIAL3_BAUD = 115 # must be set to 115200 baud
GPS_TYPE = 2 # 1 (auto detect) should work. If having problems, set this to U-Blox, or 5 for NMEA
GPS_TYPE2 = 2 # 0 (disabled)
GPS_AUTO_CONFIG = 1 # This should take care of GPS config automatically
GPS_SAVE_CFG = 1 # Save GPS configuration in flash memory inside the GPS module
GPS_GNSS_MODE = 51 # for Japan
u-blox u-center
To use u-blox u-center app without directly connecting the GPS to PC via USB
Install u-center
https://www.u-blox.com/en/product/u-center-windows
Download and install socat
wget http://www.dest-unreach.org/socat/download/socat-1.7.0.1.tar.gz
tar -xvf socat-1.7.0.1.tar.gz
cd socat-1.7.0.1
sudo ./configure
sudo make
sudo make install
Access GPS from u-center app via socat
# launch socat on ErleBrain to access the u-blox GPS serial interface from u-center app on Windows.
sudo systemctl stop apm.service
sudo socat tcp-l:2000,reuseaddr,fork file:/dev/ttyAMA0,nonblock,waitlock=/var/run/ttyAMA0.lock,b9600,iexten=0,raw
Once socat is running, connect to it from u-center at 127.0.0.1:2000 (substitute with your local IP).
Video Streaming - gstreamer
Install
# Enable camera
sudo raspi-config
# Disable erle's camera service
sudo systemctl stop camera.service
# install gstreamer
sudo apt-get update
sudo apt-get install gstreamer1.0*
Fix permission issues
# http://raspberrypi.stackexchange.com/questions/19436/how-can-i-permanently-fix-dev-vchiq-permission-errors
sudo usermod -a -G video $(whoami)
sudo chmod u+s /dev/vchiq
Test
# Test to see if stream works by lanuching raspivid manually and connecting to it at udp://@:5600 using VLC from your PC.
sudo raspivid -n -fl -w 1280 -h 720 -b 10000000 -fps 24 -t 0 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=10 pt=96 ! udpsink host=10.10.10.2 port=5600
Startup Script
vi ./videostream.sh
#!/bin/bash
sudo raspivid -n -fl -w 1280 -h 720 -b 10000000 -fps 24 -t 0 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=10 pt=96 ! udpsink host=10.10.10.2 port=5600
Change Permission
chmod a+x ./videostream.sh
Service Script
sudo vi /lib/systemd/system/videostream.service
[Unit]
Description=Video Streaming service
After=apm.service
[Service]
#Type=oneshot
ExecStart=/home/erle/videostream.sh
[Install]
WantedBy=multi-user.target
Register Service
sudo systemctl daemon-reload
sudo systemctl enable videostream.service
sudo systemctl start videostream.service
# To check the status
sudo systemctl status videostream.service
Video Streaming - mjpg-streamer
To be filled...
ROS
If you want to disable ROS to save CPU power
# config files are in /lib/systemd/system/
sudo systemctl disable ros.service
sudo systemctl stop ros.service
sudo systemctl disable mavros.service
sudo systemctl stop mavros.service
sudo systemctl disable mavros-serial.service
sudo systemctl stop mavros-serial.service
sudo systemctl disable mavros-serial2.service
sudo systemctl stop mavros-serial2.service
sudo systemctl disable mavros-wifi.service
sudo systemctl stop mavros-wifi.service
sudo systemctl disable camera.service
sudo systemctl stop camera.service
sudo systemctl disable spider.service
sudo systemctl stop spider.service
sudo systemctl disable streamingBrower.service
sudo systemctl stop streamingBrower.service
sudo systemctl disable vehicle-init.service
sudo systemctl stop vehicle-init.service
# check to see the running status of services
sudo systemctl