Viam C++ SDK current
Loading...
Searching...
No Matches
camera_client.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <viam/api/common/v1/common.pb.h>
7#include <viam/api/component/camera/v1/camera.grpc.pb.h>
8
11#include <viam/sdk/config/resource.hpp>
13#include <viam/sdk/rpc/dial.hpp>
14
15namespace viam {
16namespace sdk {
17namespace impl {
18
22class CameraClient : public Camera {
23 public:
24 using interface_type = Camera;
25
26 CameraClient(std::string name, const ViamChannel& channel);
27
28 const ViamChannel& channel() const {
29 return *channel_;
30 }
31
32 ProtoStruct do_command(const ProtoStruct& command) override;
33
34 image_collection get_images(std::vector<std::string> filter_source_names,
35 const ProtoStruct& extra) override;
36
37 point_cloud get_point_cloud(std::string mime_type, const ProtoStruct& extra) override;
38
40
41 std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) override;
42
43 // the `extra` param is frequently unnecessary but needs to be supported. Ideally, we'd
44 // like to live in a world where implementers of derived classes don't need to go out of
45 // their way to support two versions of a method (an `extra` version and a non-`extra`
46 // version), and users don't need to pass an unnecessary parameters to all method calls.
47 //
48 // To do this, we define in the parent resource class a non-virtual version of the methods
49 // that calls the virtual method and passes a `nullptr` by default in place of the `extra`
50 // param. In order to access these versions of the methods within the client code, however,
51 // we need to include these `using` lines.
55
56 protected:
57 // This constructor leaves the `channel_` as a nullptr. This is useful for testing
58 // purposes, but renders it unusable for production use. Care should be taken to
59 // avoid use of this constructor outside of tests.
60 CameraClient(std::string name,
61 std::unique_ptr<viam::component::camera::v1::CameraService::StubInterface> stub)
62 : Camera(std::move(name)), stub_(std::move(stub)) {}
63
64 private:
65 using StubType = viam::component::camera::v1::CameraService::StubInterface;
66 std::unique_ptr<StubType> stub_;
67 const ViamChannel* channel_;
68};
69
70} // namespace impl
71} // namespace sdk
72} // namespace viam
Defines a Camera component.
Implements a gRPC server for the Camera component.
A Camera represents any physical hardware that can capture frames.
Definition camera.hpp:33
std::vector< GeometryConfig > get_geometries()
Returns GeometryConfigs associated with the calling camera.
Definition camera.hpp:187
point_cloud get_point_cloud(std::string mime_type)
Get the next point_cloud from the camera.
Definition camera.hpp:175
image_collection get_images()
Get the next images from the camera as a vector of raw images with names and metadata.
Definition camera.hpp:150
virtual std::string name() const
Return the resource's name.
Definition dial.hpp:25
gRPC client implementation of a Camera component.
Definition camera_client.hpp:22
properties get_properties() override
Get the camera's properties.
std::vector< GeometryConfig > get_geometries(const ProtoStruct &extra) override
Returns GeometryConfigs associated with the calling camera.
ProtoStruct do_command(const ProtoStruct &command) override
Send/receive arbitrary commands to the resource.
image_collection get_images(std::vector< std::string > filter_source_names, const ProtoStruct &extra) override
Get the next images from the camera as a vector of raw images with names and metadata.
point_cloud get_point_cloud(std::string mime_type, const ProtoStruct &extra) override
Get the next point_cloud from the camera.
gRPC client implementation for a robot.
a collection of images that were collected from a camera all at the same time.
Definition camera.hpp:96
The points and mime type of a point cloud.
Definition camera.hpp:78
The camera's supported features and settings.
Definition camera.hpp:58