Connecting Odroid to Pixhawk

Physical Connections

The Odroid can be connected to the Pixhawk using a FTDI/USB cable. The FTDI/USB cable can be soldered as proposed here:

The jumper should go into the TELEM2 port on the pixhawk.

My Odroid seems to be unable to give sufficient power to the Pixhawk. The big LED indicator never turns on and it seems to keep on restarting. Make sure you connect another power source if that is the case with you too.


Installing MAVproxy

Now we will install MAVproxy which will allow us to control the pixhawk using mavlink commands.

In my case, my Odroid does not have internet connection due to the fact that it is connected on an ad-hoc network with my laptop. And so I needed to download all the files offline, and send them to the Odroid. You can send the file through SSH or by simply copying them on a USB stick.

Note: For all the following instructions, change the path /root to wherever you'd like to copy your files.

Copying using SSH can be done through scp as follows: `scp -r root@192.168.1.1:

If you do have internet on your Odroid, download MAVproxy directly. Otherwise, download to your laptop and copy to the Odroid. Also, make it publicly accessible:

 cd /root/
 git clone https://github.com/Dronecode/MAVProxy

 ln -s /root/MAVProxy/MAVProxy/mavproxy.py /usr/local/bin/mavproxy
 chmod +x /root/MAVProxy/MAVProxy/mavproxy.py 

Test if MAVproxy is working:

mavproxy --master/dev/ttyUSB0 --baudrate 57600 --aircraft rover

If it worked out for you and you started seeing logs, you are lucky. Proceed to the Running MAVproxy. Else, in my case the output was:

Traceback (most recent call last):
  File "/usr/local/bin/mavproxy", line 12, in <module>
import serial, Queue, select
    ImportError: No module named serial

It seems that I need to install serial module.

Installing python-serial

Two sections here, for internet and non-internet connected Odroids. Make sure that you are using python 2.7 using which python. If you are using python 3, then you would have to add a "3" to all commands and links.

Internet

Just install it directly from apt-get:

sudo apt-get install python-serial

No internet

Download python-serial deb package to your internet connected laptop from:

http://packages.ubuntu.com/trusty/all/python-serial/download

Make sure to download the armhf one.

Copy the deb file to your Odroid, and run dpkg -i <file>. All should go well, unless if you don't really have python installed, see the pymavlink section for how to install a package with all its dependencies.

Try to run mavproxy again:

mavproxy --master/dev/ttyUSB0 --baudrate 57600 --aircraft rover

In my case, I needed pymavlink to proceed.

Installing pymavlink

Download mavlink, but before that you must install the dependencies matplotlib.

Internet

Install it using apt-get:

sudo apt-get install python-matplotlib

No internet

If you are unlucky as I am and you have to do an offline installation of matplotlib, create a list of the dependencies URLs:

 apt-get --print-uris --yes install <my_package_name> | grep ^\' | cut -d\' -f2 > matplotlib.list

Copy the list back to your internet-connected computer using SSH or a USB stick and download the required packages by using:

wget --input-file matplotlib.list

Then copy the deb packages back to your Odroid using SSH or a USB stick, and install them using:

dpkg -i *.deb

Install mavlink now:

cd mavlink/pymavlink
python setup.py install --user

See the last line of the output:

Installed /root/.local/lib/python2.7/site-packages/pymavlink-1.1.63-py2.7-linux-armv7l.egg

and add the path to PYTHONPATH permanantly. In my case, these were the commands I added to .bashrc:

export PYTHONPATH="${PYTHONPATH}:/root/.local/lib/python2.7/site-packages/"

Now try to run mavproxy again:

mavproxy

Output:

WARNING: You should uninstall ModemManager as it conflicts with APM and Pixhawk
Auto-detected serial ports are:
/dev/ttySAC3
/dev/ttySAC2
/dev/ttySAC1
/dev/ttySAC0
/dev/ttyACM99
Connect 0.0.0.0:14550 source_system=255
Log Directory: 
Telemetry log: mav.tlog
Process Process-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
Waiting for heartbeat from 0.0.0.0:14550
MAV>     self.run()
  File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "build/bdist.linux-armv7l/egg/MAVProxy/modules/mavproxy_map/srtm.py", line 128, in createFileListHTTP
    conn.request("GET",self.directory)
  File "/usr/lib/python2.7/httplib.py", line 973, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1007, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 969, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 829, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 791, in send
    self.connect()
  File "/usr/lib/python2.7/httplib.py", line 772, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python2.7/socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
gaierror: [Errno -2] Name or service not known

Perfect. Now mavproxy works. Uninstall modemmanager as instructed by using:

sudo apt-get remove modemmanager

Running mavproxy

Check the USB device which your PixHawk is connected to, probably it is ttyUSB0. Run mavproxy then:

root@odroid:~/mavlink/pymavlink# ls /dev/ttyUSB*
/dev/ttyUSB0
root@odroid:~/mavlink/pymavlink# mavproxy --master=/dev/ttyUSB0 --baudrate 57600 --aircraft rover

Connect /dev/ttyUSB0 source_system=255
no script rover/mavinit.scr
Log Directory: rover/logs/2000-01-01/flight3
Telemetry log: rover/logs/2000-01-01/flight3/flight.tlog
Process Process-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
Waiting for heartbeat from /dev/ttyUSB0
    self.run()
MAV>   File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "build/bdist.linux-armv7l/egg/MAVProxy/modules/mavproxy_map/srtm.py", line 128, in createFileListHTTP
    conn.request("GET",self.directory)
  File "/usr/lib/python2.7/httplib.py", line 973, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1007, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 969, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 829, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 791, in send
    self.connect()
  File "/usr/lib/python2.7/httplib.py", line 772, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python2.7/socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
gaierror: [Errno -2] Name or service not known
online system 1
AUTO> Mode AUTO
fence breach
waypoint 2
GPS lock at 12 meters
APM: ArduRover v2.50 (3da78052)
APM: PX4: b39d9ae4 NuttX: d447403a
APM: PX4v2 002B0035 32334711 31363032

AUTO> Received 403 parameters
Saved 403 parameters to rover/logs/2000-01-01/flight3/mav.parm

Now you can use MAVLINK commands to control your vehicle.
For example you can run:

manual
hold
steer

It would set the autopilot to these modes.

For help, just type help. You'll get all commands available.

ahrstrim        : do AHRS trim
alias           : command aliases
alt             : show altitude information
arm             : arm motors
attitude        : attitude
auxopt          : select option for aux switches on CH7 and CH8 (ArduCopter only)
bat             : show battery information
calpress        : calibrate pressure sensors
camctrlmsg      : camctrlmsg
cammsg          : cammsg
changealt       : change target altitude
compassmot      : do compass/motor interference calibration
disarm          : disarm motors
fence           : geo-fence management
ground          : do a ground start
guided          : fly to a clicked location on map
gyrocal         : do gyro calibration
land            : auto land
level           : set level on a multicopter
link            : link control
log             : log file handling
magcal          : magcal
mode            : mode change
module          : module commands
motortest       : motortest commands
output          : output control
parachute       : parachute
param           : parameter handling
position        : position
posvel          : posvel
rally           : rally point control
rc              : RC input control
rcbind          : bind RC receiver
reboot          : reboot autopilot
relay           : relay commands
repeat          : repeat a command at regular intervals
reset           : reopen the connection to the MAVLink master
script          : run a script of MAVProxy commands
servo           : servo commands
set             : mavproxy settings
setspeed        : do_change_speed
setup           : go into setup mode
setyaw          : condition_yaw
shell           : run shell command
status          : show status
switch          : flight mode switch control
takeoff         : takeoff
terrain         : terrain control
time            : show autopilot time
tuneopt         : Select option for Tune Pot on Channel 6 (quadcopter only)
up              : adjust pitch trim by up to 5 degrees
velocity        : velocity
version         : show version
watch           : watch a MAVLink pattern
wp              : waypoint management

To exit, Ctrl+C.

More: odroid, pixhawk, mavlink, mavproxy