gogen

package
v0.0.0-...-0b2d427 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Generates Golang types from ROS2 message definitions

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	RclgoImportPath:     "github.com/merlindrones/rclgo",
	MessageModulePrefix: "github.com/merlindrones/rclgo-msgs",
}

Functions

func PrintErr

func PrintErr(a ...any)

func PrintErrf

func PrintErrf(format string, a ...any)

func PrintErrln

func PrintErrln(a ...any)

func RclgoRepoRootPath

func RclgoRepoRootPath() string

RclgoRepoRootPath returns the path to the root of the rclgo repository. Panics if the path can't be determined.

Types

type Config

type Config struct {
	RclgoImportPath     string
	MessageModulePrefix string
	RootPaths           []string
	DestPath            string
	CGOFlagsPath        string

	RegexIncludes  RuleSet
	ROSPkgIncludes []string
	GoPkgIncludes  []string

	LicenseHeader string
}

type Generator

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

func New

func New(config *Config) *Generator

func (*Generator) GenerateCGOFlags

func (g *Generator) GenerateCGOFlags() error

func (*Generator) GenerateGolangMessageTypes

func (g *Generator) GenerateGolangMessageTypes() error

func (*Generator) GeneratePrimitives

func (g *Generator) GeneratePrimitives() error

func (*Generator) GenerateROS2AllMessagesImporter

func (g *Generator) GenerateROS2AllMessagesImporter() error

func (*Generator) GenerateROS2ErrorTypes

func (g *Generator) GenerateROS2ErrorTypes() error

func (*Generator) GenerateRclgoFlags

func (g *Generator) GenerateRclgoFlags() error

func (*Generator) GenerateTestGogenFlags

func (g *Generator) GenerateTestGogenFlags() error

type Metadata

type Metadata struct {
	Name, Package, Type string
}

func (*Metadata) GoPackage

func (m *Metadata) GoPackage() string

func (*Metadata) ImportPath

func (m *Metadata) ImportPath() string

type ROS2Action

type ROS2Action struct {
	*Metadata
	Goal            *ROS2Message
	Result          *ROS2Message
	Feedback        *ROS2Message
	SendGoal        *ROS2Service
	GetResult       *ROS2Service
	FeedbackMessage *ROS2Message
}

func NewROS2Action

func NewROS2Action(pkg, name string) *ROS2Action

type ROS2Constant

type ROS2Constant struct {
	RosType    string
	GoType     string
	RosName    string
	Value      string
	Comment    string
	PkgName    string
	PkgIsLocal bool
}

ROS2Constant is a message definition.

func (*ROS2Constant) GoPkgReference

func (t *ROS2Constant) GoPkgReference() string

type ROS2ErrorType

type ROS2ErrorType struct {
	Name      string
	Rcl_ret_t string // The function call return value the error is mapped to
	Reference string // This is a reference to another type, so we just redefine the same type with another name
	Comment   string // Any found comments before or over the #definition
}

ROS2ErrorType must have fields exported otherwise they cannot be used by the test/template -package

type ROS2Field

type ROS2Field struct {
	TypeArray    string
	ArrayBounded string
	ArraySize    int
	DefaultValue string
	PkgName      string
	GoPkgName    string
	PkgIsLocal   bool
	RosType      string
	CType        string
	GoType       string
	RosName      string
	CName        string
	GoName       string
	Comment      string
}

Field is a message field.

func (*ROS2Field) GoPkgReference

func (t *ROS2Field) GoPkgReference() string

func (*ROS2Field) IsSingleComplex

func (t *ROS2Field) IsSingleComplex() bool

type ROS2Message

type ROS2Message struct {
	*Metadata
	Fields    []*ROS2Field
	Constants []*ROS2Constant
	GoImports map[string]string
	CImports  stringSet
}

ROS2Message is a message definition. https://design.ros2.org/articles/legacy_interface_definition.html Use ROS2MessageNew() to initialize the struct

func ParseMessage

func ParseMessage(config *Config, content string) (*ROS2Message, error)

func ROS2MessageNew

func ROS2MessageNew(pkg, name string) *ROS2Message

type ROS2Service

type ROS2Service struct {
	*Metadata
	Request  *ROS2Message
	Response *ROS2Message
}

func NewROS2Service

func NewROS2Service(pkg, name string) *ROS2Service

type Rule

type Rule struct {
	Pattern *regexp.Regexp
}

func NewRule

func NewRule(pattern string) (*Rule, error)

type RuleSet

type RuleSet []*Rule

func (RuleSet) Includes

func (s RuleSet) Includes(str string) bool

Jump to

Keyboard shortcuts

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