Viam C++ SDK current
Loading...
Searching...
No Matches
sensor.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <string>
7
8#include <viam/sdk/common/proto_value.hpp>
9#include <viam/sdk/common/utils.hpp>
10#include <viam/sdk/config/resource.hpp>
11
12namespace viam {
13namespace sdk {
14
16
22class Sensor : public Component {
23 public:
24 API api() const override;
25
29 virtual ProtoStruct do_command(const ProtoStruct& command) = 0;
30
33 inline std::vector<GeometryConfig> get_geometries() {
34 return get_geometries({});
35 }
36
40 virtual std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) = 0;
41
44 inline ProtoStruct get_readings() {
45 return get_readings({});
46 }
47
51 virtual ProtoStruct get_readings(const ProtoStruct& extra) = 0;
52
53 protected:
54 explicit Sensor(std::string name) : Component(std::move(name)){};
55};
56
57template <>
59 static API api();
60};
61
62} // namespace sdk
63} // namespace viam
Extends APIType to additionally define a resource's subtype (e.g., camera).
Definition resource_api.hpp:33
Definition component.hpp:10
virtual std::string name() const
Return the resource's name.
Definition sensor.hpp:22
std::vector< GeometryConfig > get_geometries()
Returns GeometryConfigs associated with the calling sensor.
Definition sensor.hpp:33
ProtoStruct get_readings()
Returns the measurements/data specific to this sensor.
Definition sensor.hpp:44
virtual ProtoStruct get_readings(const ProtoStruct &extra)=0
Returns the measurements/data specific to this sensor.
virtual ProtoStruct do_command(const ProtoStruct &command)=0
Send/receive arbitrary commands to the resource.
virtual std::vector< GeometryConfig > get_geometries(const ProtoStruct &extra)=0
Returns GeometryConfigs associated with the calling sensor.
API api() const override
Returns the API associated with a particular resource.
Definition resource_api.hpp:50