Skip to content

Commit 352b62a

Browse files
authored
DOCS-3550: Add navigation service examples (#550)
1 parent ee780c4 commit 352b62a

File tree

1 file changed

+139
-8
lines changed

1 file changed

+139
-8
lines changed

src/services/navigation/navigation.ts

Lines changed: 139 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,177 @@ import type {
1111
/**
1212
* A service that uses GPS to automatically navigate a robot to user defined
1313
* endpoints.
14+
*
15+
* @example
16+
*
17+
* ```ts
18+
* const navigation = new VIAM.NavigationClient(machine, 'my_navigation');
19+
*
20+
* const mode = await navigation.getMode();
21+
* ```
22+
*
23+
* For more information, see [Navigation
24+
* API](https://docs.viam.com/dev/reference/apis/services/navigation/#getmode).
1425
*/
1526
export interface Navigation extends Resource {
16-
/** Get the mode the robot is operating in. */
27+
/**
28+
* Get the mode the robot is operating in.
29+
*
30+
* @example
31+
*
32+
* ```ts
33+
* const navigation = new VIAM.NavigationClient(machine, 'my_navigation');
34+
*
35+
* const mode = await navigation.getMode();
36+
* ```
37+
*
38+
* For more information, see [Navigation
39+
* API](https://docs.viam.com/dev/reference/apis/services/navigation/#getmode).
40+
*/
1741
getMode: (extra?: Struct) => Promise<Mode>;
1842

1943
/**
2044
* Set the mode the robot is operating in.
2145
*
46+
* @example
47+
*
48+
* ```ts
49+
* const navigation = new VIAM.NavigationClient(machine, 'my_navigation');
50+
*
51+
* // Set the mode to 2 which corresponds to WAYPOINT
52+
* await navigation.setMode(2);
53+
* ```
54+
*
55+
* For more information, see [Navigation
56+
* API](https://docs.viam.com/dev/reference/apis/services/navigation/#setmode).
57+
*
2258
* @param mode - The mode for the service to operate in.
59+
*
60+
* - 0: MODE_UNSPECIFIED
61+
* - 1: MODE_MANUAL
62+
* - 2: MODE_WAYPOINT
63+
* - 3: MODE_EXPLORE
2364
*/
2465
setMode: (mode: Mode, extra?: Struct) => Promise<void>;
2566

26-
/** Get the current location of the robot. */
67+
/**
68+
* Get the current location of the robot.
69+
*
70+
* @example
71+
*
72+
* ```ts
73+
* const navigation = new VIAM.NavigationClient(machine, 'my_navigation');
74+
*
75+
* const location = await navigation.getLocation();
76+
* ```
77+
*
78+
* For more information, see [Navigation
79+
* API](https://docs.viam.com/dev/reference/apis/services/navigation/#getlocation).
80+
*/
2781
getLocation: (extra?: Struct) => Promise<NavigationPosition>;
2882

29-
/** Get an array of waypoints currently in the service's data storage. */
83+
/**
84+
* Get an array of waypoints currently in the service's data storage.
85+
*
86+
* @example
87+
*
88+
* ```ts
89+
* const navigation = new VIAM.NavigationClient(machine, 'my_navigation');
90+
*
91+
* const waypoints = await navigation.getWayPoints();
92+
* ```
93+
*
94+
* For more information, see [Navigation
95+
* API](https://docs.viam.com/dev/reference/apis/services/navigation/#getwaypoints).
96+
*/
3097
getWayPoints: (extra?: Struct) => Promise<Waypoint[]>;
3198

3299
/**
33100
* Add a waypoint to the service's data storage.
34101
*
35-
* @param location - The current location of the robot n the navigation
36-
* service with latitude and longitude values.
102+
* @example
103+
*
104+
* ```ts
105+
* const navigation = new VIAM.NavigationClient(machine, 'my_navigation');
106+
*
107+
* const location = { latitude: 40.7128, longitude: -74.006 };
108+
* await navigation.addWayPoint(location);
109+
* ```
110+
*
111+
* For more information, see [Navigation
112+
* API](https://docs.viam.com/dev/reference/apis/services/navigation/#addwaypoint).
113+
*
114+
* @param location - A waypoint described by latitude and longitude values.
37115
*/
38116
addWayPoint: (location: GeoPoint, extra?: Struct) => Promise<void>;
39117

40118
/**
41119
* Remove a waypoint from the service's data storage.
42120
*
121+
* @example
122+
*
123+
* ```ts
124+
* const navigation = new VIAM.NavigationClient(machine, 'my_navigation');
125+
*
126+
* // Remove the first waypoint
127+
* if (waypoints.length > 0) {
128+
* await navigation.removeWayPoint(waypoints[0].id);
129+
* }
130+
* ```
131+
*
132+
* For more information, see [Navigation
133+
* API](https://docs.viam.com/dev/reference/apis/services/navigation/#removewaypoint).
134+
*
43135
* @param id - The MongoDB ObjectID of the waypoint to remove from the
44136
* service's data storage.
45137
*/
46138
removeWayPoint: (id: string, extra?: Struct) => Promise<void>;
47139

48-
/** Get a list of obstacles. */
140+
/**
141+
* Get a list of obstacles.
142+
*
143+
* @example
144+
*
145+
* ```ts
146+
* const navigation = new VIAM.NavigationClient(machine, 'my_navigation');
147+
*
148+
* const obstacles = await navigation.getObstacles();
149+
* ```
150+
*
151+
* For more information, see [Navigation
152+
* API](https://docs.viam.com/dev/reference/apis/services/navigation/#getobstacles).
153+
*/
49154
getObstacles: (extra?: Struct) => Promise<GeoGeometry[]>;
50155

51-
/** Gets the list of paths known to the navigation service. */
156+
/**
157+
* Gets the list of paths known to the navigation service.
158+
*
159+
* @example
160+
*
161+
* ```ts
162+
* const navigation = new VIAM.NavigationClient(machine, 'my_navigation');
163+
*
164+
* const paths = await navigation.getPaths();
165+
* ```
166+
*
167+
* For more information, see [Navigation
168+
* API](https://docs.viam.com/dev/reference/apis/services/navigation/#getpaths).
169+
*/
52170
getPaths: (extra?: Struct) => Promise<Path[]>;
53171

54-
/** Gets information on the properties of the current navigation service. */
172+
/**
173+
* Gets information on the properties of the current navigation service.
174+
*
175+
* @example
176+
*
177+
* ```ts
178+
* const navigation = new VIAM.NavigationClient(machine, 'my_navigation');
179+
*
180+
* const properties = await navigation.getProperties();
181+
* ```
182+
*
183+
* For more information, see [Navigation
184+
* API](https://docs.viam.com/dev/reference/apis/services/navigation/#getproperties).
185+
*/
55186
getProperties: () => Promise<NavigationProperties>;
56187
}

0 commit comments

Comments
 (0)