Viam C++ SDK current
Loading...
Searching...
No Matches
geometry.hpp
1#pragma once
2
3#include <array>
4#include <string>
5#include <tuple>
6
7#include <viam/api/common/v1/common.pb.h>
8
9#include <viam/sdk/common/pose.hpp>
10#include <viam/sdk/spatialmath/orientation.hpp>
11
12namespace viam {
13namespace sdk {
14
15// TODO(RSDK-4553): add thorough documentation to this whole file.
16enum GeometryType {
17 box,
18 sphere,
19 capsule,
20 point,
21 unknown,
22};
23
24struct box {
25 double x;
26 double y;
27 double z;
28 friend bool operator==(const box& lhs, const box& rhs);
29};
30struct sphere {
31 double radius;
32 friend bool operator==(const sphere& lhs, const sphere& rhs);
33};
34struct capsule {
35 double radius;
36 double length;
37 friend bool operator==(const capsule& lhs, const capsule& rhs);
38};
39
40typedef boost::variant<struct box, struct sphere, struct capsule, boost::blank> geometry_specifics;
41
43 public:
44 viam::common::v1::Geometry to_proto() const;
45 viam::common::v1::RectangularPrism box_proto() const;
46 viam::common::v1::Sphere sphere_proto() const;
47 viam::common::v1::Capsule capsule_proto() const;
48 viam::common::v1::Pose pose_proto() const;
49 static GeometryConfig from_proto(const viam::common::v1::Geometry& proto);
50 static std::vector<GeometryConfig> from_proto(
51 const viam::common::v1::GetGeometriesResponse& proto);
52 void set_coordinates(coordinates coordinates);
53 void set_pose(pose pose);
54 void set_pose_orientation(pose_orientation orientation);
55 void set_theta(double theta);
56 void set_geometry_specifics(geometry_specifics gs);
57 void set_geometry_type(GeometryType type);
58 void set_orientation_config(OrientationConfig config);
59 void set_label(std::string label);
60 double get_theta() const;
61 coordinates get_coordinates() const;
62 pose get_pose() const;
63 geometry_specifics get_geometry_specifics() const;
64 GeometryType get_geometry_type() const;
65 OrientationConfig get_orientation_config() const;
66 std::string get_label() const;
67 friend bool operator==(const GeometryConfig& lhs, const GeometryConfig& rhs);
69
70 private:
71 GeometryType geometry_type_;
72 pose pose_;
73 geometry_specifics geometry_specifics_;
74 // TODO: if and when RDK makes more explicit use of ox/oy/oz, we should
75 // do the same here
76 OrientationConfig orientation_config_;
77 std::string label_;
78};
79
80struct geo_point {
81 double longitude, latitude;
82
83 common::v1::GeoPoint to_proto() const;
84 static geo_point from_proto(const common::v1::GeoPoint& proto);
85 friend bool operator==(const geo_point& lhs, const geo_point& rhs);
86 friend std::ostream& operator<<(std::ostream& os, const geo_point& v);
87};
88
90 geo_point location;
91 std::vector<GeometryConfig> geometries;
92
93 common::v1::GeoGeometry to_proto() const;
94 static geo_geometry from_proto(const common::v1::GeoGeometry& proto);
95 friend bool operator==(const geo_geometry& lhs, const geo_geometry& rhs);
96};
97
98} // namespace sdk
99} // namespace viam
Definition geometry.hpp:42
Definition orientation.hpp:19
Definition geometry.hpp:24
Definition geometry.hpp:34
Definition pose.hpp:8
Definition geometry.hpp:89
Definition geometry.hpp:80
Definition pose.hpp:13
Definition pose.hpp:18
Definition geometry.hpp:30