Viam C++ SDK current
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | 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  frame_system_config
 
struct  operation
 

Public Types

enum class  status : uint8_t { k_initializing , k_running , k_unspecified }
 the current status of the robot
 

Public Member Functions

 RobotClient (ViamChannel channel)
 
void refresh ()
 Call out to the robot to see if there are any new resources that need to be registered. Compares the currently registered resources to the ones from the robot, seeing if any updates have been made. If so, they are registered and updated in ResourceManager. This method can be called manually, or it will be called periodically and automatically if a positive refresh_interval is passed in the Options of the named constructors.
 
void close ()
 Disconnect this robot client from any robot to which it is connected. After calling this method it is no longer valid to call any methods which communicate with the robot.
 
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< T > resource_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.
 
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, ProtoStruct > &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.
 
status get_machine_status () const
 gets the current status of the machine
 

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 (ViamChannel channel, const Options &options)
 Creates a robot client connected to the provided channel.
 

Friends

class ModuleService
 
struct impl::LogBackend
 
std::ostream & operator<< (std::ostream &os, const status &v)
 

Detailed Description

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

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.

◆ 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, ProtoStruct > & 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 ( 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.

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