1 Star 1 Fork 2

AMOVLAB / amov-gimbal-libs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

阿木实验室 云台/吊舱驱动库

本仓库提供适用于多个平台的云台C++驱动库及简要例程

快速入门

支持的设备

支持的平台

  • X86_64-linux
  • X86_64-Windows
  • i386-linux
  • i386-Windows
  • aarch64-linux
  • aarch32-hf-linux
  • aarch32-sf-linux

获取仓库

git clone https://gitee.com/amovlab/amov-gimbal-libs.git

依赖

  • GLIBC (2.34 or later)
  • CMake(version 3.0 or later)
  • MinGw(Windos下需使用MinGw进行构建及编译)

安装及使用云台库

Windos

  • 无需安装,在编写程序时正确导入 /inc/amovGimbal 目录下的头文件 以及/lib 目录下指定架构的dll文件
  • 运行应用时将对应的dll文件复制至相同路径下即可
  • 导入方式可参考CMakeList.txt文件的处理方式 如下所示
target_link_libraries(${PROJECT_NAME} libAMOV_Gimbal.dll)   #链接 AMOV_Gimbal库
link_directories(${libAMOV_Gimbal_dir})                     #指定库文件目录 libAMOV_Gimbal_dir即为库文件所在的目录
target_include_directories(${PROJECT_NAME} ${inc_dir})      #指定头文件目录 inc_dir即为库文件路径所在的目录    

Linux

sudo cp lib/*****/libAMOV_Gimbal.so /usr/lib/       #库文件
sudo cp -r inc/amovGimbal usr/include/              #头文件

例程

  • 本工程中提供以G1吊舱为样例的C++、python3使用例程
  • python例程通过调用ctypes中间层(/example/2py.cpp)实现,因此正确运行python例程需要构建C++例程
  • 以下提供一个linux单独构建的CMakeList.txt参考(位于根目录):
#构建前需正确安装库
add_subdirectory(example/serial)                                    #添加串口子模块
add_library(AMOV_Gimbal_python SHARED example/2py.cpp)              #指定构建目标
target_link_libraries(AMOV_Gimbal_python serial AMOV_Gimbal)        #链接串口库、AMOV_Gimbal库   
target_include_directories(AMOV_Gimbal_python                       #指定头文件
    PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
)

构建

Windos

cmake -B build -G "MinGW Makefiles"
cmake --build build

Linux

mkdir build
cd build
cmake ..
make

C++例程

Windos

  • 复制 lib/*-win/libAMOV_Gimbal.dll build/example/serial/libserial.dll(在build目录下可不复制这个) 至运行目录
./build/example_test.exe COM* G1                        #以运行G1吊舱为例

Linux

sudo cp build/example/serial/libserial.so /usr/lib/     #安装串口库
chmod 777 /dev/tty*                                     #赋予串口权限
./build/example_test /dev/tty* G1                       #以运行G1吊舱为例 

结果

  • 云台将间隔约2S向正方向与初始点间摆动并在控制台输出姿态信息,如下所示
GIMBAL_CMD_RCV_POS
=============================================
HALL_yaw: 0.00
HALL_roll: 0.00
HALL_pitch: 0.00
GYRO_yaw: 0.00
GYRO_roll: 0.00
GYRO_pitch: 0.00

python 例程

通过/example/2py.cpp构建ctypes风格库从而使得python可以通过ctypes模块调用C++库 python例程为/example/example.py 该例程实现了云台在20°(roll),30°(pitch),40°(yaw)姿态与初始姿态往复运动 并通过控制台输出实时姿态信息,其余功能可参考例程函数实现

图像快速获取

分别提供普通WEB相机与流媒体相机通过opencv获取图像的简易demo

  • 使用前需编译或安装opencv-python
  • example/example_stream_cam_image.py 适用于流媒体相机
  • example/example_web_cam_image.py 适用于普通WEB相机

依赖安装

  • 在已完成C++例程的基础上如下操作

Windos

  • 复制 lib/*-win/libAMOV_Gimbal.dll build/example/serial/libserial.dll build/libAMOV_Gimbal_python.dll 至example/目录
cd example/
python example.py

Linux

sudo cp build/libAMOV_Gimbal_python.so /usr/lib/
chmod 777 /dev/tty*                                     #赋予串口权限
sudo chmod +x example/example.py                        #赋予可执行权限
python3 example/example.py

库及构建信息

该库编译采用C++11标准,使用pthread

该库采用交叉编译技术于 Ubuntu 20.04.6 LTS 系统中进行构建 下面是针对不同的平台采用的编译器信息

  • x86_64-linux/i386-linux: gcc/g++ (version 9.3.0)
  • x86_64-Windows/i386-Windows: w64-mingw32-gcc-posix/w64-mingw32-g++-posix (gcc version 9.3.0)
  • arrch64-linux: aarch64-linux-gnu-gcc/aarch64-linux-gnu-g++ (gcc version 9.3.0)
  • arm-hf-linux: arm-linux-gnu-gcc-hf/arm-linux-gnu-g++-hf (gcc version 9.4.0)
  • arm-sf-linux: arm-linux-gnu-gcc-sf/arm-linux-gnu-g++-sf (gcc version 9.4.0)

用户可根据这些信息分析可能存在的兼容性问题

MIT License Copyright (c) 2023 AmovLab Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/amovlab/amov-gimbal-libs.git
git@gitee.com:amovlab/amov-gimbal-libs.git
amovlab
amov-gimbal-libs
amov-gimbal-libs
master

搜索帮助