Add Pitch, Roll & Yaw display

This commit is contained in:
Stephen Merrony
2018-06-23 17:17:04 +01:00
parent 5abba0793d
commit 7c56a6de16
2 changed files with 34 additions and 1 deletions

21
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {},
"args": [],
"showLog": true
}
]
}

View File

@@ -100,6 +100,9 @@ const (
fQatY
fQatZ
fTemp
fRoll
fPitch
fYaw
fSSID
fVersion
fNumFields
@@ -157,6 +160,10 @@ func setupFields() {
fields[fTemp] = field{label{4, 19, termbox.ColorWhite, termbox.ColorDefault, "Temp:"}, 16, 19, 6, termbox.ColorWhite, termbox.ColorDefault, "?"}
fields[fQatW] = field{label{30, 19, termbox.ColorWhite, termbox.ColorDefault, "W Quat:"}, 42, 19, 6, termbox.ColorWhite, termbox.ColorDefault, "?"}
fields[fRoll] = field{label{4, 20, termbox.ColorWhite, termbox.ColorDefault, "Roll:"}, 16, 20, 6, termbox.ColorWhite, termbox.ColorDefault, "?"}
fields[fPitch] = field{label{30, 20, termbox.ColorWhite, termbox.ColorDefault, "Pitch:"}, 42, 20, 6, termbox.ColorWhite, termbox.ColorDefault, "?"}
fields[fYaw] = field{label{54, 20, termbox.ColorWhite, termbox.ColorDefault, "Yaw:"}, 66, 20, 6, termbox.ColorWhite, termbox.ColorDefault, "?"}
fields[fSSID] = field{label{10, 22, termbox.ColorWhite, termbox.ColorDefault, "SSID: "}, 16, 22, 20, termbox.ColorWhite, termbox.ColorDefault, "?"}
fields[fVersion] = field{label{56, 22, termbox.ColorWhite, termbox.ColorDefault, "Firmware: "}, 66, 22, 10, termbox.ColorWhite, termbox.ColorDefault, "?"}
@@ -461,6 +468,11 @@ func updateFields(newFd tello.FlightData) {
fields[fQatZ].value = fmt.Sprintf("%f", newFd.IMU.QuaternionZ)
fields[fTemp].value = fmt.Sprintf("%dC", newFd.IMU.Temperature)
p, r, y := tello.QuatToEulerDeg(float64(newFd.IMU.QuaternionX), float64(newFd.IMU.QuaternionY), float64(newFd.IMU.QuaternionZ), float64(newFd.IMU.QuaternionW))
fields[fRoll].value = fmt.Sprintf("%d", r)
fields[fPitch].value = fmt.Sprintf("%d", p)
fields[fYaw].value = fmt.Sprintf("%d", y)
fields[fSSID].value = newFd.SSID
fields[fVersion].value = newFd.Version
}
@@ -495,7 +507,7 @@ func startVideo() {
go func() {
for {
drone.StartVideo()
time.Sleep(time.Second)
time.Sleep(500 * time.Millisecond)
}
}()