-
Notifications
You must be signed in to change notification settings - Fork 110
/
base.go
81 lines (67 loc) · 1.79 KB
/
base.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Package fake implements a fake base.
package fake
import (
"context"
"github.com/edaniels/golog"
"github.com/golang/geo/r3"
"go.viam.com/rdk/components/base"
"go.viam.com/rdk/components/generic"
"go.viam.com/rdk/config"
"go.viam.com/rdk/registry"
"go.viam.com/rdk/resource"
)
func init() {
registry.RegisterComponent(
base.Subtype,
resource.NewDefaultModel("fake"),
registry.Component{
Constructor: func(
ctx context.Context,
_ registry.Dependencies,
config config.Component,
logger golog.Logger,
) (interface{}, error) {
return &Base{Name: config.Name}, nil
},
},
)
}
var _ = base.LocalBase(&Base{})
// Base is a fake base that returns what it was provided in each method.
type Base struct {
generic.Echo
Name string
CloseCount int
}
// MoveStraight does nothing.
func (b *Base) MoveStraight(ctx context.Context, distanceMm int, mmPerSec float64, extra map[string]interface{}) error {
return nil
}
// Spin does nothing.
func (b *Base) Spin(ctx context.Context, angleDeg, degsPerSec float64, extra map[string]interface{}) error {
return nil
}
// SetPower does nothing.
func (b *Base) SetPower(ctx context.Context, linear, angular r3.Vector, extra map[string]interface{}) error {
return nil
}
// SetVelocity does nothing.
func (b *Base) SetVelocity(ctx context.Context, linear, angular r3.Vector, extra map[string]interface{}) error {
return nil
}
// Width returns some arbitrary width.
func (b *Base) Width(ctx context.Context) (int, error) {
return 600, nil
}
// Stop does nothing.
func (b *Base) Stop(ctx context.Context, extra map[string]interface{}) error {
return nil
}
// IsMoving always returns false.
func (b *Base) IsMoving(ctx context.Context) (bool, error) {
return false, nil
}
// Close does nothing.
func (b *Base) Close() {
b.CloseCount++
}