gobot: gobot.io/x/gobot/platforms/mavlink Index | Files

package mavlink

import "gobot.io/x/gobot/platforms/mavlink"

Package mavlink contains the Gobot adaptor and driver for the MAVlink Communication Protocol.

Installing:

go get gobot.io/x/gobot/platforms/mavlink

Example:

package main

import (
	"fmt"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/platforms/mavlink"
	common "gobot.io/x/gobot/platforms/mavlink/common"
)

func main() {
	adaptor := mavlink.NewAdaptor("/dev/ttyACM0")
	iris := mavlink.NewDriver(adaptor)

	work := func() {
		iris.Once(iris.Event("packet"), func(data interface{}) {
			packet := data.(*common.MAVLinkPacket)

			dataStream := common.NewRequestDataStream(100,
				packet.SystemID,
				packet.ComponentID,
				4,
				1,
			)
			iris.SendPacket(common.CraftMAVLinkPacket(packet.SystemID,
				packet.ComponentID,
				dataStream,
			))
		})

		iris.On(iris.Event("message"), func(data interface{}) {
			if data.(common.MAVLinkMessage).Id() == 30 {
				message := data.(*common.Attitude)
				fmt.Println("Attitude")
				fmt.Println("TIME_BOOT_MS", message.TIME_BOOT_MS)
				fmt.Println("ROLL", message.ROLL)
				fmt.Println("PITCH", message.PITCH)
				fmt.Println("YAW", message.YAW)
				fmt.Println("ROLLSPEED", message.ROLLSPEED)
				fmt.Println("PITCHSPEED", message.PITCHSPEED)
				fmt.Println("YAWSPEED", message.YAWSPEED)
				fmt.Println("")
			}
		})
	}

	robot := gobot.NewRobot("mavBot",
		[]gobot.Connection{adaptor},
		[]gobot.Device{iris},
		work,
	)

	robot.Start()
}

For further information refer to mavlink README: https://github.com/hybridgroup/gobot/blob/master/platforms/mavlink/README.md

Index

Package Files

doc.go mavlink_adaptor.go mavlink_driver.go mavlink_udp_adaptor.go

Constants

const (
    // PacketEvent event
    PacketEvent = "packet"
    // MessageEvent event
    MessageEvent = "message"
    // ErrorIOEEvent event
    ErrorIOEvent = "errorIO"
    // ErrorMAVLinkEvent event
    ErrorMAVLinkEvent = "errorMAVLink"
)

type Adaptor Uses

type Adaptor struct {
    // contains filtered or unexported fields
}

Adaptor is a Mavlink-over-serial adaptor.

func NewAdaptor Uses

func NewAdaptor(port string) *Adaptor

NewAdaptor creates a new mavlink adaptor with specified port

func (*Adaptor) Connect Uses

func (m *Adaptor) Connect() (err error)

Connect returns true if connection to device is successful

func (*Adaptor) Finalize Uses

func (m *Adaptor) Finalize() (err error)

Finalize returns true if connection to devices is closed successfully

func (*Adaptor) Name Uses

func (m *Adaptor) Name() string

func (*Adaptor) Port Uses

func (m *Adaptor) Port() string

func (*Adaptor) ReadMAVLinkPacket Uses

func (m *Adaptor) ReadMAVLinkPacket() (*common.MAVLinkPacket, error)

func (*Adaptor) SetName Uses

func (m *Adaptor) SetName(n string)

func (*Adaptor) Write Uses

func (m *Adaptor) Write(b []byte) (int, error)

type BaseAdaptor Uses

type BaseAdaptor interface {
    gobot.Connection

    io.Writer
    ReadMAVLinkPacket() (*common.MAVLinkPacket, error)
}

Adaptor is a Mavlink transport adaptor.

type Driver Uses

type Driver struct {
    gobot.Eventer
    // contains filtered or unexported fields
}

func NewDriver Uses

func NewDriver(a BaseAdaptor, v ...time.Duration) *Driver

NewDriver creates a new mavlink driver.

It add the following events:

"packet" - triggered when a new packet is read
"message" - triggered when a new valid message is processed

func (*Driver) Connection Uses

func (m *Driver) Connection() gobot.Connection

func (*Driver) Halt Uses

func (m *Driver) Halt() (err error)

Halt returns true if device is halted successfully

func (*Driver) Name Uses

func (m *Driver) Name() string

func (*Driver) SendPacket Uses

func (m *Driver) SendPacket(packet *common.MAVLinkPacket) (err error)

SendPacket sends a packet to mavlink device

func (*Driver) SetName Uses

func (m *Driver) SetName(n string)

func (*Driver) Start Uses

func (m *Driver) Start() error

Start begins process to read mavlink packets every m.Interval and process them

type MavlinkInterface Uses

type MavlinkInterface interface {
}

type UDPAdaptor Uses

type UDPAdaptor struct {
    // contains filtered or unexported fields
}

func NewUDPAdaptor Uses

func NewUDPAdaptor(port string) *UDPAdaptor

NewAdaptor creates a new Mavlink-over-UDP adaptor with specified port.

func (*UDPAdaptor) Connect Uses

func (m *UDPAdaptor) Connect() error

Connect returns true if connection to device is successful

func (*UDPAdaptor) Finalize Uses

func (m *UDPAdaptor) Finalize() (err error)

Finalize returns true if connection to devices is closed successfully

func (*UDPAdaptor) Name Uses

func (m *UDPAdaptor) Name() string

func (*UDPAdaptor) Port Uses

func (m *UDPAdaptor) Port() string

func (*UDPAdaptor) ReadMAVLinkPacket Uses

func (m *UDPAdaptor) ReadMAVLinkPacket() (*common.MAVLinkPacket, error)

func (*UDPAdaptor) SetName Uses

func (m *UDPAdaptor) SetName(n string)

func (*UDPAdaptor) Write Uses

func (m *UDPAdaptor) Write(b []byte) (int, error)

type UDPConnection Uses

type UDPConnection interface {
    Close() error
    ReadFromUDP([]byte) (int, *net.UDPAddr, error)
    WriteTo([]byte, net.Addr) (int, error)
}

Package mavlink imports 6 packages (graph). Updated 2019-05-24. Refresh now. Tools for package owners.