# Base API

The base API allows you to give commands to your [base components](https://docs.viam.com/reference/components/base/) for moving all configured components attached to a platform as a whole without needing to send commands to individual components.

The base component supports the following methods:

| Method Name | Description | `viam-micro-server` Support |
| --- | --- | --- |
| [`MoveStraight`](https://docs.viam.com/reference/apis/components/base/#movestraight) | Move the base in a straight line across the given distance (mm) at the given velocity (mm/sec). |  |
| [`Spin`](https://docs.viam.com/reference/apis/components/base/#spin) | Turn the base in place, rotating it to the given angle (degrees) at the given angular velocity (degrees/sec). |  |
| [`SetPower`](https://docs.viam.com/reference/apis/components/base/#setpower) | Set the linear and angular power of the base, represented as a percentage of max power for each direction in the range of \[-1.0 to 1.0\]. |  |
| [`SetVelocity`](https://docs.viam.com/reference/apis/components/base/#setvelocity) | Set the linear velocity (mm/sec) and angular velocity (degrees/sec) of the base. |  |
| [`GetProperties`](https://docs.viam.com/reference/apis/components/base/#getproperties) | Get the width and turning radius of the model of base in meters. |  |
| [`IsMoving`](https://docs.viam.com/reference/apis/components/base/#ismoving) | Returns whether the base is actively moving (or attempting to move) under its own power. |  |
| [`Stop`](https://docs.viam.com/reference/apis/components/base/#stop) | Stop the base from moving immediately. |  |
| [`GetGeometries`](https://docs.viam.com/reference/apis/components/base/#getgeometries) | Get all the geometries associated with the base in its current configuration, in the frame of the base. |  |
| [`Reconfigure`](https://docs.viam.com/reference/apis/components/base/#reconfigure) | Reconfigure this resource. |  |
| [`DoCommand`](https://docs.viam.com/reference/apis/components/base/#docommand) | Execute model-specific commands that are not otherwise defined by the component API. |  |
| [`GetResourceName`](https://docs.viam.com/reference/apis/components/base/#getresourcename) | Get the `ResourceName` for this base. |  |
| [`Close`](https://docs.viam.com/reference/apis/components/base/#close) | Safely shut down the resource and prevent further use. |  |

## API

### MoveStraight

Move the base in a straight line across the given distance (mm) at the given velocity (mm/sec).

**Parameters:**

- `distance` ( [int](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (required): The distance (in millimeters) to move. Negative implies backwards.
- `velocity` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (required): The velocity (in millimeters per second) to move. Negative implies backwards.
- `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:**

- None.

### Spin

Turn the base in place, rotating it to the given angle (degrees) at the given angular velocity (degrees/sec).

**Parameters:**

- `angle` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (required): The angle (in degrees) to spin.
- `velocity` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (required): The angular velocity (in degrees per second) to spin. Given a positive angle and a positive velocity, the base will turn to the left.
- `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:**

- None.

### SetPower

Set the linear and angular power of the base, represented as a percentage of max power for each direction in the range of \[-1.0 to 1.0\].

**Parameters:**

- `linear` ( [viam.components.base.Vector3](https://python.viam.dev/autoapi/viam/components/base/index.html#viam.components.base.Vector3)) (required): The linear component. Only the Y component is used for wheeled base. Positive implies forwards.
- `angular` ( [viam.components.base.Vector3](https://python.viam.dev/autoapi/viam/components/base/index.html#viam.components.base.Vector3)) (required): The angular component. Only the Z component is used for wheeled base. Positive turns left; negative turns right.
- `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:**

- None.

### SetVelocity

Set the linear velocity (mm/sec) and angular velocity (degrees/sec) of the base.

**Parameters:**

- `linear` ( [viam.components.base.Vector3](https://python.viam.dev/autoapi/viam/components/base/index.html#viam.components.base.Vector3)) (required): Velocity in mm/sec.
- `angular` ( [viam.components.base.Vector3](https://python.viam.dev/autoapi/viam/components/base/index.html#viam.components.base.Vector3)) (required): Velocity in deg/sec.
- `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:**

- None.

### GetProperties

Get the width and turning radius of the model of base in meters.

**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.base.Base.Properties](https://python.viam.dev/autoapi/viam/components/base/index.html#viam.components.base.Base.Properties)): : The properties of the base.

### IsMoving

Returns whether the base is actively moving (or attempting to move) under its own power.

**Parameters:**

- `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:**

- ( [bool](https://docs.python.org/3/library/stdtypes.html#boolean-type-bool)): : Whether the base is moving.

### Stop

Stop the base from moving immediately.

**Parameters:**

**Returns:**

- None.

### GetGeometries

Get all the geometries associated with the base in its current configuration, in the [frame](https://docs.viam.com/reference/services/frame-system/) of the base.

**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.

### Reconfigure

Reconfigure this resource.

**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.

### DoCommand

Execute model-specific commands that are not otherwise defined by the component API.

**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.

### GetResourceName

Get the `ResourceName` for this base.

**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.

### Close

Safely shut down the resource and prevent further use.

**Parameters:**

- None.

**Returns:**

- None.
