sbgECom Library
5.2.590-stable
Interface SBG Systems IMU/AHRS/INS
|
This guide will help you quickly get started with the sbgECom ANSI C Library and the sbgInsRestApi to configure your device and read data.
It also explains how to use the CLI tools, sbgEComApi and sbgBasicLogger, to configure your device and log data to CSV files.
SBG Systems products use a proprietary binary format, sbgECom, for data output and device communication.
Device configuration is managed using the modern, JSON-based sbgInsRestApi, which provides a portable and easy-to-integrate solution.
The sbgECom library is the C implementation of the sbgECom binary protocol used by the device to send data messages.
It also provides specific commands, such as SBG_ECOM_CMD_API_GET and SBG_ECOM_CMD_API_POST, to support sbgInsRestApi configuration.
For example, the SBG_ECOM_LOG_EKF_EULER message returns the AHRS/INS roll, pitch, and yaw angles.
The sbgInsRestApi is a JSON-based RESTful API that handles device configuration and monitoring.
Standard HTTP GET and POST requests are used to interact with the device via various endpoints (URLs).
For example, entering http://<my-device-ip>/api/v1/settings
in a web browser retrieves all the device settings in JSON format.
The sbgECom library is designed for easy integration within your projects. Written in clean, well-documented C code with embedded systems in mind.
It is strongly recommended to use the sbgECom library for proper protocol support and future-proofing against updates.
The sbgECom library and code samples have no third-party dependencies and are written in standard C99.
However, the CLI tools sbgBasicLogger and sbgEComApi are written in C++ (14) and depend on Argtable3.
SBG Systems has validated the following tool-chain and libraries:
The sbgECom library can be easily ported to any platform with minimal changes.
To adapt the library to your specific platform, you'll need to provide or implement a few low-level methods and configurations:
sbgECom/common/sbgConfig.h
to tailor the library to your environment.sbgGetTime
and sbgSleep
in sbgECom/common/platform/sbgPlatform.c
to handle timing and sleep operations according to your platform's requirements.sbgCommonLibSetLogCallback
to track and manage library error, warning, and info logs.sbgECom/common/interfaces/
directory to ensure data transmission and reception on your platform.To build the sbgECom static library, code examples, and command-line tools, go to the sbgECom
directory and type:
The compiled library, examples, and tools will be located in the sbgECom/build/Debug
folder.
-DUSE_DEPRECATED_MACROS=OFF
to avoid using outdated defines, macros, and enum values.To install the compiled sbgECom library on your system, use the following command:
This will install the static library, headers and cmake files into the default system installation path (e.g., /usr/local on Linux/macOS or C:/Program Files on Windows).
If you want to customize the installation directory, specify it using –prefix option in the cmake command:
Make sure to set the installation path in your system's PATH or library path (LD_LIBRARY_PATH on Linux, DYLD_LIBRARY_PATH on macOS, or environment variables on Windows) if needed.
SBG Systems provides two CLI (Command Line Interface) tools to facilitate evaluation and integration.
You can find the C/C++ source code for each tool in the sbgECom/tools
directory. Pre-compiled 64-bit binaries for Windows, Linux, and Mac OS X platforms are available in the sbgECom/bin/tools
directory.
The sbgBasicLogger
tool parses sbgECom messages from a serial or Ethernet interface and writes the log content to CSV files without altering the device configuration.
It can also read sbgECom messages from a binary file, making it useful for converting sbgECom binary streams to text files.
Additionally, sbgBasicLogger
can extract raw GNSS data streams, RTCM streams, device settings, information, and error logs.
For example, the following command displays received messages on the terminal:
Refer to the sbgBasicLogger README for more details.
The sbgEComApi
tool provides easy access to the sbgInsRestApi over serial or Ethernet UDP interfaces. It enables GET and POST queries through command-line arguments, making it ideal for configuring devices like HPINS, ELLIPSE v3, or PULSE using simple bash scripts.
For example, the following command fetches all device settings as JSON content:
Refer to the sbgEComApi README for more details.
SBG Systems provides several simple C code examples to help you quickly get started with the sbgECom library.
Each example includes both the source code and pre-compiled binaries.
sbgECom/examples
directory.sbgECom/bin/examples
folder, compiled for 64-bit systems.This C code sample demonstrates the usage of the sbgECom
library and the sbgInsRestApi.
This example supports both serial connections and Ethernet UDP communication.
Functionality:
sbgECom
and sbgInsRestApi
.Compatibility:
The code is written in plain ANSI C and is designed to work on any POSIX and Windows system.
With minor modifications, it can also run on bare-metal devices.
The example source file is located in the sbgECom/examples/sbgEComExample
directory.
ELLIPSE v3 (Serial): ELLIPSE devices communicate at 115200 bps over the default serial port A.
HPINS (Ethernet UDP): Uses an Ethernet UDP connection with the device's default output port set to 1234 and input port set to 5678.
The IP address is typically acquired via DHCP. In this example, assume the device IP address is 192.168.1.1:
PULSE (Serial): PULSE IMUs communicate at 921600 bps by default:
This legacy C code sample demonstrates the usage of sbgECom
for ELLIPSE devices running firmware v2 or earlier.
It uses only the legacy configuration commands and does not rely on the newer sbgInsRestApi.
The example source file is located in the sbgECom/examples/ellipseLegacy
directory.
To run the example for an ELLIPSE device communicating at 115200 bps over the default serial port A:
The sbgInsRestApi provides easy access to the ELLIPSE on-board magnetic field calibration.
This guide demonstrates how to use the sbgEComApi CLI tool to interact with the sbgInsRestApi.
Alternatively, you can implement this procedure using the SBG_ECOM_CMD_API_GET and SBG_ECOM_CMD_API_POST sbgECom commands.
In this example, we focus on a 3D on-board magnetic calibration. For a 2D calibration, simply change the mode
parameter to 2d
in the payload and ensure that the device is rotated only horizontally during the magnetic field acquisition.
Clear any previously acquired magnetic field data and prepare the device for a new 3D magnetic field acquisition:
Slowly rotate the unit around each IMU axis to acquire representative magnetic field data.
Once enough data has been collected, compute the new magnetic calibration parameters:
If successful, you should receive output similar to the following:
Extract the hardIronCorrection
and softIronCorrection
parameters from the calibration results to update the magnetic calibration.
Ensure that the calibrationMode
field is correctly set to reflect the method used, whether 2d
or 3d
.
This step is essential to store the new magnetic calibration settings in the device's FLASH memory.
The new calibration will only take effect after the device has been rebooted:
This minimal C example demonstrates how to use the ELLIPSE on-board magnetic calibration using the legacy sbgECom commands.
This example is relevant for legacy code that has not yet migrated to the new sbgInsRestApi.
It is also applicable to ELLIPSE v1/v2 devices that do not support the new sbgInsRestApi.
The example source file can be found in the sbgECom/examples/onBoardMagCalib
directory.
You can try this example by typing the following command line:
A simple C example illustrating how to send air data aiding measurements to an ELLIPSE using the sbgECom binary protocol and library.
The following command will send air data aiding to the device while simultaneously reading output messages on the same serial interface: