gobot.io/x/gobot/v2@v2.1.0/platforms/mavlink/doc.go (about) 1 /* 2 Package mavlink contains the Gobot adaptor and driver for the MAVlink Communication Protocol. 3 4 Installing: 5 6 go get gobot.io/x/gobot/v2/platforms/mavlink 7 8 Example: 9 10 package main 11 12 import ( 13 "fmt" 14 15 "gobot.io/x/gobot/v2" 16 "gobot.io/x/gobot/v2/platforms/mavlink" 17 common "gobot.io/x/gobot/v2/platforms/mavlink/common" 18 ) 19 20 func main() { 21 adaptor := mavlink.NewAdaptor("/dev/ttyACM0") 22 iris := mavlink.NewDriver(adaptor) 23 24 work := func() { 25 iris.Once(iris.Event("packet"), func(data interface{}) { 26 packet := data.(*common.MAVLinkPacket) 27 28 dataStream := common.NewRequestDataStream(100, 29 packet.SystemID, 30 packet.ComponentID, 31 4, 32 1, 33 ) 34 iris.SendPacket(common.CraftMAVLinkPacket(packet.SystemID, 35 packet.ComponentID, 36 dataStream, 37 )) 38 }) 39 40 iris.On(iris.Event("message"), func(data interface{}) { 41 if data.(common.MAVLinkMessage).Id() == 30 { 42 message := data.(*common.Attitude) 43 fmt.Println("Attitude") 44 fmt.Println("TIME_BOOT_MS", message.TIME_BOOT_MS) 45 fmt.Println("ROLL", message.ROLL) 46 fmt.Println("PITCH", message.PITCH) 47 fmt.Println("YAW", message.YAW) 48 fmt.Println("ROLLSPEED", message.ROLLSPEED) 49 fmt.Println("PITCHSPEED", message.PITCHSPEED) 50 fmt.Println("YAWSPEED", message.YAWSPEED) 51 fmt.Println("") 52 } 53 }) 54 } 55 56 robot := gobot.NewRobot("mavBot", 57 []gobot.Connection{adaptor}, 58 []gobot.Device{iris}, 59 work, 60 ) 61 62 robot.Start() 63 } 64 65 For further information refer to mavlink README: 66 https://github.com/hybridgroup/gobot/blob/master/platforms/mavlink/README.md 67 */ 68 package mavlink // import "gobot.io/x/gobot/v2/platforms/mavlink"