MotionConfiguration reference

MotionConfiguration is an optional message you pass to the motion service’s MoveOnGlobe and MoveOnMap calls to override defaults for a single execution. It is not used with Move, which is synchronous and does not expose per-call motion parameters.

The navigation service uses MoveOnGlobe internally and builds a MotionConfiguration from its own attributes; see Navigation service correspondence below for the mapping.

Fields

FieldTypeDefaultDescription
obstacle_detectors[]ObstacleDetectoremptyPairs of vision_service and camera that the motion service polls for transient obstacles during execution.
position_polling_frequency_hzdouble (optional)unset (implementation default)How often the service polls the movement sensor (or SLAM service) for the current position. Higher values detect deviation sooner but use more CPU.
obstacle_polling_frequency_hzdouble (optional)unset (implementation default)How often each obstacle detector is queried for transient obstacles. Higher values detect obstacles sooner but use more CPU and camera bandwidth.
plan_deviation_mdouble (optional)2.6 m (MoveOnGlobe), 1.0 m (MoveOnMap)Distance in meters the robot may deviate from the current plan before the service triggers a replan. Set larger than your movement sensor’s accuracy.
linear_m_per_secdouble (optional)0.3 m/sTarget linear velocity when moving in a straight line.
angular_degs_per_secdouble (optional)60 deg/sTarget angular velocity when turning.

ObstacleDetector

Each entry pairs a vision service with a camera:

FieldTypeDescription
vision_servicestringName of the vision service that reports detected obstacles.
camerastringName of the camera whose images feed that vision service.

The motion service queries each detector at obstacle_polling_frequency_hz and feeds the reported geometry to the planner for the remainder of the current execution.

Units

plan_deviation_m is meters at the API boundary. The motion service stores the value internally as millimeters, and the Go SDK’s MotionConfiguration struct exposes that millimeter form as PlanDeviationMM.

Usage

from viam.proto.service.motion import MotionConfiguration, ObstacleDetector
from viam.proto.common import GeoPoint

configuration = MotionConfiguration(
    obstacle_detectors=[
        ObstacleDetector(vision_service="obstacles", camera="front-cam"),
    ],
    position_polling_frequency_hz=2.0,
    obstacle_polling_frequency_hz=2.0,
    plan_deviation_m=5.0,
    linear_m_per_sec=0.5,
    angular_degs_per_sec=30.0,
)

execution_id = await motion_service.move_on_globe(
    component_name="my-base",
    destination=GeoPoint(latitude=40.6640, longitude=-73.9387),
    movement_sensor_name="my-gps",
    configuration=configuration,
)
import (
    geo "github.com/kellydunn/golang-geo"
    "go.viam.com/rdk/services/motion"
)

positionHz := 2.0
obstacleHz := 2.0
configuration := &motion.MotionConfiguration{
    ObstacleDetectors: []motion.ObstacleDetectorName{
        {VisionServiceName: "obstacles", CameraName: "front-cam"},
    },
    PositionPollingFreqHz: &positionHz,
    ObstaclePollingFreqHz: &obstacleHz,
    PlanDeviationMM:       5000, // 5 meters, stored as mm internally
    LinearMPerSec:         0.5,
    AngularDegsPerSec:     30.0,
}

executionID, err := motionService.MoveOnGlobe(ctx, motion.MoveOnGlobeReq{
    ComponentName:      "my-base",
    Destination:        geo.NewPoint(40.6640, -73.9387),
    MovementSensorName: "my-gps",
    MotionCfg:          configuration,
})

Navigation service correspondence

When you configure the navigation service, it builds a MotionConfiguration from its attributes on every internal MoveOnGlobe call. The attributes map to MotionConfiguration fields as follows:

Navigation service attributeMotionConfiguration field
meters_per_seclinear_m_per_sec
degs_per_secangular_degs_per_sec
plan_deviation_mplan_deviation_m
position_polling_frequency_hzposition_polling_frequency_hz
obstacle_polling_frequency_hzobstacle_polling_frequency_hz
obstacle_detectors[]obstacle_detectors[]

The navigation service also has a replan_cost_factor attribute with no MotionConfiguration equivalent; it is a navigation-service-only tuning knob.

What’s next