# Movement sensor API

The movement sensor API allows you to give commands to your [movement sensor components](https://docs.viam.com/reference/components/movement-sensor/) for getting a GPS location, linear velocity and acceleration, angular velocity and acceleration, and heading.

Different movement sensors provide different data, so be aware that not all of the methods below are supported by all movement sensors.

#### Tip
You can run `GetProperties` on your sensor for a list of its supported methods.

| Method Name | Description | Models That Support This Method | `viam-micro-server` Support |
| --- | --- | --- | --- |
| [`GetPosition`](https://docs.viam.com/reference/apis/components/movement-sensor/#getposition) | Get the current latitude, longitude, and altitude. | GPS models, `wheeled-odometry` |  |
| [`GetLinearVelocity`](https://docs.viam.com/reference/apis/components/movement-sensor/#getlinearvelocity) | Get the current linear velocity as a 3D vector. | GPS models, `wheeled-odometry` |  |
| [`GetAngularVelocity`](https://docs.viam.com/reference/apis/components/movement-sensor/#getangularvelocity) | Get the current angular velocity as a 3D vector. | IMU models, `gyro-mpu6050`, and `wheeled-odometry` |  |
| [`GetLinearAcceleration`](https://docs.viam.com/reference/apis/components/movement-sensor/#getlinearacceleration) | Get the current linear acceleration as a 3D vector. | IMU models, `accel-adxl345`, and `gyro-mpu6050` |  |
| [`GetCompassHeading`](https://docs.viam.com/reference/apis/components/movement-sensor/#getcompassheading) | Get the current compass heading in degrees. | GPS models |  |
| [`GetOrientation`](https://docs.viam.com/reference/apis/components/movement-sensor/#getorientation) | Get the current orientation. | IMU models, `wheeled-odometry` |  |
| [`GetProperties`](https://docs.viam.com/reference/apis/components/movement-sensor/#getproperties) | Get the supported properties of this sensor. | all models |  |
| [`GetAccuracy`](https://docs.viam.com/reference/apis/components/movement-sensor/#getaccuracy) | Get the accuracy of the various sensors. | GPS models |  |
| [`GetReadings`](https://docs.viam.com/reference/apis/components/movement-sensor/#getreadings) | Obtain the measurements/data specific to this sensor. | all models |  |
| [`DoCommand`](https://docs.viam.com/reference/apis/components/movement-sensor/#docommand) | Send or receive model-specific commands. | all models |  |
| [`Close`](https://docs.viam.com/reference/apis/components/movement-sensor/#close) | Safely shut down the resource and prevent further use. | all models |  |

## API

### GetLinearVelocity

Report the current linear velocity in the x, y, and z directions (as a 3D vector) in meters per second.

Supported by GPS models.
Supported by `viam-micro-server`.

- [Python](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-1-0)
- [Go](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-1-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-1-2)
- [Flutter](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-1-3)

**Parameters:**

- `extra` (Mapping[ [str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), Any]) (optional): Extra options to pass to the underlying RPC call.
- `timeout` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.

**Returns:**

- ( [viam.components.movement_sensor.Vector3](https://python.viam.dev/autoapi/viam/components/movement_sensor/index.html#viam.components.movement_sensor.Vector3)): : The linear velocity in m/sec.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/movement_sensor/client/index.html#viam.components.movement_sensor.client.MovementSensorClient.get_linear_velocity).

### GetAngularVelocity

Report the current angular velocity about the x, y, and z axes (as a 3D vector) in degrees per second.

Supported by IMU models and by `gyro-mpu6050`.
Supported by `viam-micro-server`.

- [Python](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-2-0)
- [Go](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-2-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-2-2)
- [Flutter](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-2-3)

**Parameters:**

**Returns:**

- ( [viam.components.movement_sensor.Vector3](https://python.viam.dev/autoapi/viam/components/movement_sensor/index.html#viam.components.movement_sensor.Vector3)): : The angular velocity in degrees/sec.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/movement_sensor/client/index.html#viam.components.movement_sensor.client.MovementSensorClient.get_angular_velocity).

### GetCompassHeading

Report the current [compass heading](https://en.wikipedia.org/wiki/Heading_%28navigation%29) in degrees.

Supported by GPS models.
Supported by `viam-micro-server`.

- [Python](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-3-0)
- [Go](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-3-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-3-2)
- [Flutter](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-3-3)

**Parameters:**

**Returns:**

- ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)): : The compass heading in degrees.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/movement_sensor/client/index.html#viam.components.movement_sensor.client.MovementSensorClient.get_compass_heading).

### GetOrientation

Report the current orientation of the sensor.

Supported by IMU models.

- [Python](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-4-0)
- [Go](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-4-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-4-2)
- [Flutter](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-4-3)

**Parameters:**

**Returns:**

- ( [viam.components.movement_sensor.Orientation](https://python.viam.dev/autoapi/viam/components/movement_sensor/index.html#viam.components.movement_sensor.Orientation)): : The orientation.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/movement_sensor/client/index.html#viam.components.movement_sensor.client.MovementSensorClient.get_orientation).

### GetPosition

Report the current GeoPoint (latitude, longitude) and altitude (in meters).

Supported by GPS models.
Supported by `viam-micro-server`.

- [Python](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-5-0)
- [Go](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-5-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-5-2)
- [Flutter](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-5-3)

**Parameters:**

**Returns:**

- (Tuple[viam.components.movement_sensor.GeoPoint, [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)]): : The current lat/long, along with the altitude in m.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/movement_sensor/client/index.html#viam.components.movement_sensor.client.MovementSensorClient.get_position).

### GetProperties

Get the supported properties of this sensor.
Supported by `viam-micro-server`.

- [Python](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-6-0)
- [Go](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-6-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-6-2)
- [Flutter](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-6-3)

**Parameters:**

**Returns:**

- ( [viam.components.movement_sensor.movement_sensor.MovementSensor.Properties](https://python.viam.dev/autoapi/viam/components/movement_sensor/movement_sensor/index.html#viam.components.movement_sensor.movement_sensor.MovementSensor.Properties)): : The properties.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/movement_sensor/client/index.html#viam.components.movement_sensor.client.MovementSensorClient.get_properties).

### GetAccuracy

Get the reliability metrics of the movement sensor, including various parameters to assess the sensor’s accuracy and precision in different dimensions.

Supported by GPS models and `imu-wit`.

- [Python](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-7-0)
- [Go](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-7-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-7-2)
- [Flutter](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-7-3)

**Parameters:**

**Returns:**

- ( [MovementSensor.Accuracy](https://python.viam.dev/autoapi/viam/components/movement_sensor/movement_sensor/index.html#viam.components.movement_sensor.movement_sensor.MovementSensor.Accuracy)): : The accuracies of the movement sensor.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/movement_sensor/client/index.html#viam.components.movement_sensor.client.MovementSensorClient.get_accuracy).

### GetLinearAcceleration

Report the current linear acceleration in the x, y, and z directions (as a 3D vector) in meters per second per second.

Supported by IMU models, `accel-adxl345`, and `gyro-mpu6050`.
Supported by `viam-micro-server`.

- [Python](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-8-0)
- [Go](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-8-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-8-2)
- [Flutter](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-8-3)

**Parameters:**

**Returns:**

- ( [viam.components.movement_sensor.Vector3](https://python.viam.dev/autoapi/viam/components/movement_sensor/index.html#viam.components.movement_sensor.Vector3)): : The linear acceleration in m/sec^2.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/movement_sensor/client/index.html#viam.components.movement_sensor.client.MovementSensorClient.get_linear_acceleration).

### GetGeometries

Get all the geometries associated with the movement sensor in its current configuration, in the [frame](https://docs.viam.com/reference/services/frame-system/) of the movement sensor. The [motion](https://docs.viam.com/reference/services/motion/) and [navigation](https://docs.viam.com/reference/services/navigation/) services use the relative position of inherent geometries to configured geometries representing obstacles for collision detection and obstacle avoidance while motion planning.

- [Python](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-9-0)

**Parameters:**

**Returns:**

- ( [List[viam.proto.common.Geometry]](https://python.viam.dev/autoapi/viam/proto/common/index.html#viam.proto.common.Geometry)): : The geometries associated with the Component.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/movement_sensor/client/index.html#viam.components.movement_sensor.client.MovementSensorClient.get_geometries).

### GetReadings

Get all the measurements/data from the sensor. Results depend on the sensor model and can be of any type. If a sensor is not configured to take a certain measurement or fails to read a piece of data, that data will not appear in the readings dictionary. Supported by `viam-micro-server`.

- [Python](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-10-0)
- [Go](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-10-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-10-2)
- [Flutter](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-10-3)

**Parameters:**

**Returns:**

- (Mapping[ [str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), viam.utils.SensorReading]): : The readings for the MovementSensor. Can be of any type.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/movement_sensor/client/index.html#viam.components.movement_sensor.client.MovementSensorClient.get_readings).

### Reconfigure

Reconfigure this resource. Reconfigure must reconfigure the resource atomically and in place.

- [Go](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-11-0)

**Parameters:**

- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
- `deps` [(Dependencies)](https://pkg.go.dev/go.viam.com/rdk/resource#Dependencies): The resource dependencies.
- `conf` [(Config)](https://pkg.go.dev/go.viam.com/rdk/resource#Config): The resource configuration.

**Returns:**

- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.

For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/resource#Resource).

### DoCommand

Execute model-specific commands that are not otherwise defined by the component API. Most models do not implement `DoCommand`. Any available model-specific commands should be covered in the model’s documentation. If you are implementing your own movement sensor and want to add features that have no corresponding built-in API method, you can implement them with [`DoCommand`](https://docs.viam.com/reference/sdks/docommand/). Supported by `viam-micro-server`.

- [Python](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-12-0)
- [Go](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-12-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-12-2)
- [Flutter](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-12-3)

**Parameters:**

- `command` (Mapping[ [str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), ValueTypes]) (required): The command to execute.
- `timeout` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.

**Returns:**

- (Mapping[ [str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), viam.utils.ValueTypes]): : Result of the executed command.

**Raises:**

- (NotImplementedError): Raised if the Resource does not support arbitrary commands.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/movement_sensor/client/index.html#viam.components.movement_sensor.client.MovementSensorClient.do_command).

### GetResourceName

Get the `ResourceName` for this movement sensor.

- [Python](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-13-0)
- [Go](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-13-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-13-2)
- [Flutter](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-13-3)

**Parameters:**

- `name` ( [str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)) (required): The name of the Resource.

**Returns:**

- ( [viam.proto.common.ResourceName](https://python.viam.dev/autoapi/viam/proto/common/index.html#viam.proto.common.ResourceName)): : The ResourceName of this Resource.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/movement_sensor/client/index.html#viam.components.movement_sensor.client.MovementSensorClient.get_resource_name).

### Close

Safely shut down the resource and prevent further use.

- [Python](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-14-0)
- [Go](https://docs.viam.com/reference/apis/components/movement-sensor/#tabset-referenceapiscomponentsmovement-sensor-14-1)

**Parameters:**

- None.

**Returns:**

- None.

**Example:**

```python

```
