所需材料:
- 可以插入usb接口的linux系统(本人使用windows的子系统WSL UBUNTU作为N3的计算平台)
- N3飞控系统
- windows上安装DJI Assistant 2 forAutopilot
- lightBridge2遥控器
步骤
-
从dji开源的github网站下载OSDK,切换到3.9版本,因为N3最高只能运行3.9版本的。
git clone [email protected]:dji-sdk/Onboard-SDK.git cd Onboard-SDK git checkout 3.9
-
编译osdk
mkdir build && cd build cmake .. make -j8
-
注册dji账号并注册app, 修改usb设备端口号
// 登录https://www.dji.com/并使用邮箱注册账号 // 使用刚刚的账号密码登录 https://developer.dji.com/cn/user/apps/#all 点击创建应用。 // 随便填写app名称描述等信息,复制APP ID和APP key,将之替换掉/home/wj/Onboard-SDK/sample/platform/linux/common/UserConfig.txt中的app_id和app_key // 通过设备查询usb连接的是COM4,于是更改UserConfig.txt中的device:/dev/ttyS4 // 波特率维持baudrate : 230400 // 将修改后的UserConfig.txt复制到Onborad_SDK/build/bin/中
-
赋于UART端口权限,
sudo chmod 777 /dev/ttyS4 sudo usermod -a -G dialout $USER
-
将N3连接电脑在DJI Assistant 2中设置相关参数
// 打开设置,开启DJI账号信息,DJI设备信息,Onboard SDK APP ID三个选项 // 点开N3,跳到SDK界面,勾选启动API控制选项
-
使用串口连接N3,接口说明参考N3使用0说明第18页,
- GND—GND
- TXD—RXD
- RXD—TXD
-
使用lightbridge连接N3和手机,运行Onboard-SDK/build/bin中的案例
./djiosdk-flightcontrol-sample UserConfig.txt UserConfig.txt // 若显示以下信息表示激活成功 kobosp@KOBOSPG400u:~/CLionProjects/Onboard-SDK-3.9/build/bin$ ./djiosdk-flightcontrol-sample UserConfig.txt argv[1] = UserConfig.txt Read App ID User Configuration read successfully. STATUS/1 @ init, L56: Attempting to open device /dev/ttyUSB0 with baudrate 230400... STATUS/1 @ init, L66: ...Serial started successfully. STATUS/1 @ parseDroneVersionInfo, L762: Device Serial No. = 0670093152 STATUS/1 @ parseDroneVersionInfo, L764: Hardware = A3 STATUS/1 @ parseDroneVersionInfo, L765: Firmware = 3.3.8.47 ERRORLOG/1 @ initVirtualRC, L1188: Virtual RC is not supported on this platform! STATUS/1 @ activate, L1398: version 0x303082F STATUS/1 @ activate, L1411: Activation successful STATUS/1 @ verify, L247: Verify subscription successful. STATUS/1 @ initGimbal, L926: Checking if gimbal is connected ... STATUS/1 @ startPackage, L353: Start package 0 result: 0. STATUS/1 @ startPackage, L355: Package 0 info: freq=50, nTopics=1. STATUS/1 @ removePackage, L471: Remove package 0 successful. STATUS/1 @ initGimbal, L970: Gimbal not mounted! | Available commands: | | [a] Monitored Takeoff + Landing | | [b] Monitored Takeoff + Position Control + Landing | | [c] Monitored Takeoff + Position Control + Force Landing Avoid Ground |
失败可参考:
-
[DJI A3 Onboard SDK problem No connection
扫描二维码关注公众号,回复: 13393601 查看本文章