Skip to content

Commit 66ae951

Browse files
authored
RSDK-6443 - Change RDK implementation of MoveOnMap to use MoveOnMapNew (viamrobotics#3479)
1 parent 85bc318 commit 66ae951

File tree

12 files changed

+544
-192
lines changed

12 files changed

+544
-192
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ require (
8383
go.uber.org/atomic v1.10.0
8484
go.uber.org/multierr v1.11.0
8585
go.uber.org/zap v1.24.0
86-
go.viam.com/api v0.1.253
86+
go.viam.com/api v0.1.255
8787
go.viam.com/test v1.1.1-0.20220913152726-5da9916c08a2
8888
go.viam.com/utils v0.1.59
8989
goji.io v2.0.2+incompatible

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1489,8 +1489,8 @@ go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
14891489
go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY=
14901490
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
14911491
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
1492-
go.viam.com/api v0.1.253 h1:lqTtDtwpBy2r2Z4TPaT2rb6msK6IAU/E2MTRdprjQno=
1493-
go.viam.com/api v0.1.253/go.mod h1:msa4TPrMVeRDcG4YzKA/S6wLEUC7GyHQE973JklrQ10=
1492+
go.viam.com/api v0.1.255 h1:ApxFMQaPug1oVZuw/07pKax2I2z8pzQJx+14ziFMzR4=
1493+
go.viam.com/api v0.1.255/go.mod h1:msa4TPrMVeRDcG4YzKA/S6wLEUC7GyHQE973JklrQ10=
14941494
go.viam.com/test v1.1.1-0.20220913152726-5da9916c08a2 h1:oBiK580EnEIzgFLU4lHOXmGAE3MxnVbeR7s1wp/F3Ps=
14951495
go.viam.com/test v1.1.1-0.20220913152726-5da9916c08a2/go.mod h1:XM0tej6riszsiNLT16uoyq1YjuYPWlRBweTPRDanIts=
14961496
go.viam.com/utils v0.1.59 h1:h6x9aFlX00DIS3x1DWwonG5XICIgIE5m4R3RDGObXuw=

services/motion/builtin/builtin.go

+10-33
Original file line numberDiff line numberDiff line change
@@ -240,46 +240,23 @@ func (ms *builtIn) Move(
240240
return true, nil
241241
}
242242

243-
// MoveOnMap will move the given component to the given destination on the slam map generated from a slam service specified by slamName.
244-
// Bases are the only component that supports this.
245-
func (ms *builtIn) MoveOnMap(
246-
ctx context.Context,
247-
componentName resource.Name,
248-
destination spatialmath.Pose,
249-
slamName resource.Name,
250-
extra map[string]interface{},
251-
) (bool, error) {
243+
func (ms *builtIn) MoveOnMap(ctx context.Context, req motion.MoveOnMapReq) (motion.ExecutionID, error) {
244+
if err := ctx.Err(); err != nil {
245+
return uuid.Nil, err
246+
}
252247
ms.mu.RLock()
253248
defer ms.mu.RUnlock()
249+
ms.logger.CDebugf(ctx, "MoveOnMap called with %s", req)
250+
251+
// TODO: Deprecated: remove once no motion apis use the opid system
254252
operation.CancelOtherWithLabel(ctx, builtinOpLabel)
255-
// make call to motionplan
256-
mr, err := ms.newMoveOnMapRequest(ctx, motion.MoveOnMapReq{
257-
ComponentName: componentName,
258-
Destination: destination,
259-
SlamName: slamName,
260-
Extra: extra,
261-
}, nil, defaultMaxReplans)
262-
if err != nil {
263-
return false, fmt.Errorf("error making plan for MoveOnMap: %w", err)
264-
}
265253

266-
planResp, err := mr.Plan(ctx)
267-
if err != nil {
268-
return false, err
269-
}
270-
resp, err := mr.Execute(ctx, planResp.Waypoints)
271-
// Error
254+
id, err := state.StartExecution(ctx, ms.state, req.ComponentName, req, ms.newMoveOnMapRequest)
272255
if err != nil {
273-
return false, err
256+
return uuid.Nil, err
274257
}
275258

276-
// Didn't reach goal
277-
if resp.Replan {
278-
ms.logger.CWarnf(ctx, "didn't reach the goal. Reason: %s\n", resp.ReplanReason)
279-
return false, nil
280-
}
281-
// Reached goal
282-
return true, nil
259+
return id, nil
283260
}
284261

285262
func (ms *builtIn) MoveOnMapNew(ctx context.Context, req motion.MoveOnMapReq) (motion.ExecutionID, error) {

0 commit comments

Comments
 (0)