Skip to content

Commit 61af083

Browse files
authored
APP-8776 Move geometry proto conversions to reference frame (#5149)
1 parent 75d3f33 commit 61af083

34 files changed

+566
-423
lines changed

components/arm/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func (c *client) Geometries(ctx context.Context, extra map[string]interface{}) (
218218
if err != nil {
219219
return nil, err
220220
}
221-
return spatialmath.NewGeometriesFromProto(resp.GetGeometries())
221+
return referenceframe.NewGeometriesFromProto(resp.GetGeometries())
222222
}
223223

224224
// warnKinematicsUnsafe is a helper function to warn the user that no kinematics have been supplied for the conversion between

components/arm/server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,12 @@ func (s *serviceServer) GetGeometries(ctx context.Context, req *commonpb.GetGeom
184184
if err != nil {
185185
return nil, err
186186
}
187-
return &commonpb.GetGeometriesResponse{Geometries: spatialmath.NewGeometriesToProto(gifs.Geometries())}, nil
187+
return &commonpb.GetGeometriesResponse{Geometries: referenceframe.NewGeometriesToProto(
188+
gifs.Geometries())}, nil
188189
}
189190
return nil, err
190191
}
191-
return &commonpb.GetGeometriesResponse{Geometries: spatialmath.NewGeometriesToProto(geometries)}, nil
192+
return &commonpb.GetGeometriesResponse{Geometries: referenceframe.NewGeometriesToProto(geometries)}, nil
192193
}
193194

194195
// GetKinematics returns the kinematics information associated with the arm.

components/base/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"go.viam.com/rdk/logging"
1515
rprotoutils "go.viam.com/rdk/protoutils"
16+
"go.viam.com/rdk/referenceframe"
1617
"go.viam.com/rdk/resource"
1718
"go.viam.com/rdk/spatialmath"
1819
)
@@ -162,5 +163,5 @@ func (c *client) Geometries(ctx context.Context, extra map[string]interface{}) (
162163
if err != nil {
163164
return nil, err
164165
}
165-
return spatialmath.NewGeometriesFromProto(resp.GetGeometries())
166+
return referenceframe.NewGeometriesFromProto(resp.GetGeometries())
166167
}

components/base/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010

1111
"go.viam.com/rdk/operation"
1212
"go.viam.com/rdk/protoutils"
13+
"go.viam.com/rdk/referenceframe"
1314
"go.viam.com/rdk/resource"
14-
"go.viam.com/rdk/spatialmath"
1515
)
1616

1717
// ErrGeometriesNil is the returned error if base geometries are nil.
@@ -171,7 +171,7 @@ func (s *serviceServer) GetGeometries(ctx context.Context, req *commonpb.GetGeom
171171
if geometries == nil {
172172
return nil, ErrGeometriesNil(req.GetName())
173173
}
174-
return &commonpb.GetGeometriesResponse{Geometries: spatialmath.NewGeometriesToProto(geometries)}, nil
174+
return &commonpb.GetGeometriesResponse{Geometries: referenceframe.NewGeometriesToProto(geometries)}, nil
175175
}
176176

177177
// DoCommand receives arbitrary commands.

components/base/server_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"go.viam.com/test"
1212

