原文:
GitHub - thinkexist1989/SRI-FTSensor-SDK: C++ wrappper of the FT Sensor made by Sunrise Instruments.C++ wrappper of the FT Sensor made by Sunrise Instruments. - GitHub - thinkexist1989/SRI-FTSensor-SDK: C++ wrappper of the FT Sensor made by Sunrise Instruments.https://github.com/thinkexist1989/SRI-FTSensor-SDK.git 介绍:SRI FTSensor SDK是Sunrise Instruments制作的FTSensor的跨平台c++封装。
依赖:SRI FTSensor SDK是一个仅头文件的库。但这取决于一些Boost lib。
Boost.Asio 提供tcp ,串口通讯
还可以使用一些Boost头文件专用库,如lexical_cast、format和string_algo。
如果你使用的是类linux系统(例如Ubuntu), Boost可以通过包管理器轻松安装:
$ sudo apt install boost-all-dev
编译:您可以将所有头文件(在include目录中)放入您自己的项目中,并对其进行编译。在根目录中,有一个示例来展示如何使用这个SDK。在安装Boost库之后,您可以输入以下命令:
$ git clone https://github.com/thinkexist1989/SRI-FTSensor-SDK.git
$ cd SRI-FTSensor-SDK/
$ mkdir build && cd build
$ cmake ..
$ make -j`nproc`
$ ./test #Run the example
使用:1.在main.cpp中包含头文件
#include <sri/ftsensor.hpp>
#include <sri/commethernet.hpp> // connection to the tcp-type FTSensor
#include <iostream>
int main() {
...
}
2.初始化与FTSensor的通信(我有一个ip 192.168.1.108的tcp类型传感器
SRI::CommEthernet* ce = new SRI::CommEthernet("192.168.1.108", 4008);
3.通过通讯初始化传感器
SRI::FTSensor sensor(ce);
4。获取或设置一些参数
IpAddr ip = sensor.getIpAddress();
5.获取传感器实时数据
auto rtData = sensor.getRealTimeDataOnce<float>(rtMode,rtDataValid);