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 virtual ProtoStruct get_status() = 0;
34
37 inline std::vector<GeometryConfig> get_geometries() {
38 return get_geometries({});
39 }
40
44 virtual std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) = 0;
45
48 inline ProtoStruct get_readings() {
49 return get_readings({});
50 }
51
55 virtual ProtoStruct get_readings(const ProtoStruct& extra) = 0;
56
57 protected:
58 explicit Sensor(std::string name) : Component(std::move(name)) {}
59};
60
61template <>
63 static API api();
64};
65
66} // namespace sdk
67} // namespace viam
Definition resource_api.hpp:21
Definition component.hpp:10
virtual std::string name() const
Return the resource's name.
Definition sensor.hpp:22
virtual ProtoStruct get_status()=0
Get the status of the sensor.
std::vector< GeometryConfig > get_geometries()
Returns GeometryConfigs associated with the calling sensor.
Definition sensor.hpp:37
ProtoStruct get_readings()
Returns the measurements/data specific to this sensor.
Definition sensor.hpp:48
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:46