This repository includes Python and C code for reading multiple messages from Swift-Nav Piksi Multi. All the codes are tested in Linux environments and instructions are for Linux only.
The provided codes can perform the following tasks:
- read multiple messages from the Piksi Multi (C/Python)
- read and write settings through command line (without the console) (Python)
For debugging purposes, Multi can be configured to work in simulation mode so that you do not have to go outside with a GPS antenna for testing your codes.
With Multi connected to your computer and Swift Console running:
- Click the
Settings
tab - In the
Simulator
section, you will see a value forenabled
. Click on this. - Set the value of
enabled
toTrue
by selecting True from the drop-down menu right part of the tab. - Then click
Save to Flash
button.
The official documentation can be found here.
This code only processes few messages like LLH position, velocity, baseline solution, and UTC. Please refer the SPB Manual for additional messages. For finding the elements in a message, check relevant h file in /c/include/libsbp
of sbp library. For example, SBP_MSG_POS_LLH
is in navigation.h
.
SBP library has issues with working with Python 3 as of writing of this code. So it is necessary to use Python 2. Below instructions assume that conda has already been installed.
Install required libraries
pip install sbp
Simply run the py file (default port = \dev\ttyUSB0, default baud rate = 115200). For issues, see troubleshooting.
python2 read_sbp.py
For different ports or baud rates:
python read_sbp.py -p /path/to/port -b baud_rate
- To rest:
python2 reset_multi.py -p /path/to/port -b baud_rate
- To write settings to Multi from an ini file
python2 write_from_ini_file.py -f /path/to/ini/file
There are few ini files saved in settings_files directory. These files are first saved through the SwiftNav Console. Usually those files are tied to serial number of the GPS. So you need different files for different GPS units. 3. Running the code through bash files There are few bash files added so that you do not need to manually type all the arguments.
sudo chmod +x name/of/the/bashfile
./name/of/the/bashfile
Multi sends messages using a custom protocol called Swaiftnav Binary Protocol (SBP). Running this C-code needs the installation of few dependencies.
- sbp-lib : for parsing the SBP messages
- lib-serial : for communicating with Multi through the serial port
SBP Library - sbp-lib
- Clone the official sbp library
git clone https://github.com/swift-nav/libsbp.git
- Install dependencies
sudo apt-get -y install build-essential pkg-config cmake doxygen check
- Create a build directory
cd libsbp/c mkdir build cd build
- Build and install
cmake ../ make sudo make install
Serial Port Library - lib-serial
- Clone the repo
git clone git://sigrok.org/libserialport
- Install required packages
sudo apt-get -y install autoconf sudo apt-get -y install libtool
- Build the library
cd libserialport ./autogen.sh ./configure make sudo make install
On 64-bit systems, you might need to install below packages.
sudo apt-get -y install libgtk2.0-0:i386 libidn11:i386 libglu1-mesa:i386
sudo apt-get -y install libpangox-1.0-0:i386 libpangoxft-1.0-0:i386
-
Compiling
mkdir build cd build cmake ../ make
-
Running (see Troubleshooting below for issues)
./read_rtk -p /dev/ttyUSB0
- Error: "libserialport.so.0: cannot open shared object" - solution: configure dynamic linker run-time bindings
sudo ldconfig /usr/local/lib
- Cannot open the serial port (replace /path/to/ports with your actual port, eg: sudo chmod 777 /dev/ttyUSB0)
sudo chmod 777 /path/to/port
- Error: AttributeError: 'module' object has no attribute 'Struct' - solution
python SBP libraries need specific versions of "construct" and "requests-futures" libraries.
sudo pip install construct==2.9.33 sudo pip install requests-futures==0.9.5