Viam C++ SDK current
Loading...
Searching...
No Matches
world_state.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <optional>
7
8#include <viam/sdk/common/pose.hpp>
9#include <viam/sdk/common/proto_convert.hpp>
10#include <viam/sdk/spatialmath/geometry.hpp>
11
12namespace viam {
13namespace common {
14namespace v1 {
15
16class GeometriesInFrame;
17class Transform;
18class WorldState;
19
20} // namespace v1
21} // namespace common
22} // namespace viam
23
24namespace viam {
25namespace sdk {
26
33 public:
36 std::vector<GeometryConfig> geometries;
37
39 std::string reference_frame;
40
41 friend bool operator==(const geometries_in_frame&, const geometries_in_frame&) = default;
42 };
43
49 struct transform {
51 std::string reference_frame;
55 std::optional<GeometryConfig> physical_object;
56
57 friend bool operator==(const transform&, const transform&) = default;
58 };
59
60 WorldState() = default;
61
65 WorldState(std::vector<geometries_in_frame> obstacles, std::vector<transform> transforms);
66
69 const std::vector<geometries_in_frame>& obstacles() const;
70
73 // another, or to attach moving geometries to the frame system.
74 const std::vector<transform>& transforms() const;
75
76 friend bool operator==(const WorldState&, const WorldState&) = default;
77
78 private:
79 std::vector<geometries_in_frame> obstacles_;
80 std::vector<transform> transforms_;
81};
82
83namespace proto_convert_details {
84
85template <>
86struct to_proto_impl<WorldState::geometries_in_frame> {
87 void operator()(const WorldState::geometries_in_frame&, common::v1::GeometriesInFrame*) const;
88};
89
90template <>
91struct from_proto_impl<common::v1::GeometriesInFrame> {
92 WorldState::geometries_in_frame operator()(const common::v1::GeometriesInFrame*) const;
93};
94
95template <>
96struct to_proto_impl<WorldState::transform> {
97 void operator()(const WorldState::transform&, common::v1::Transform*) const;
98};
99
100template <>
101struct from_proto_impl<common::v1::Transform> {
102 WorldState::transform operator()(const common::v1::Transform*) const;
103};
104
105template <>
107 void operator()(const WorldState&, common::v1::WorldState*) const;
108};
109
110template <>
111struct from_proto_impl<common::v1::WorldState> {
112 WorldState operator()(const common::v1::WorldState*) const;
113};
114
115} // namespace proto_convert_details
116} // namespace sdk
117} // namespace viam
Describes the physical environment around a robot.
Definition world_state.hpp:32
WorldState(std::vector< geometries_in_frame > obstacles, std::vector< transform > transforms)
Constructs a WorldState with the given obstacles and transforms.
const std::vector< geometries_in_frame > & obstacles() const
A list of obstacles expressed as a geometry and the reference frame in which it was observed.
const std::vector< transform > & transforms() const
A list of Transforms, optionally with geometries. Used as supplemental transforms to transform a pose...
Holds a set of geometries observed from a particular reference frame.
Definition world_state.hpp:35
std::string reference_frame
The reference frame in which the geometries were observed.
Definition world_state.hpp:39
Represents a pose and two reference frames.
Definition world_state.hpp:49
pose_in_frame pose_in_observer_frame
The pose of this frame relative to the observer's frame.
Definition world_state.hpp:53
std::string reference_frame
The name of this reference frame.
Definition world_state.hpp:51
std::optional< GeometryConfig > physical_object
An optional geometry representing the physical object at this transform's location.
Definition world_state.hpp:55
Definition pose.hpp:39