-
Notifications
You must be signed in to change notification settings - Fork 110
/
cmd.go
53 lines (46 loc) · 1.14 KB
/
cmd.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
// Package main shows a simple server with a fake arm.
package main
import (
"context"
"go.viam.com/utils"
"go.viam.com/rdk/components/arm"
"go.viam.com/rdk/components/arm/fake"
"go.viam.com/rdk/gostream/codec/x264"
"go.viam.com/rdk/logging"
"go.viam.com/rdk/resource"
robotimpl "go.viam.com/rdk/robot/impl"
"go.viam.com/rdk/robot/web"
)
var logger = logging.NewDebugLogger("simpleserver")
func main() {
utils.ContextualMain(mainWithArgs, logger)
}
func mainWithArgs(ctx context.Context, args []string, logger logging.Logger) error {
arm1Name := arm.Named("arm1")
cfg := resource.Config{
Name: arm1Name.Name,
Model: resource.DefaultModelFamily.WithModel("ur5e"),
ConvertedAttributes: &fake.Config{
ArmModel: "ur5e",
},
}
arm1, err := fake.NewArm(context.Background(), nil, cfg, logger)
if err != nil {
return err
}
myRobot, err := robotimpl.RobotFromResources(
ctx,
map[resource.Name]resource.Resource{
arm1Name: arm1,
},
logger,
robotimpl.WithWebOptions(web.WithStreamConfig(x264.DefaultStreamConfig)),
)
if err != nil {
return err
}
//nolint:errcheck
defer myRobot.Close(ctx)
<-ctx.Done()
return nil
}