10#include <viam/sdk/common/grpc_fwd.hpp>
11#include <viam/sdk/common/pose.hpp>
12#include <viam/sdk/common/proto_convert.hpp>
13#include <viam/sdk/common/utils.hpp>
15#include <viam/sdk/components/component.hpp>
17#include <viam/sdk/resource/resource.hpp>
18#include <viam/sdk/rpc/dial.hpp>
19#include <viam/sdk/services/service.hpp>
27class FrameSystemConfig;
28class GetMachineStatusResponse;
34class SendTracesRequest;
43class ParentSendTracesExporter;
65 friend std::ostream& operator<<(std::ostream& os,
const status& v);
69 ProtoStruct kinematics;
76 boost::optional<std::string> session_id;
77 ProtoStruct arguments;
78 boost::optional<time_pt> started;
83 enum class resource_state : uint8_t {
94 boost::optional<time_pt> last_updated;
101 std::string revision;
102 boost::optional<time_pt> last_updated;
107 enum class module_state : uint8_t {
116 std::string module_name;
118 boost::optional<time_pt> last_updated;
120 std::uint32_t consecutive_failures;
125 enum class package_type : uint8_t {
134 enum class package_state : uint8_t {
147 boost::optional<time_pt> last_updated;
149 std::uint64_t bytes_downloaded;
150 std::uint64_t total_bytes;
155 std::string job_name;
156 std::vector<time_pt> recent_successful_runs;
157 std::vector<time_pt> recent_failed_runs;
163 std::vector<resource_status> resources;
165 std::vector<module_status> modules;
166 std::vector<package_status> packages;
167 std::vector<job_status> job_statuses;
191 static std::shared_ptr<RobotClient>
at_address(
const std::string& address,
207 std::vector<Name> resource_names()
const;
222 template <
typename T>
228 return std::dynamic_pointer_cast<T>(
resource_by_name({API::get<T>(),
"", std::move(name)}));
234 const std::vector<WorldState::transform>& additional_transforms = {});
246 std::string destination,
247 const std::vector<WorldState::transform>& additional_transforms = {});
258 void stop_all(
const std::unordered_map<Name, ProtoStruct>& extra);
276 const std::string& destination_frame,
277 const std::vector<WorldState::transform>& additional_transforms,
278 const ProtoStruct& extra);
286 friend class impl::ParentSendTracesExporter;
288 void log(
const std::string& name,
289 const std::string& level,
290 const std::string& message,
292 const std::string& file,
296 bool send_traces(
const robot::v1::SendTracesRequest* req);
303 void connect_logging();
307 void connect_tracing();
309 void refresh_every();
310 void check_connection();
312 std::thread refresh_thread_;
313 std::thread check_connection_thread_;
314 std::atomic<bool> should_refresh_;
315 std::atomic<bool> should_check_connection_;
316 std::chrono::seconds refresh_interval_;
317 std::chrono::seconds check_every_interval_;
318 std::chrono::seconds reconnect_every_interval_;
323 std::unique_ptr<impl> impl_;
325 mutable std::mutex lock_;
327 std::vector<Name> resource_names_;
331namespace proto_convert_details {
Defines the gRPC receiving logic for a module. C++ module authors can construct a ModuleService and u...
Definition service.hpp:30
A name for specific instances of resources.
Definition resource_api.hpp:61
Defines a resource manager for use by anything that tracks resources.
Definition resource_manager.hpp:22
gRPC client for a robot, to be used for all interactions with a robot. There are two ways to instanti...
Definition client.hpp:54
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.
pose_in_frame get_pose(const std::string &component_name)
Get the pose of a component in the world reference frame.
std::shared_ptr< Resource > resource_by_name(const Name &name)
Lookup and return a shared_ptr to a resource.
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.
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.
void close()
Disconnect this robot client from any robot to which it is connected. After calling this method it is...
void stop_all()
Cancel all operations for the robot and stop all actuators and movement.
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.
void block_for_operation(std::string id)
Blocks on the specified operation of the robot, returning when it is complete.
void cancel_operation(std::string id)
Cancel a specified operation on the robot.
std::vector< operation > get_operations()
Get the list of operations currently running on a robot.
std::shared_ptr< T > resource_by_name(std::string name)
Lookup and return a shared_ptr to a resource of the requested type.
Definition client.hpp:227
pose_in_frame get_pose(const std::string &component_name, const std::string &destination_frame, const std::vector< WorldState::transform > &additional_transforms, const ProtoStruct &extra)
Get the pose of a component in the desired reference frame.
void stop_all(const std::unordered_map< Name, ProtoStruct > &extra)
Cancel all operations for the robot and stop all actuators and movement.
static std::shared_ptr< RobotClient > with_channel(ViamChannel channel, const Options &options)
Creates a robot client connected to the provided channel.
void refresh()
Call out to the robot to see if there are any new resources that need to be registered....
machine_status get_machine_status() const
gets the current status of the machine
status
the current status of the robot
Definition client.hpp:59
Defines the resource registry and associated types.
Definition client.hpp:100
Definition client.hpp:154
Definition client.hpp:161
Definition client.hpp:106
Definition client.hpp:124
Definition log_backend.hpp:18
Definition proto_convert.hpp:24