steering

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

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

func NewController

func NewController(client mqtt.Client, steeringTopic, driveModeTopic, rcSteeringTopic, tfSteeringTopic, objectsTopic string, options ...Option) *Controller

func (*Controller) Objects

func (c *Controller) Objects() []*events.Object

func (*Controller) Start

func (c *Controller) Start() error

func (*Controller) Stop

func (c *Controller) Stop()

type Corrector

type Corrector interface {
	AdjustFromObjectPosition(currentSteering float64, objects []*events.Object) float64
}

type GridCorrector

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

func NewGridCorrector

func NewGridCorrector(options ...OptionCorrector) *GridCorrector

func (*GridCorrector) AdjustFromObjectPosition

func (c *GridCorrector) AdjustFromObjectPosition(currentSteering float64, objs []*events.Object) float64

AdjustFromObjectPosition modify steering value according object positions

  1. To compute steering correction, split in image in zones and define correction value for each zone

    Steering computed : -1 -0.66 -0.33 0 0.33 0.66 1 0% |-----|-----|-----|-----|-----|-----| : | 0 | 0 | 0 | 0 | 0 | 0 | 20% |-----|-----|-----|-----|-----|-----| : | 0 | 0 | 0 | 0 | 0 | 0 | 40% |-----|-----|-----|-----|-----|-----| : | 0 | 0 | 0.25|-0.25| 0 | 0 | 60% |-----|-----|-----|-----|-----|-----| : | 0 | 0.25| 0.5 |-0.5 |-0.25| 0 | 80% |-----|-----|-----|-----|-----|-----| : | 0.25| 0.5 | 1 | -1 |-0.5 |-0.25| 100%|-----|-----|-----|-----|-----|-----|

  2. For straight (current steering near of 0), search nearest object and if:

    * left and right values < 0: use correction from right value according image splitting * left and right values > 0: use correction from left value according image splitting * left < 0 and right values > 0: use (right + (right - left) / 2) value

  3. If current steering != 0 (turn on left or right), shift right and left values proportionnaly to current steering and apply 2.

    : -1 -0.66 -0.33 0 0.33 0.66 1 0% |-----|-----|-----|-----|-----|-----| : | 0 | 0 | 0 | 0 | 0 | 0 | 20% |-----|-----|-----|-----|-----|-----| : | 0.2 | 0.1 | 0 | 0 |-0.1 |-0.2 | 40% |-----|-----|-----|-----|-----|-----| : | ... | ... | ... | ... | ... | ... |

type GridMap

type GridMap struct {
	DistanceSteps []float64   `json:"distance_steps"`
	SteeringSteps []float64   `json:"steering_steps"`
	Data          [][]float64 `json:"data"`
}

func NewGridMapFromJson

func NewGridMapFromJson(fileName string) (*GridMap, error)

func (*GridMap) ValueOf

func (f *GridMap) ValueOf(steering float64, distance float64) (float64, error)

type Option

type Option func(c *Controller)

func WithCorrector

func WithCorrector(c Corrector) Option

func WithObjectsCorrectionEnabled

func WithObjectsCorrectionEnabled(enabled, enabledOnUserDrive bool) Option

type OptionCorrector

type OptionCorrector func(c *GridCorrector)

func WidthDeltaMiddle

func WidthDeltaMiddle(d float64) OptionCorrector

func WithGridMap

func WithGridMap(configPath string) OptionCorrector

func WithObjectMoveFactors

func WithObjectMoveFactors(configPath string) OptionCorrector

Jump to

Keyboard shortcuts

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