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/api/component/sensor/v1/sensor.pb.h>
9
10#include <viam/sdk/common/proto_type.hpp>
11#include <viam/sdk/common/utils.hpp>
12#include <viam/sdk/config/resource.hpp>
13
14namespace viam {
15namespace sdk {
16
18
24class Sensor : public Component {
25 public:
26 API api() const override;
27
31 virtual AttributeMap do_command(const AttributeMap& command) = 0;
32
35 inline std::vector<GeometryConfig> get_geometries() {
36 return get_geometries({});
37 }
38
42 virtual std::vector<GeometryConfig> get_geometries(const AttributeMap& extra) = 0;
43
46 inline AttributeMap get_readings() {
47 return get_readings({});
48 }
49
53 virtual AttributeMap get_readings(const AttributeMap& extra) = 0;
54
55 protected:
56 explicit Sensor(std::string name) : Component(std::move(name)){};
57};
58
59template <>
61 static API api();
62};
63
64} // namespace sdk
65} // namespace viam
Extends APIType to additionally define a resource's subtype (e.g., camera).
Definition resource_api.hpp:33
Definition component.hpp:14
virtual std::string name() const
Return the resource's name.
Definition sensor.hpp:24
AttributeMap get_readings()
Returns the measurements/data specific to this sensor.
Definition sensor.hpp:46
std::vector< GeometryConfig > get_geometries()
Returns GeometryConfigs associated with the calling sensor.
Definition sensor.hpp:35
virtual AttributeMap get_readings(const AttributeMap &extra)=0
Returns the measurements/data specific to this sensor.
virtual std::vector< GeometryConfig > get_geometries(const AttributeMap &extra)=0
Returns GeometryConfigs associated with the calling sensor.
API api() const override
Returns the API associated with a particular resource.
virtual AttributeMap do_command(const AttributeMap &command)=0
Send/receive arbitrary commands to the resource.
Definition resource_api.hpp:50