spot-sdk-js
Version:
Develop applications and payloads for Spot using the unofficial Boston Dynamics Spot Node.js SDK.
81 lines (72 loc) • 3.71 kB
JavaScript
const {BaseClient, common_header_errors} = require('../bosdyn-client/common.js');
const local_grid_pb = require('../bosdyn/api/local_grid_pb.js');
const local_grid_service_grpc_pb = require('../bosdyn/api/local_grid_service_grpc_pb.js');
/**
* Client to access local grid local_grids from the robot.
* @class LocalGridClient
* @extends BaseClient
*/
class LocalGridClient extends BaseClient {
static default_service_name = 'local-grid-service';
static service_type = 'bosdyn.api.LocalGridService';
/**
* Create an instance of LocalGridClient's class.
* @param {string} [name=null] Name of the Class.
*/
constructor(name = null){
super(local_grid_service_grpc_pb.LocalGridServiceClient, name);
}
/**
* Get a list of the local_grid types available from the robot.
* @param {object} args Extra arguments for controlling RPC details.
* @return {array} A list of the different types (string names) of local grids.
* @throws {RpcError} Problem communicating with the robot.
*/
async get_local_grid_types(args){
const request = new local_grid_pb.GetLocalGridTypesRequest();
return await this.call(this._stub.getLocalGridTypes, request, (res) => {res.getLocalGridType()}, common_header_errors, args);
}
/**
* Get a list of the local_grid types available from the robot asynchronously.
* @param {object} args Extra arguments for controlling RPC details.
* @return {array} A list of the different types (string names) of local grids.
* @throws {RpcError} Problem communicating with the robot.
*/
get_local_grid_types_async(args){
const request = new local_grid_pb.GetLocalGridTypesRequest();
return this.call_async(this._stub.getLocalGridTypes, request, (res) => {res.getLocalGridType()}, common_header_errors, args);
}
/**
* Get a selection of local_grids of specified types.
* @param {Array<String>} local_grid_type_names List of strings specifying types local_grids to request.
* Available local_grid types may be requested using get_local_grid_types().
* @param {object} args Extra arguments for controlling RPC details.
* @return {Array<LocalGridResponseProtos>} A list of LocalGridResponseProtos, each containing a local_grid or an error status code.
* @throws {RpcError} Problem communicating with the robot.
*/
async get_local_grids(local_grid_type_names, args){
const request = new local_grid_pb.GetLocalGridsRequest();
for(const local_grid_type_name of local_grid_type_names){
request.addLocalGridRequests(local_grid_type_name);
}
return await this.call(this._stub.getLocalGrids, request, (res) => {res.getLocalGridResponses()}, common_header_errors, args);
}
/**
* Get a selection of local_grids of specified types asynchronously.
* @param {Array<String>} local_grid_type_names List of strings specifying types local_grids to request.
* Available local_grid types may be requested using get_local_grid_types().
* @param {object} args Extra arguments for controlling RPC details.
* @return {Array<LocalGridResponseProtos>} A list of LocalGridResponseProtos, each containing a local_grid or an error status code.
* @throws {RpcError} Problem communicating with the robot.
*/
get_local_grids_async(local_grid_type_names, args){
const request = new local_grid_pb.GetLocalGridsRequest();
for(const local_grid_type_name of local_grid_type_names){
request.addLocalGridRequests(local_grid_type_name);
}
return this.call_async(this._stub.getLocalGrids, request, (res) => {res.getLocalGridResponses()}, common_header_errors, args);
}
};
module.exports = {
LocalGridClient
};