From 69523b784222911219987f6415e7809cfe94472e Mon Sep 17 00:00:00 2001 From: JessamyT Date: Mon, 21 Apr 2025 16:33:58 -0700 Subject: [PATCH 1/2] DOCS-3550: Add navigation service examples --- src/services/navigation/navigation.ts | 145 ++++++++++++++++++++++++-- 1 file changed, 136 insertions(+), 9 deletions(-) diff --git a/src/services/navigation/navigation.ts b/src/services/navigation/navigation.ts index d7c43836e..014629939 100644 --- a/src/services/navigation/navigation.ts +++ b/src/services/navigation/navigation.ts @@ -11,46 +11,173 @@ import type { /** * A service that uses GPS to automatically navigate a robot to user defined * endpoints. + * + * @example + * + * ```ts + * const navigation = new VIAM.NavigationClient(machine, 'my_navigation'); + * + * const mode = await navigation.getMode(); + * ``` + * + * For more information, see [Navigation + * API](https://docs.viam.com/dev/reference/apis/services/navigation/#getmode). */ export interface Navigation extends Resource { - /** Get the mode the robot is operating in. */ + /** Get the mode the robot is operating in. + * + * @example + * + * ```ts + * const navigation = new VIAM.NavigationClient(machine, 'my_navigation'); + * + * const mode = await navigation.getMode(); + * ``` + * + * For more information, see [Navigation + * API](https://docs.viam.com/dev/reference/apis/services/navigation/#getmode). + */ getMode: (extra?: Struct) => Promise; /** * Set the mode the robot is operating in. * + * @example + * + * ```ts + * const navigation = new VIAM.NavigationClient(machine, 'my_navigation'); + * + * // Set the mode to 2 which corresponds to WAYPOINT + * await navigation.setMode(2); + * ``` + * + * For more information, see [Navigation + * API](https://docs.viam.com/dev/reference/apis/services/navigation/#setmode). + * * @param mode - The mode for the service to operate in. + * - 0: MODE_UNSPECIFIED + * - 1: MODE_MANUAL + * - 2: MODE_WAYPOINT + * - 3: MODE_EXPLORE */ setMode: (mode: Mode, extra?: Struct) => Promise; - /** Get the current location of the robot. */ + /** Get the current location of the robot. + * + * @example + * + * ```ts + * const navigation = new VIAM.NavigationClient(machine, 'my_navigation'); + * + * const location = await navigation.getLocation(); + * ``` + * + * For more information, see [Navigation + * API](https://docs.viam.com/dev/reference/apis/services/navigation/#getlocation). + */ getLocation: (extra?: Struct) => Promise; - /** Get an array of waypoints currently in the service's data storage. */ + /** Get an array of waypoints currently in the service's data storage. + * + * @example + * + * ```ts + * const navigation = new VIAM.NavigationClient(machine, 'my_navigation'); + * + * const waypoints = await navigation.getWayPoints(); + * ``` + * + * For more information, see [Navigation + * API](https://docs.viam.com/dev/reference/apis/services/navigation/#getwaypoints). + */ getWayPoints: (extra?: Struct) => Promise; /** * Add a waypoint to the service's data storage. * - * @param location - The current location of the robot n the navigation - * service with latitude and longitude values. - */ + * @example + * + * ```ts + * const navigation = new VIAM.NavigationClient(machine, 'my_navigation'); + * + * const location = { latitude: 40.7128, longitude: -74.006 }; + * await navigation.addWayPoint(location); + * ``` + * + * For more information, see [Navigation + * API](https://docs.viam.com/dev/reference/apis/services/navigation/#addwaypoint). + * + * @param location - A waypoint described by latitude and longitude values. + * */ addWayPoint: (location: GeoPoint, extra?: Struct) => Promise; /** * Remove a waypoint from the service's data storage. * + * @example + * + * ```ts + * const navigation = new VIAM.NavigationClient(machine, 'my_navigation'); + * + * // Remove the first waypoint + * if (waypoints.length > 0) { + * await navigation.removeWayPoint(waypoints[0].id); + * } + * ``` + * + * For more information, see [Navigation + * API](https://docs.viam.com/dev/reference/apis/services/navigation/#removewaypoint). + * * @param id - The MongoDB ObjectID of the waypoint to remove from the * service's data storage. */ removeWayPoint: (id: string, extra?: Struct) => Promise; - /** Get a list of obstacles. */ + /** + * Get a list of obstacles. + * + * @example + * + * ```ts + * const navigation = new VIAM.NavigationClient(machine, 'my_navigation'); + * + * const obstacles = await navigation.getObstacles(); + * ``` + * + * For more information, see [Navigation + * API](https://docs.viam.com/dev/reference/apis/services/navigation/#getobstacles). + */ getObstacles: (extra?: Struct) => Promise; - /** Gets the list of paths known to the navigation service. */ + /** + * Gets the list of paths known to the navigation service. + * + * @example + * + * ```ts + * const navigation = new VIAM.NavigationClient(machine, 'my_navigation'); + * + * const paths = await navigation.getPaths(); + * ``` + * + * For more information, see [Navigation + * API](https://docs.viam.com/dev/reference/apis/services/navigation/#getpaths). + */ getPaths: (extra?: Struct) => Promise; - /** Gets information on the properties of the current navigation service. */ + /** + * Gets information on the properties of the current navigation service. + * + * @example + * + * ```ts + * const navigation = new VIAM.NavigationClient(machine, 'my_navigation'); + * + * const properties = await navigation.getProperties(); + * ``` + * + * For more information, see [Navigation + * API](https://docs.viam.com/dev/reference/apis/services/navigation/#getproperties). + */ getProperties: () => Promise; } From 5f6db9a7958799de99931f0bdb2e753e06552763 Mon Sep 17 00:00:00 2001 From: JessamyT Date: Tue, 22 Apr 2025 13:13:21 -0700 Subject: [PATCH 2/2] lint --- src/services/navigation/navigation.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/services/navigation/navigation.ts b/src/services/navigation/navigation.ts index 014629939..8257990d6 100644 --- a/src/services/navigation/navigation.ts +++ b/src/services/navigation/navigation.ts @@ -24,7 +24,8 @@ import type { * API](https://docs.viam.com/dev/reference/apis/services/navigation/#getmode). */ export interface Navigation extends Resource { - /** Get the mode the robot is operating in. + /** + * Get the mode the robot is operating in. * * @example * @@ -55,6 +56,7 @@ export interface Navigation extends Resource { * API](https://docs.viam.com/dev/reference/apis/services/navigation/#setmode). * * @param mode - The mode for the service to operate in. + * * - 0: MODE_UNSPECIFIED * - 1: MODE_MANUAL * - 2: MODE_WAYPOINT @@ -62,7 +64,8 @@ export interface Navigation extends Resource { */ setMode: (mode: Mode, extra?: Struct) => Promise; - /** Get the current location of the robot. + /** + * Get the current location of the robot. * * @example * @@ -77,7 +80,8 @@ export interface Navigation extends Resource { */ getLocation: (extra?: Struct) => Promise; - /** Get an array of waypoints currently in the service's data storage. + /** + * Get an array of waypoints currently in the service's data storage. * * @example * @@ -108,7 +112,7 @@ export interface Navigation extends Resource { * API](https://docs.viam.com/dev/reference/apis/services/navigation/#addwaypoint). * * @param location - A waypoint described by latitude and longitude values. - * */ + */ addWayPoint: (location: GeoPoint, extra?: Struct) => Promise; /**