Panel | ||||||
---|---|---|---|---|---|---|
| ||||||
This content is no longer in active support - and is superceded by the code targeted for C++17 accessible at https://navtechradar.atlassian.net/wiki/spaces/IA/pages/2328199577 |
C++ Source Code
This code is a series of classes developed using C++ 11. The source code for end users to easily integrate into their application, regardless of the target platform, is available at https://bitbucket.org/navtechradar/iasdk-public/src/master/cpp/cpp_11/
SDK Requirements
C++ 11
C++11 Compiler
GCC 4.8 and above
Clang 3.5 and above
Visual Studio 2019 (VC++ 2019 runtime libraries)
Building the SDK
The SDK is written in C++ and must be compiled prior to use. The SDK is designed to be compiled by a standard C++ compiler installation; that is, no external libraries (beyond the standard and/or Posix libraries) are required. The SDK may be built using either: * Command line * From Visual Studio Code * From Visual Studio
To build the SDK outside Visual Studio, your platform must have the CMake tools installed. To check if CMake is present, run:
Code Block |
---|
cmake --version |
Building from the command line
Cmake can be invoked directly from the command line to build the SDK, as follows:
Code Block |
---|
cd <IA SDK install path>/iasdk/build
cmake .
make |
The build can be removed by running:
Code Block |
---|
make clean |
The build process will generate two executables by default:
Code Block |
---|
/iasdk/build/testclient
/iasdk/build/navigationclient |
Building from VS Code
The project is configured to work with the Microsoft CMake Tools. If the CMake Tools are installed, opening the project in VSCode should detect the make files and configure the project accordingly. The first time a build is selected you will need to select a compiler kit. This will present a list of possible compiler configurations.
Using the VS Code build task
The .vscode
folder contains a build task configuration for invoking CMake. To build: * hit ctrl-shift-b * select Build
(Note: you can also select Clean as one of the build options)
The build process will (again) generate two executables by default:
Code Block |
---|
/iasdk/build/testclient
/iasdk/build/navigationclient |
Building from Visual Studio
If the Microsoft C++ compiler (msvc) is used, the SDK provides a Visual Studio solution (.sln) file.
Double-clicking on the .sln file will launch Visual Studio. In Visual Studio select:
Build -> Build Solution
(Alternatively, use crtl-shift-b)
...
The SDK C++ API provides an object-based interface for controlling/configuring the radar and for processing incoming data.
Communication to the radar is asynchronous: * Outgoing messages are encapsulated within API calls. The parameters provided to the functions are used to populate Colossus messages, which are sent to the sensor. * Incoming messages from the sensor invoke callbacks. Each (supported) incoming message will have a callback function object associated with it. The callback is passed a (shared) pointer to the received data.
The API handles all endianness and encoding required by the Colossus protocol; removing the need from the client.
Connecting to the sensor
The steps involved in connecting and getting data are as follows:
Setup your radar client and hook up the message and connection events:
Code Block |
---|
#include "radar_client.h"
int main()
{
Navtech::Radar_client radar_client { "127.0.0.1"_ipv4 };
// See below for details on message handler callbacks
//
radar_client.set_configuration_data_callback(config_handler);
radar_client.set_fft_data_callback(fft_handler);
...
} |
Connect to the radar:
Code Block |
---|
int main()
{
Navtech::Radar_client radar_client { "127.0.0.1"_ipv4 };
radar_client.set_configuration_data_callback(config_handler);
radar_client.set_fft_data_callback(fft_handler);
// Connect to the radar
//
radar_client.start();
} |
On successful connection you will receive a Configuration message with details of the radar's current configuration. So you must have the handler setup before you connect.
Message handler callbacks
An incoming Colossus message will be unmarshalled and stored in a message-specific structure.
Each structure also defines a pointer type (usually a std::shared_ptr
). This pointer type is used to allocate, and then access, the structure object created from the incoming Colossus message.
The message handler callback must be a Callable Type - a function, a member-function, a function-object or a lambda expression.
The signature of the Callable Type for a data item of type Message_Ty
depends on the type of the Colossus message being received; for example:
Code Block |
---|
void (*callback_fn_ptr)( // Configuration data
const Configuration_data::Pointer&,
const Configuration_data::ProtobufPointer&
);
void (*callback_fn_ptr)(const Fft_data::Pointer&); // FFT data
void (*callback_fn_ptr)(const std::vector<std::uint8_t>&); // Raw FFT data |
WherePointer
is the message structure-specific pointer type.
For example:
Code Block |
---|
void config_handler(
const Configuration_data::Pointer& data,
const Configuration_data::ProtobufPointer& protobuf_config
)
{
// Process incoming configuration...
} |
Once connected and you have the config data, tell the radar to start sending FFT Data:
Code Block |
---|
radar_client.start_fft_data(); |
You must provide a incoming FFT Data:
Code Block |
---|
void fft_handler(const Fft_data::Pointer& data)
{
// Process incoming FFT data...
} |
When you need to disconnect, firstly stop the FFT Data:
Code Block |
---|
radar_client.stop(); |
Then unbind the data handlers:
Code Block |
---|
radar_client.set_fft_data_callback();
radar_client.set_configuration_data_callback(); |
Then disconnect:
Code Block |
---|
radar_client.stop(); |
The file testclient_main.cpp
contains an example of basic configuration and FFT data processing operations. It can be used as the basis for more complex applications.
...