1313
"go.viam.com/rdk/components/base"
14+
"go.viam.com/rdk/referenceframe"
1415
"go.viam.com/rdk/resource"
1516
"go.viam.com/rdk/spatialmath"
1617
"go.viam.com/rdk/testutils/inject"
@@ -210,7 +211,7 @@ func TestServer(t *testing.T) {
210211
req := &pbcommon.GetGeometriesRequest{Name: testBaseName}
211212
resp, err := server.GetGeometries(context.Background(), req) // TODO (rh) rename server to bServer after review
212213
test.That(t, resp, test.ShouldResemble, &pbcommon.GetGeometriesResponse{
213-
Geometries: spatialmath.NewGeometriesToProto([]spatialmath.Geometry{box}),
214+
Geometries: referenceframe.NewGeometriesToProto([]spatialmath.Geometry{box}),
214215
})
215216
test.That(t, err, test.ShouldBeNil)
216217

components/camera/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"go.viam.com/rdk/logging"
3131
"go.viam.com/rdk/pointcloud"
3232
"go.viam.com/rdk/protoutils"
33+
"go.viam.com/rdk/referenceframe"
3334
"go.viam.com/rdk/resource"
3435
"go.viam.com/rdk/rimage/transform"
3536
"go.viam.com/rdk/spatialmath"
@@ -340,7 +341,7 @@ func (c *client) Geometries(ctx context.Context, extra map[string]interface{}) (
340341
if err != nil {
341342
return nil, err
342343
}
343-
return spatialmath.NewGeometriesFromProto(resp.GetGeometries())
344+
return referenceframe.NewGeometriesFromProto(resp.GetGeometries())
344345
}
345346

346347
// TODO(RSDK-6433): This method can be called more than once during a client's lifecycle.

components/camera/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
"go.viam.com/rdk/logging"
1515
"go.viam.com/rdk/pointcloud"
1616
"go.viam.com/rdk/protoutils"
17+
"go.viam.com/rdk/referenceframe"
1718
"go.viam.com/rdk/resource"
18-
"go.viam.com/rdk/spatialmath"
1919
"go.viam.com/rdk/utils"
2020
)
2121

@@ -256,5 +256,5 @@ func (s *serviceServer) GetGeometries(ctx context.Context, req *commonpb.GetGeom
256256
if err != nil {
257257
return nil, err
258258
}
259-
return &commonpb.GetGeometriesResponse{Geometries: spatialmath.NewGeometriesToProto(geometries)}, nil
259+
return &commonpb.GetGeometriesResponse{Geometries: referenceframe.NewGeometriesToProto(geometries)}, nil
260260
}

components/gripper/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (c *client) Geometries(ctx context.Context, extra map[string]interface{}) (
128128
if err != nil {
129129
return nil, err
130130
}
131-
return spatialmath.NewGeometriesFromProto(resp.GetGeometries())
131+
return referenceframe.NewGeometriesFromProto(resp.GetGeometries())
132132
}
133133

134134
func (c *client) Kinematics(ctx context.Context) (referenceframe.Model, error) {

components/gripper/server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
rprotoutils "go.viam.com/rdk/protoutils"
1414
"go.viam.com/rdk/referenceframe"
1515
"go.viam.com/rdk/resource"
16-
"go.viam.com/rdk/spatialmath"
1716
)
1817

1918
// ErrGeometriesNil is the returned error if gripper geometries are nil.
@@ -118,7 +117,7 @@ func (s *serviceServer) GetGeometries(ctx context.Context, req *commonpb.GetGeom
118117
if geometries == nil {
119118
return nil, ErrGeometriesNil(req.GetName())
120119
}
121-
return &commonpb.GetGeometriesResponse{Geometries: spatialmath.NewGeometriesToProto(geometries)}, nil
120+
return &commonpb.GetGeometriesResponse{Geometries: referenceframe.NewGeometriesToProto(geometries)}, nil
122121
}
123122

124123
func (s *serviceServer) GetKinematics(ctx context.Context, req *commonpb.GetKinematicsRequest) (*commonpb.GetKinematicsResponse, error) {

config/proto_conversions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ func FrameConfigFromProto(proto *pb.Frame) (*referenceframe.LinkConfig, error) {
519519
}
520520

521521
if proto.GetGeometry() != nil {
522-
geom, err := spatial.NewGeometryFromProto(proto.GetGeometry())
522+
geom, err := referenceframe.NewGeometryFromProto(proto.GetGeometry())
523523
if err != nil {
524524
return nil, err
525525
}

0 commit comments

Comments
 (0)