Viam C++ SDK current
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
viam::sdk::RobotClient Class Reference

gRPC client for a robot, to be used for all interactions with a robot. There are two ways to instantiate a robot: More...

#include "robot/client.hpp"

Classes

struct  discovery
 
struct  discovery_query
 
struct  frame_system_config
 
struct  operation
 
struct  status
 

Public Member Functions

void refresh ()
 
void close ()
 
 RobotClient (std::shared_ptr< ViamChannel > channel)
 
std::vector< Nameresource_names () const
 
std::shared_ptr< Resourceresource_by_name (const Name &name)
 Lookup and return a shared_ptr to a resource.
 
template<typename T >
std::shared_ptr< Tresource_by_name (std::string name)
 Lookup and return a shared_ptr to a resource of the requested type.
 
std::vector< frame_system_configget_frame_system_config (const std::vector< WorldState::transform > &additional_transforms={})
 Get the configuration of the frame system of the given robot.
 
std::vector< operationget_operations ()
 Get the list of operations currently running on a robot.
 
std::vector< statusget_status (std::vector< Name > &components)
 Get the status of the requested robot components.
 
std::vector< statusget_status ()
 Get the status of all robot components.
 
std::vector< discoverydiscover_components (const std::vector< discovery_query > &queries)
 
pose_in_frame transform_pose (const pose_in_frame &query, std::string destination, const std::vector< WorldState::transform > &additional_transforms={})
 Transform a given Pose to a new specified destination which is a reference frame.
 
void block_for_operation (std::string id)
 Blocks on the specified operation of the robot, returning when it is complete.
 
void stop_all ()
 Cancel all operations for the robot and stop all actuators and movement.
 
void stop_all (const std::unordered_map< Name, AttributeMap > &extra)
 Cancel all operations for the robot and stop all actuators and movement.
 
void cancel_operation (std::string id)
 Cancel a specified operation on the robot.
 

Static Public Member Functions

static std::shared_ptr< RobotClientat_address (const std::string &address, const Options &options)
 Create a robot client connected to the robot at the provided address.
 
static std::shared_ptr< RobotClientat_local_socket (const std::string &address, const Options &options)
 Creates a robot client connected to the robot at the provided local socket.
 
static std::shared_ptr< RobotClientwith_channel (std::shared_ptr< ViamChannel > channel, const Options &options)
 Creates a robot client connected to the provided channel.
 

Detailed Description

gRPC client for a robot, to be used for all interactions with a robot. There are two ways to instantiate a robot:

You must close() a robot when finished with it in order to release its resources. Robots creates via at_address will automatically close, but robots created via with_channel require a user call to close().

Member Function Documentation

◆ at_address()

static std::shared_ptr< RobotClient > viam::sdk::RobotClient::at_address ( const std::string & address,
const Options & options )
static

Create a robot client connected to the robot at the provided address.

Parameters
addressThe address of the robot (IP address, URI, URL, etc.)
optionsOptions for connecting and refreshing.

◆ at_local_socket()

static std::shared_ptr< RobotClient > viam::sdk::RobotClient::at_local_socket ( const std::string & address,
const Options & options )
static

Creates a robot client connected to the robot at the provided local socket.

Parameters
addressThe local socket of the robot (a .sock file, etc.).
optionsOptions for connecting and refreshing. Creates a direct connection to the robot using the unix:// scheme. Only useful for connecting to robots across Unix sockets.

◆ block_for_operation()

void viam::sdk::RobotClient::block_for_operation ( std::string id)

Blocks on the specified operation of the robot, returning when it is complete.

Parameters
idThe ID of the operation to block on.

◆ cancel_operation()

void viam::sdk::RobotClient::cancel_operation ( std::string id)

Cancel a specified operation on the robot.

Parameters
idThe ID of the operation to cancel.

◆ get_frame_system_config()

std::vector< frame_system_config > viam::sdk::RobotClient::get_frame_system_config ( const std::vector< WorldState::transform > & additional_transforms = {})

Get the configuration of the frame system of the given robot.

Returns
The configuration of the calling robot's frame system.

◆ get_operations()

std::vector< operation > viam::sdk::RobotClient::get_operations ( )

Get the list of operations currently running on a robot.

Returns
The list of operations currently running on the calling robot.

◆ get_status() [1/2]

std::vector< status > viam::sdk::RobotClient::get_status ( )

Get the status of all robot components.

Returns
A list of statuses.

◆ get_status() [2/2]

std::vector< status > viam::sdk::RobotClient::get_status ( std::vector< Name > & components)

Get the status of the requested robot components.

Parameters
componentsA list of the specific components for which status is desired.
Returns
A list of statuses.

◆ resource_by_name() [1/2]

std::shared_ptr< Resource > viam::sdk::RobotClient::resource_by_name ( const Name & name)

Lookup and return a shared_ptr to a resource.

Parameters
nameThe Name of the resource.
Exceptions
`Exception`if the requested resource doesn't exist or is the wrong type.
Returns
a shared_ptr to the requested resource as an uncasted Resource.

This method should not be called directly except in specific cases. The type-annotated resource_by_name<T>(name) overload is the preferred method for obtaining resources.

Because the return type here is a Resource, the user will need to manually cast to the desired type.

◆ resource_by_name() [2/2]

template<typename T >
std::shared_ptr< T > viam::sdk::RobotClient::resource_by_name ( std::string name)
inline

Lookup and return a shared_ptr to a resource of the requested type.

Parameters
nameThe ordinary name of the resource.
Exceptions
`Exception`if the requested resource doesn't exist or is the wrong type.
Returns
a shared_ptr to the requested resource.

◆ stop_all()

void viam::sdk::RobotClient::stop_all ( const std::unordered_map< Name, AttributeMap > & extra)

Cancel all operations for the robot and stop all actuators and movement.

Parameters
extraAny extra params to pass to resources' stop methods, keyed by Name.

◆ transform_pose()

pose_in_frame viam::sdk::RobotClient::transform_pose ( const pose_in_frame & query,
std::string destination,
const std::vector< WorldState::transform > & additional_transforms = {} )

Transform a given Pose to a new specified destination which is a reference frame.

Parameters
queryThe pose that should be transformed.
destinationThe name of the reference frame to transform the given pose to.
Returns
the pose_in_frame of the transformed pose.

◆ with_channel()

static std::shared_ptr< RobotClient > viam::sdk::RobotClient::with_channel ( std::shared_ptr< ViamChannel > channel,
const Options & options )
static

Creates a robot client connected to the provided channel.

Parameters
channelThe channel to connect with.
optionsOptions for connecting and refreshing. Connects directly to a pre-existing channel. A robot created this way must be close()d manually.

The documentation for this class was generated from the following file: