Skip to content

Commit 0a08c12

Browse files
committed
add customizability to fake gantry and standardize default gantry model
1 parent 55b799b commit 0a08c12

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

components/gantry/fake/gantry.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ func makeGantryModel(cfg resource.Config, newConf *Config) (referenceframe.Model
4242
case modelPath != "":
4343
model, err = referenceframe.KinematicModelFromFile(modelPath, cfg.Name)
4444
default:
45-
// if no arm model is specified, we return a fake arm with 1 dof and 0 spatial transformation
45+
// if no gantry model is specified, we return a default one.
4646
model, err = referenceframe.UnmarshalModelJSON(gantryModelJSON, cfg.Name)
4747
}
48+
49+
if (len(model.DoF()) != 1) {
50+
return nil, fmt.Errorf("gantry model must have exactly one degree of freedom, got %d", len(model.DoF()))
51+
}
52+
4853
return model, err
4954
}
5055

@@ -80,9 +85,9 @@ func NewGantry(conf resource.Config, logger logging.Logger) (gantry.Gantry, erro
8085
testutils.NewUnimplementedResource(conf.ResourceName()),
8186
resource.TriviallyReconfigurable{},
8287
resource.TriviallyCloseable{},
83-
[]float64{120},
88+
[]float64{m.DoF()[0].Max / 2},
8489
[]float64{50},
85-
[]float64{350},
90+
[]float64{m.DoF()[0].Max},
8691
m,
8792
logger,
8893
}, nil

components/gantry/fake/test_gantry_model.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"id": "base",
77
"parent": "world",
88
"translation": {
9-
"x": 0,
9+
"x": -50,
1010
"y": 0,
1111
"z": 0
1212
}
@@ -20,11 +20,11 @@
2020
"z": 0
2121
},
2222
"geometry": {
23-
"x": 150,
24-
"y": 120,
23+
"x": 50,
24+
"y": 50,
2525
"z": 10,
2626
"translation": {
27-
"x": -475,
27+
"x": 0,
2828
"y": 0,
2929
"z": 5
3030
}
@@ -41,7 +41,7 @@
4141
"y": 0,
4242
"z": 0
4343
},
44-
"max": 500,
44+
"max": 100,
4545
"min": 0
4646
}
4747
]

components/gantry/server_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func TestServer(t *testing.T) {
254254
t.Run("geometries", func(t *testing.T) {
255255
// geometries only works for single axis (multi-axis is a controller of multiple single-axis gantries)
256256
injectGantry.PositionFunc = func(ctx context.Context, extra map[string]interface{}) ([]float64, error) {
257-
return []float64{1.0}, nil
257+
return []float64{51.0}, nil
258258
}
259259
geometries, err := gantryServer.GetGeometries(context.Background(), &commonpb.GetGeometriesRequest{Name: testGantryName})
260260
test.That(t, err, test.ShouldBeNil)
@@ -266,7 +266,7 @@ func TestServer(t *testing.T) {
266266
&commonpb.Pose{
267267
X: 1.0,
268268
Y: 0.0,
269-
Z: 0.0,
269+
Z: 5.0,
270270
OX: 0.0,
271271
OY: 0.0,
272272
OZ: 1.0,

referenceframe/testfiles/example_gantry.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"id": "base",
77
"parent": "world",
88
"translation": {
9-
"x": 0,
9+
"x": -50,
1010
"y": 0,
1111
"z": 0
1212
}
@@ -20,13 +20,13 @@
2020
"z": 0
2121
},
2222
"geometry": {
23-
"x": 150,
24-
"y": 120,
23+
"x": 50,
24+
"y": 50,
2525
"z": 10,
2626
"translation": {
2727
"x": 0,
2828
"y": 0,
29-
"z": 0
29+
"z": 5
3030
}
3131
}
3232
}
@@ -41,7 +41,7 @@
4141
"y": 0,
4242
"z": 0
4343
},
44-
"max": 500,
44+
"max": 100,
4545
"min": 0
4646
}
4747
]

services/motion/builtin/builtin_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,14 @@ func TestGetPose(t *testing.T) {
193193
pose, err := ms.GetPose(context.Background(), "gantry1", "", nil, map[string]interface{}{})
194194
test.That(t, err, test.ShouldBeNil)
195195
test.That(t, pose.Parent(), test.ShouldEqual, referenceframe.World)
196-
test.That(t, pose.Pose().Point().X, test.ShouldAlmostEqual, 120)
196+
test.That(t, pose.Pose().Point().X, test.ShouldAlmostEqual, 0)
197197
test.That(t, pose.Pose().Point().Y, test.ShouldAlmostEqual, 0)
198198
test.That(t, pose.Pose().Point().Z, test.ShouldAlmostEqual, 0)
199199

200200
pose, err = ms.GetPose(context.Background(), "arm1", "", nil, map[string]interface{}{})
201201
test.That(t, err, test.ShouldBeNil)
202202
test.That(t, pose.Parent(), test.ShouldEqual, referenceframe.World)
203-
test.That(t, pose.Pose().Point().X, test.ShouldAlmostEqual, 620)
203+
test.That(t, pose.Pose().Point().X, test.ShouldAlmostEqual, 500)
204204
test.That(t, pose.Pose().Point().Y, test.ShouldAlmostEqual, 0)
205205
test.That(t, pose.Pose().Point().Z, test.ShouldAlmostEqual, 300)
206206

@@ -233,7 +233,7 @@ func TestGetPose(t *testing.T) {
233233

234234
pose, err = ms.GetPose(context.Background(), "arm1", "testFrame2", transforms, map[string]interface{}{})
235235
test.That(t, err, test.ShouldBeNil)
236-
test.That(t, pose.Pose().Point().X, test.ShouldAlmostEqual, -620)
236+
test.That(t, pose.Pose().Point().X, test.ShouldAlmostEqual, -500)
237237
test.That(t, pose.Pose().Point().Y, test.ShouldAlmostEqual, 0)
238238
test.That(t, pose.Pose().Point().Z, test.ShouldAlmostEqual, -300)
239239
test.That(t, pose.Pose().Orientation().AxisAngles().RX, test.ShouldEqual, 0)

0 commit comments

Comments
 (0)