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
35 struct orientation {
36 double o_x, o_y, o_z, theta;
37 };
38
40 struct position {
41 geo_point coordinate;
42 float altitude_m;
43 };
44
46 struct properties {
47 bool linear_velocity_supported;
48 bool angular_velocity_supported;
49 bool orientation_supported;
50 bool position_supported;
51 bool compass_heading_supported;
52 bool linear_acceleration_supported;
53 };
54
55 API api() const override;
56
57 inline Vector3 get_linear_velocity() {
58 return get_linear_velocity({});
59 }
60
61 virtual Vector3 get_linear_velocity(const ProtoStruct& extra) = 0;
62
63 inline Vector3 get_angular_velocity() {
64 return get_angular_velocity({});
65 }
66
67 virtual Vector3 get_angular_velocity(const ProtoStruct& extra) = 0;
68
69 inline compassheading get_compass_heading() {
70 return get_compass_heading({});
71 }
72
73 virtual compassheading get_compass_heading(const ProtoStruct& extra) = 0;
74
75 inline orientation get_orientation() {
76 return get_orientation({});
77 }
78
79 virtual orientation get_orientation(const ProtoStruct& extra) = 0;
80
81 inline position get_position() {
82 return get_position({});
83 }
84
85 virtual position get_position(const ProtoStruct& extra) = 0;
86
87 inline properties get_properties() {
88 return get_properties({});
89 }
90
91 virtual properties get_properties(const ProtoStruct& extra) = 0;
92
93 inline std::unordered_map<std::string, float> get_accuracy() {
94 return get_accuracy({});
95 }
96
97 virtual std::unordered_map<std::string, float> get_accuracy(const ProtoStruct& extra) = 0;
98
99 inline Vector3 get_linear_acceleration() {
100 return get_linear_acceleration({});
101 }
102
103 virtual Vector3 get_linear_acceleration(const ProtoStruct& extra) = 0;
104
108 virtual ProtoStruct do_command(const ProtoStruct& command) = 0;
109
112 inline std::vector<GeometryConfig> get_geometries() {
113 return get_geometries({});
114 }
115
119 virtual std::vector<GeometryConfig> get_geometries(const ProtoStruct& extra) = 0;
120
121 protected:
122 explicit MovementSensor(std::string name) : Component(std::move(name)) {}
123};
124
125template <>
127 static API api();
128};
129
130bool operator==(const MovementSensor::compassheading& lhs,
132bool operator==(const MovementSensor::position& lhs, const MovementSensor::position& rhs);
133bool operator==(const MovementSensor::properties& lhs, const MovementSensor::properties& rhs);
134} // namespace sdk
135} // namespace viam
Definition resource_api.hpp:21
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:112
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:35
Definition movement_sensor.hpp:40
Definition movement_sensor.hpp:46
Definition linear_algebra.hpp:25
Definition geometry.hpp:86