mobile

package
v0.0.0-...-7a59755 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

README

mobile

Go Mobile wrapper for the Robomaster SDK. This is mostly to address several limitations of Go Mobile and to expose things in a way that it will hopefully not complain about. This shoudl hopefully work with both Android and iOS.

Documentation

Index

Constants

View Source
const (
	CameraHorizontalResolutionPoints = camera.HorizontalResolutionPoints
	CameraVerticalResolutionPoints   = camera.VerticalResolutionPoints
	CameraHorizontalFOVDegrees       = camera.HorizontalFOVDegrees
	CameraVerticalFOVDegrees         = camera.VerticalFOVDegrees
)

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App holds the ID for a specific app.

func NewApp

func NewApp(id int64) (*App, error)

NewApp creates a new App instance with the given ID. If the ID is 0, a new ID will be generated.

func (*App) ID

func (a *App) ID() int64

ID returns the ID for the App instance.

type Camera

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

Camera allows controlling the robot camera.

func (*Camera) AddVideoHandler

func (c *Camera) AddVideoHandler(handler VideoHandler) (int64, error)

AddVideoHandler adds a new video handler to the camera. If this is the first video handler added, the camera will start sending video frames.

func (*Camera) IsRecordingVideo

func (c *Camera) IsRecordingVideo() (bool, error)

IsRecordingVideo returns true if the camera is currently recording video.

func (*Camera) RecordingTimeInSeconds

func (c *Camera) RecordingTimeInSeconds() int64

RecordingTimeInSeconds returns the current recording time in seconds.

func (*Camera) RemoveVideoHandler

func (c *Camera) RemoveVideoHandler(t int64) error

RemoveVideoHandler removes a video handler from the camera. If this is the last video handler removed, the camera will stop sending video frames.

func (*Camera) StartRecordingVideo

func (c *Camera) StartRecordingVideo() error

StartRecordingVideo starts recording video from the camera to the robot's SD card.

func (*Camera) StopRecordingVideo

func (c *Camera) StopRecordingVideo() error

StopRecordingVideo stops recording video from the camera to the robot's SD card.

type Chassis

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

Chassis allows controlling the robot chassis. It also works as the robot main controller interface.

func (*Chassis) Move

func (c *Chassis) Move(ls *StickPosition, rs *StickPosition) error

Move moves the robot using the given stick positions. The left stick controls the robot's gimbal and chassis rotation and the right stick controls the robot's chassis (up/down/left/right).

type Client

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

Client is the main entry point for the mobile SDK.

func NewClient

func NewClient(appID int64) (*Client, error)

NewClient creates a new Client instance. If appID is 0, the client will try to connect to the first available Robomaster robot. If it is non-zero, it will only connect to a robot that is broadcasting the given appID. The appID can be configured in the robot through a qrcode.

func NewWifiDirectClient

func NewWifiDirectClient() (*Client, error)

NewWifiDirectClient creates a new Client instance that will connect to a Robomaster robot using Wifi Direct.

func (*Client) Camera

func (c *Client) Camera() *Camera

Camera returns the Camera instance for the client.

func (*Client) Chassis

func (c *Client) Chassis() *Chassis

Controller returns the Controller instance for the client.

func (*Client) Connection

func (c *Client) Connection() *Connection

Connnection returns the Connection instance for the client.

func (*Client) GamePad

func (c *Client) GamePad() *GamePad

GamePad returns the GamePad instance for the client. The GamePad is optional and may be nil.

func (*Client) Robot

func (c *Client) Robot() *Robot

Robot returns the Robot instance for the client.

func (*Client) Start

func (c *Client) Start() error

Start starts the client.

func (*Client) Stop

func (c *Client) Stop() error

Stop stops the client.

type Connection

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

Camera allows controlling the robot's connection.

func (*Connection) SignalQualityBars

func (c *Connection) SignalQualityBars() int8

SignalQualityBars returns the current signal quality bars (1 to 4).

func (*Connection) SignalQualityLevel

func (c *Connection) SignalQualityLevel() int8

SignalQualityLevel returns the current signal quality level (0 to 60).

type GamePad

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

GamePad allows controlling the DJI Robomaster gamepad accessory.

func (*GamePad) C1Pressed

func (g *GamePad) C1Pressed() bool

C1Pressed returns whether the C1 button is pressed.

func (*GamePad) C2Pressed

func (g *GamePad) C2Pressed() bool

C2Pressed returns whether the C2 button is pressed.

func (*GamePad) FirePressed

func (g *GamePad) FirePressed() bool

FirePressed returns whether the fire button is pressed.

func (*GamePad) FnPressed

func (g *GamePad) FnPressed() bool

FnPressed returns whether the Fn button is pressed.

type QRCode

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

QRCode allows generating QRCodes that can be read by a Robomaster robot.

func NewQRCode

func NewQRCode(appID int64, countryCode, ssID, password,
	bssID string) (*QRCode, error)

NewQRCode creates a new QRCode instance. The bssID parameter is optional and may be an empty string.

func (*QRCode) Image

func (q *QRCode) Image(size int) ([]byte, error)

Image returns the QRCode image (with size as its width and height) as a byte slice with RGB24 image data.

type Robot

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

Robot allows reading the robot parameters.

func (*Robot) BatteryPowerPercent

func (r *Robot) BatteryPowerPercent() int8

BatteryPowerPercent returns the current battery power percent (0 to 100).

type StickPosition

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

StickPosition represents the position of a stick controller.

func NewStickPosition

func NewStickPosition(x, y float64) *StickPosition

NewStickPosition creates a new StickPosition with the given X and Y positions.

func (*StickPosition) InterpolatedX

func (s *StickPosition) InterpolatedX() int64

InterpolatedX returns the interpolated X position of the stick controller.

func (*StickPosition) InterpolatedY

func (s *StickPosition) InterpolatedY() int64

InterpolatedY returns the interpolated Y position of the stick controller.

func (*StickPosition) Set

func (s *StickPosition) Set(x, y float64)

Set sets the position of the stick controller. X and Y must be between 0.0 and 1.0.

type VideoHandler

type VideoHandler interface {
	// HandleVideo is called when a new video frame is received from the camera.
	// rgb24Data, as the name name implies, is the raw data for a RGB24 image and
	// its dimensions are 1280x720.
	HandleVideo(rgb24Data []byte)
}

VideoHandler is the interface that must be implemented by types that want to handle video frames from the camera.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL