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;
30 };
31
34 struct orientation {
35 double o_x, o_y, o_z, theta;
36 };
37
39 struct position {
40 geo_point coordinate;
41 float altitude_m;
42 };
43
45 struct properties {
46 bool linear_velocity_supported;
47 bool angular_velocity_supported;
48 bool orientation_supported;
49 bool position_supported;
50 bool compass_heading_supported;
51 bool linear_acceleration_supported;
52 };
53
54 API api() const override;
55
56 inline Vector3 get_linear_velocity() {
57 return get_linear_velocity({});
58 }
59
60 virtual Vector3 get_linear_velocity(const ProtoStruct& extra) = 0;
61
62 inline Vector3 get_angular_velocity() {
63 return get_angular_velocity({});
64 }
65
66 virtual Vector3 get_angular_velocity(const ProtoStruct& extra) = 0;
67
68 inline compassheading get_compass_heading() {
69 return get_compass_heading({});
70 }
71
72 virtual compassheading get_compass_heading(const ProtoStruct& extra) = 0;
73
74 inline orientation get_orientation() {
75 return get_orientation({});
76 }
77
78 virtual orientation get_orientation(const ProtoStruct& extra) = 0;
79
80 inline position get_position() {
81 return get_position({});
82 }
83
84 virtual position get_position(const ProtoStruct& extra) = 0;
85
86 inline properties get_properties() {
87 return get_properties({});
88 }
89
90 virtual properties get_properties(const ProtoStruct& extra) = 0;
91
92 inline std::unordered_map<std::string, float> get_accuracy() {
93 return get_accuracy({});
94 }
95
96 virtual std::unordered_map<std::string, float> get_accuracy(const ProtoStruct& extra) = 0;
97
98 inline Vector3 get_linear_acceleration() {
99 return get_linear_acceleration({});
100 }
101
102 virtual Vector3 get_linear_acceleration(const ProtoStruct& extra) = 0;
103
107 virtual ProtoStruct do_command(const ProtoStruct& command) = 0;
108
111 inline std::vector<GeometryConfig> get_geometries() {
112 return get_geometries({});
113 }
114
118 virtual std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) = 0;
119
120 protected:
121 explicit MovementSensor(std::string name) : Component(std::move(name)){};
122};
123
124template <>
126 static API api();
127};
128
129bool operator==(const MovementSensor::compassheading& lhs,
131bool operator==(const MovementSensor::position& lhs, const MovementSensor::position& rhs);
132bool operator==(const MovementSensor::properties& lhs, const MovementSensor::properties& rhs);
133} // namespace sdk
134} // namespace viam
Extends APIType to additionally define a resource's subtype (e.g., camera).
Definition resource_api.hpp:33
Definition component.hpp:10
Definition movement_sensor.hpp:24
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:111
virtual std::string name() const
Return the resource's name.
Definition linear_algebra.hpp:15
Current position of the motor relative to its home.
Definition resource_api.hpp:50
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.
Definition movement_sensor.hpp:34
Definition movement_sensor.hpp:39
Definition movement_sensor.hpp:45
Definition geometry.hpp:80