Motion Service

The motion service enables your machine to plan and move itself or its components relative to itself, other machines, and the world. The motion service:

  1. Gathers the current positions of the machine’s components as defined with the frame system.
  2. Plans the necessary motions to move a component to a given destination while obeying any constraints you configure.

The motion service can:

  • use motion planning algorithms locally on your machine to plan coordinated motion across many components.
  • pass movement requests through to individual components which have implemented their own motion planning.

Configuration

You need to configure frames for your machine’s components with the frame system. This defines the spatial context within which the motion service operates.

The motion service itself is enabled on the machine by default, so you do not need to do any extra configuration in the Viam app to enable it.

API

The motion service API supports the following methods:

Method NameDescription
MoveThe Move method is the primary way to move multiple components, or to move any object to any other location.
MoveOnMapMove a base component to a destination pose on a SLAM map.
MoveOnGlobeMove a base component to a destination GPS point, represented in geographic notation (latitude, longitude).
GetPoseGetPose gets the location and orientation of a component within the frame system.
StopPlanStop a base component being moved by an in progress MoveOnGlobe or MoveOnMap call.
ListPlanStatusesReturns the statuses of plans created by MoveOnGlobe or MoveOnMap calls that meet at least one of the following conditions since the motion service initialized: - the plan’s status is in progress - the plan’s status changed state within the last 24 hours All repeated fields are in chronological order.
GetPlanBy default, returns the plan history of the most recent MoveOnGlobe or MoveOnMap call to move a base component.
ReconfigureReconfigure this resource.
FromRobotGet the resource from the provided robot with the given name.
DoCommandExecute model-specific commands that are not otherwise defined by the service API.
GetResourceNameGet the ResourceName for this instance of the motion service with the given name.
CloseSafely shut down the resource and prevent further use.

Test the motion service

You can test motion on your machine from the CONTROL tab.

Motion card on the Control tab

Enter x and y coordinates to move your machine to, then click the Move button to issue a MoveOnMap() request.

Next steps

The following tutorials contain complete example code for interacting with a robot arm through the arm component API, and with the motion service API, respectively: