gobot
gobot copied to clipboard
Added An Example With Tmux For Keyboard control
package main
// import ( // "time"
// "gobot.io/x/gobot" // "gobot.io/x/gobot/platforms/dji/tello" // )
// func main() { // drone := tello.NewDriver("8888")
// work := func() { // drone.TakeOff() // // var count int // // gobot.Every(1time.Second, func() { // // drone.Hover() // // if count == 30{ // // drone.Land() // // } // // drone.Clockwise(30) // // }) // gobot.After(3time.Second, func() { // drone.BackFlip() // }) // drone.BackFlip()
// } // robot := gobot.NewRobot("tello", // []gobot.Connection{}, // []gobot.Device{drone}, // work, // )
// robot.Start() // }
import ( "fmt" "os"
term "github.com/nsf/termbox-go"
"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/dji/tello"
// "gobot.io/x/gobot/platforms/opencv"
// "gocv.io/x/gocv"
)
const ( frameSize = 960 * 720 * 3 )
func reset() { term.Sync() // cosmestic purpose } func main() { err := term.Init() if err != nil { panic(err) } defer term.Close() drone := tello.NewDriver("8890") work := func() { fmt.Println("Enter any key to see their ASCII code or press ESC button to quit") fmt.Println("Connected") for { switch ev := term.PollEvent(); ev.Type { case term.EventKey: switch ev.Key { case term.KeyEsc: drone.Land() os.Exit(9) case term.KeyF1: drone.BackFlip() reset() fmt.Println("F1 pressed") // case term.KeyF2: // reset() // fmt.Println("F2 pressed") // case term.KeyF3: // reset() // fmt.Println("F3 pressed") // case term.KeyF4: // reset() // fmt.Println("F4 pressed") // case term.KeyF5: // reset() // fmt.Println("F5 pressed") // case term.KeyF6: // reset() // fmt.Println("F6 pressed") // case term.KeyF7: // reset() // fmt.Println("F7 pressed") // case term.KeyF8: // reset() // fmt.Println("F8 pressed") // case term.KeyF9: // reset() // fmt.Println("F9 pressed") // case term.KeyF10: // reset() // fmt.Println("F10 pressed") // case term.KeyF11: // reset() // fmt.Println("F11 pressed") // case term.KeyF12: // reset() // fmt.Println("F12 pressed") // case term.KeyInsert: // reset() // fmt.Println("Insert pressed") // case term.KeyDelete: // reset() // fmt.Println("Delete pressed") // case term.KeyHome: // reset() // fmt.Println("Home pressed") // case term.KeyEnd: // reset() // fmt.Println("End pressed") case term.KeyPgup: drone.Up(9) reset() fmt.Println("Page Up pressed") case term.KeyPgdn: drone.Down(9) reset() fmt.Println("Page Down pressed") case term.KeyArrowUp: drone.Forward(9) reset() fmt.Println("Arrow Up pressed") case term.KeyArrowDown: drone.Backward(9) reset() fmt.Println("Arrow Down pressed") case term.KeyArrowLeft: drone.Left(9) reset() fmt.Println("Arrow Left pressed") case term.KeyArrowRight: drone.Right(9) reset() fmt.Println("Arrow Right pressed") case term.KeySpace: // drone.Hover() drone.BackFlip() reset() fmt.Println("Space pressed") case term.KeyBackspace: drone.Land() reset() fmt.Println("Backspace pressed") os.Exit(18) case term.KeyEnter: drone.TakeOff() reset() fmt.Println("Enter pressed") // case term.KeyTab: // reset() // fmt.Println("Tab pressed")
default:
// we only want to read a single character or one key pressed event
reset()
fmt.Println("ASCII : ", ev.Ch)
}
case term.EventError:
panic(ev.Err)
}
}
// drone.On(tello.ConnectedEvent, func(data interface{}) {
// err := term.Init()
// if err != nil {
// panic(err)
// }
// })
}
robot := gobot.NewRobot("tello",
[]gobot.Connection{},
[]gobot.Device{drone},
work,
)
robot.Start()
}
Hello @sharmasandeepkr sorry for the delay in reviewing this PR.
I do not see any commit in this pull request that contains a new example. Was that what you meant with the code in your comment?
Codecov Report
Merging #705 (27c76b4) into master (9d38858) will increase coverage by
79.00%
. The diff coverage is74.57%
.
@@ Coverage Diff @@
## master #705 +/- ##
===========================================
+ Coverage 0 79.00% +79.00%
===========================================
Files 0 73 +73
Lines 0 4886 +4886
===========================================
+ Hits 0 3860 +3860
- Misses 0 780 +780
- Partials 0 246 +246
Impacted Files | Coverage Δ | |
---|---|---|
drivers/spi/apa102.go | 80.00% <ø> (ø) |
|
drivers/spi/mcp3002.go | 40.62% <ø> (ø) |
|
drivers/spi/mcp3004.go | 39.39% <ø> (ø) |
|
drivers/spi/mcp3008.go | 39.39% <ø> (ø) |
|
drivers/spi/mcp3202.go | 37.14% <ø> (ø) |
|
drivers/spi/mcp3204.go | 37.14% <ø> (ø) |
|
drivers/spi/mcp3208.go | 37.14% <ø> (ø) |
|
drivers/spi/mcp3304.go | 37.14% <ø> (ø) |
|
robot_work.go | 80.00% <ø> (ø) |
|
version.go | 100.00% <ø> (ø) |
|
... and 82 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 9d38858...27c76b4. Read the comment docs.
Codecov Report
Merging #705 (3bfba27) into master (9d38858) will increase coverage by
78.61%
. The diff coverage is70.96%
.
:exclamation: Current head 3bfba27 differs from pull request most recent head ae9eadc. Consider uploading reports for the commit ae9eadc to get more accurate results
@@ Coverage Diff @@
## master #705 +/- ##
===========================================
+ Coverage 0 78.61% +78.61%
===========================================
Files 0 78 +78
Lines 0 6280 +6280
===========================================
+ Hits 0 4937 +4937
- Misses 0 1023 +1023
- Partials 0 320 +320
Impacted Files | Coverage Δ | |
---|---|---|
drivers/spi/apa102.go | 78.00% <ø> (ø) |
|
drivers/spi/mcp3002.go | 42.10% <ø> (ø) |
|
drivers/spi/mcp3004.go | 41.02% <ø> (ø) |
|
drivers/spi/mcp3008.go | 41.02% <ø> (ø) |
|
drivers/spi/mcp3202.go | 39.02% <ø> (ø) |
|
drivers/spi/mcp3204.go | 39.02% <ø> (ø) |
|
drivers/spi/mcp3208.go | 39.02% <ø> (ø) |
|
drivers/spi/mcp3304.go | 39.02% <ø> (ø) |
|
robot_work.go | 76.74% <ø> (ø) |
|
version.go | 100.00% <ø> (ø) |
|
... and 87 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 9d38858...ae9eadc. Read the comment docs.
@sharmasandeepkr and @deadprogram because this PR has no answer to the last question since more than 2 years, I'm going to close the PR without any merge.