Viam C++ SDK current
Loading...
Searching...
No Matches
movement_sensor.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <string>
7
8#include <viam/sdk/common/linear_algebra.hpp>
9#include <viam/sdk/common/proto_value.hpp>
10#include <viam/sdk/common/utils.hpp>
11#include <viam/sdk/config/resource.hpp>
12#include <viam/sdk/spatialmath/orientation.hpp>
13
14namespace viam {
15namespace sdk {
16
18
24class MovementSensor : public Component {
25 public:
29 double value = 0.0;
30 friend bool operator==(const compassheading&, const compassheading&) = default;
31 };
32
36 struct orientation {
37 double o_x = 0.0, o_y = 0.0, o_z = 0.0, theta = 0.0;
38 };
39
41 struct position {
42 geo_point coordinate;
43 float altitude_m = 0.0f;
44 friend bool operator==(const position&, const position&) = default;
45 };
46
48 struct properties {
49 bool linear_velocity_supported = false;
50 bool angular_velocity_supported = false;
51 bool orientation_supported = false;
52 bool position_supported = false;
53 bool compass_heading_supported = false;
54 bool linear_acceleration_supported = false;
55 friend bool operator==(const properties&, const properties&) = default;
56 };
57
58 API api() const override;
59
60 inline Vector3 get_linear_velocity() {
61 return get_linear_velocity({});
62 }
63
64 virtual Vector3 get_linear_velocity(const ProtoStruct& extra) = 0;
65
66 inline Vector3 get_angular_velocity() {
67 return get_angular_velocity({});
68 }
69
70 virtual Vector3 get_angular_velocity(const ProtoStruct& extra) = 0;
71
72 inline compassheading get_compass_heading() {
73 return get_compass_heading({});
74 }
75
76 virtual compassheading get_compass_heading(const ProtoStruct& extra) = 0;
77
78 inline orientation get_orientation() {
79 return get_orientation({});
80 }
81
82 virtual orientation get_orientation(const ProtoStruct& extra) = 0;
83
84 inline position get_position() {
85 return get_position({});
86 }
87
88 virtual position get_position(const ProtoStruct& extra) = 0;
89
90 inline properties get_properties() {
91 return get_properties({});
92 }
93
94 virtual properties get_properties(const ProtoStruct& extra) = 0;
95
96 inline std::unordered_map<std::string, float> get_accuracy() {
97 return get_accuracy({});
98 }
99
100 virtual std::unordered_map<std::string, float> get_accuracy(const ProtoStruct& extra) = 0;
101
102 inline Vector3 get_linear_acceleration() {
103 return get_linear_acceleration({});
104 }
105
106 virtual Vector3 get_linear_acceleration(const ProtoStruct& extra) = 0;
107
111 virtual ProtoStruct do_command(const ProtoStruct& command) = 0;
112
115 virtual ProtoStruct get_status() = 0;
116
119 inline std::vector<GeometryConfig> get_geometries() {
120 return get_geometries({});
121 }
122
126 virtual std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) = 0;
127
128 protected:
129 explicit MovementSensor(std::string name) : Component(std::move(name)) {}
130
131 explicit MovementSensor(const ResourceConfig& cfg) : Component(cfg) {}
132};
133
134template <>
136 static API api();
137};
138
139} // namespace sdk
140} // namespace viam
Definition resource_api.hpp:21
Definition component.hpp:10
Definition movement_sensor.hpp:24
virtual ProtoStruct get_status()=0
Get the status of the movement sensor.
API api() const override
Returns the API associated with a particular resource.
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 movementsensor.
std::vector< GeometryConfig > get_geometries()
Returns GeometryConfigs associated with the calling movementsensor.
Definition movement_sensor.hpp:119
Definition resource.hpp:42
virtual std::string name() const
Return the resource's name.
Current position of the motor relative to its home.
Definition resource_api.hpp:46
Definition movement_sensor.hpp:27
double value
A number from 0-359 where 0 is North, 90 is East, 180 is South, and 270 is West.
Definition movement_sensor.hpp:29
Struct version of viam::common::v1::Orientation. TODO: we already have this in orientation_types....
Definition movement_sensor.hpp:36
Definition movement_sensor.hpp:41
Definition movement_sensor.hpp:48
Definition linear_algebra.hpp:25
Definition geometry.hpp:89