@@ -32,12 +32,14 @@ func TestClient(t *testing.T) {
32
32
var (
33
33
capArmPos spatialmath.Pose
34
34
capArmJointPos []referenceframe.Input
35
+ moveOptions arm.MoveOptions
35
36
extraOptions map [string ]interface {}
36
37
)
37
38
38
39
pos1 := spatialmath .NewPoseFromPoint (r3.Vector {X : 1 , Y : 2 , Z : 3 })
39
40
jointPos1 := []referenceframe.Input {{1. }, {2. }, {3. }}
40
41
expectedGeometries := []spatialmath.Geometry {spatialmath .NewPoint (r3.Vector {1 , 2 , 3 }, "" )}
42
+ expectedMoveOptions := arm.MoveOptions {MaxVelRads : 1 , MaxAccRads : 2 }
41
43
injectArm := & inject.Arm {}
42
44
injectArm .EndPositionFunc = func (ctx context.Context , extra map [string ]interface {}) (spatialmath.Pose , error ) {
43
45
extraOptions = extra
@@ -52,12 +54,22 @@ func TestClient(t *testing.T) {
52
54
extraOptions = extra
53
55
return nil
54
56
}
55
-
56
57
injectArm .MoveToJointPositionsFunc = func (ctx context.Context , jp []referenceframe.Input , extra map [string ]interface {}) error {
57
58
capArmJointPos = jp
58
59
extraOptions = extra
59
60
return nil
60
61
}
62
+ injectArm .MoveThroughJointPositionsFunc = func (
63
+ ctx context.Context ,
64
+ positions [][]referenceframe.Input ,
65
+ options * arm.MoveOptions ,
66
+ extra map [string ]interface {},
67
+ ) error {
68
+ capArmJointPos = positions [len (positions )- 1 ]
69
+ moveOptions = * options
70
+ extraOptions = extra
71
+ return nil
72
+ }
61
73
injectArm .StopFunc = func (ctx context.Context , extra map [string ]interface {}) error {
62
74
extraOptions = extra
63
75
return errStopUnimplemented
@@ -82,7 +94,6 @@ func TestClient(t *testing.T) {
82
94
capArmPos = ap
83
95
return nil
84
96
}
85
-
86
97
injectArm2 .MoveToJointPositionsFunc = func (ctx context.Context , jp []referenceframe.Input , extra map [string ]interface {}) error {
87
98
capArmJointPos = jp
88
99
return nil
@@ -94,11 +105,10 @@ func TestClient(t *testing.T) {
94
105
return nil
95
106
}
96
107
97
- armSvc , err := resource .NewAPIResourceCollection (
98
- arm .API , map [resource.Name ]arm.Arm {
99
- arm .Named (testArmName ): injectArm ,
100
- arm .Named (testArmName2 ): injectArm2 ,
101
- })
108
+ armSvc , err := resource .NewAPIResourceCollection (arm .API , map [resource.Name ]arm.Arm {
109
+ arm .Named (testArmName ): injectArm ,
110
+ arm .Named (testArmName2 ): injectArm2 ,
111
+ })
102
112
test .That (t , err , test .ShouldBeNil )
103
113
resourceAPI , ok , err := resource.LookupAPIRegistration [arm.Arm ](arm .API )
104
114
test .That (t , err , test .ShouldBeNil )
@@ -164,6 +174,17 @@ func TestClient(t *testing.T) {
164
174
test .That (t , capArmJointPos , test .ShouldResemble , jointPos2 )
165
175
test .That (t , extraOptions , test .ShouldResemble , map [string ]interface {}{"foo" : "MoveToJointPositions" })
166
176
177
+ err = arm1Client .MoveThroughJointPositions (
178
+ context .Background (),
179
+ [][]referenceframe.Input {jointPos2 , jointPos1 },
180
+ & expectedMoveOptions ,
181
+ map [string ]interface {}{"foo" : "MoveThroughJointPositions" },
182
+ )
183
+ test .That (t , err , test .ShouldBeNil )
184
+ test .That (t , capArmJointPos , test .ShouldResemble , jointPos1 )
185
+ test .That (t , moveOptions , test .ShouldResemble , expectedMoveOptions )
186
+ test .That (t , extraOptions , test .ShouldResemble , map [string ]interface {}{"foo" : "MoveThroughJointPositions" })
187
+
167
188
err = arm1Client .Stop (context .Background (), map [string ]interface {}{"foo" : "Stop" })
168
189
test .That (t , err , test .ShouldNotBeNil )
169
190
test .That (t , err .Error (), test .ShouldContainSubstring , errStopUnimplemented .Error ())
0 commit comments