Viam C++ SDK current
|
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< Name > | resource_names () const |
std::shared_ptr< Resource > | resource_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_config > | get_frame_system_config (const std::vector< WorldState::transform > &additional_transforms={}) |
Get the configuration of the frame system of the given robot. | |
std::vector< operation > | get_operations () |
Get the list of operations currently running on a robot. | |
std::vector< status > | get_status (std::vector< Name > &components) |
Get the status of the requested robot components. | |
std::vector< status > | get_status () |
Get the status of all robot components. | |
std::vector< discovery > | discover_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, 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. | |
Static Public Member Functions | |
static std::shared_ptr< RobotClient > | at_address (const std::string &address, const Options &options) |
Create a robot client connected to the robot at the provided address. | |
static std::shared_ptr< RobotClient > | at_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< RobotClient > | with_channel (std::shared_ptr< ViamChannel > channel, const Options &options) |
Creates a robot client connected to the provided channel. | |
gRPC client for a robot, to be used for all interactions with a robot. There are two ways to instantiate a robot:
RobotClient::at_address(...)
RobotClient::with_channel(...)
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()
.
|
static |
Create a robot client connected to the robot at the provided address.
address | The address of the robot (IP address, URI, URL, etc.) |
options | Options for connecting and refreshing. |
|
static |
Creates a robot client connected to the robot at the provided local socket.
address | The local socket of the robot (a .sock file, etc.). |
options | Options for connecting and refreshing. Creates a direct connection to the robot using the unix:// scheme. Only useful for connecting to robots across Unix sockets. |
void viam::sdk::RobotClient::block_for_operation | ( | std::string | id | ) |
Blocks on the specified operation of the robot, returning when it is complete.
id | The ID of the operation to block on. |
void viam::sdk::RobotClient::cancel_operation | ( | std::string | id | ) |
Cancel a specified operation on the robot.
id | The ID of the operation to cancel. |
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.
std::vector< operation > viam::sdk::RobotClient::get_operations | ( | ) |
Get the list of operations currently running on a robot.
std::vector< status > viam::sdk::RobotClient::get_status | ( | ) |
Get the status of all robot components.
Get the status of the requested robot components.
components | A list of the specific components for which status is desired. |
Lookup and return a shared_ptr
to a resource.
name | The Name of the resource. |
`Exception` | if the requested resource doesn't exist or is the wrong type. |
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.
|
inline |
Lookup and return a shared_ptr
to a resource of the requested type.
name | The ordinary name of the resource. |
`Exception` | if the requested resource doesn't exist or is the wrong type. |
shared_ptr
to the requested resource. 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.
extra | Any extra params to pass to resources' stop methods, keyed by Name . |
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.
query | The pose that should be transformed. |
destination | The name of the reference frame to transform the given pose to. |
pose_in_frame
of the transformed pose.
|
static |
Creates a robot client connected to the provided channel.
channel | The channel to connect with. |
options | Options for connecting and refreshing. Connects directly to a pre-existing channel. A robot created this way must be close() d manually. |