组装过程中为了测试电机的连接以及转向,现将电机测试功能单独制作一个页面,以便使用。
一,效果
原型
实际效果总是差那么一丢丢.
二,实现思路
- MavlinkConsole 功能,可以在地面站上直接发送nash指令,利用此可以测试一些传感器的基本功能。比如陀螺,磁力计等。
- 由于我的地面站是基于QGC3.1.3修改的 ,但是此版本的地面站没有MavlinkConsole 功能,所以需要将高版本的此功能移植过来。mavlink2.0以上版本的固件都具备此功能,而地面站此需要3.3.2以上。移植时直接将MavlinkConsolePage.qml界面文件 与MavlinkConsoleController.h和MavlinkConsoleController.cpp 控制类 拷贝过来即可。
- 新建MotorTestPage.qml电机测试界面,调用MavlinkConsoleController 控制类即可。
- 关键指令:
pwm test -c 1 -p 1200 // 1 表示第几个电机 。1200 表示转速,此数值为0 则停止转动
- 界面:
QGCButton {
id:startBtn
text: qsTr("开始")
width: _butttonWidth
anchors.left:splierR.right
anchors.leftMargin:10
anchors.topMargin:50
onClicked: {
//pwm test -c 1 -p 1200
var commandStr = "pwm test -c "+(index+1)+" -p "+rValue
conController.sendCommand(commandStr)
}
}
QGCButton {
id:stopBtn
text: qsTr("停止")
width: _butttonWidth
anchors.left:startBtn.right
anchors.leftMargin:5
anchors.topMargin:50
onClicked: {
var commandStr = "pwm test -c "+(index+1)+" -p 0"
//pwm test -c 1 -p 0
conController.sendCommand(commandStr)
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)