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 <boost/optional/optional.hpp>
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
47 struct transform {
49 std::string reference_frame;
53 boost::optional<GeometryConfig> physical_object;
54 };
55
56 WorldState() = default;
57
61 WorldState(std::vector<geometries_in_frame> obstacles, std::vector<transform> transforms);
62
65 const std::vector<geometries_in_frame>& obstacles() const;
66
69 // another, or to attach moving geometries to the frame system.
70 const std::vector<transform>& transforms() const;
71
72 friend bool operator==(const WorldState& lhs, const WorldState& rhs);
73 friend bool operator==(const geometries_in_frame& lhs, const geometries_in_frame& rhs);
74 friend bool operator==(const transform& lhs, const transform& rhs);
75
76 private:
77 std::vector<geometries_in_frame> obstacles_;
78 std::vector<transform> transforms_;
79};
80
81namespace proto_convert_details {
82
83template <>
84struct to_proto_impl<WorldState::geometries_in_frame> {
85 void operator()(const WorldState::geometries_in_frame&, common::v1::GeometriesInFrame*) const;
86};
87
88template <>
89struct from_proto_impl<common::v1::GeometriesInFrame> {
90 WorldState::geometries_in_frame operator()(const common::v1::GeometriesInFrame*) const;
91};
92
93template <>
94struct to_proto_impl<WorldState::transform> {
95 void operator()(const WorldState::transform&, common::v1::Transform*) const;
96};
97
98template <>
99struct from_proto_impl<common::v1::Transform> {
100 WorldState::transform operator()(const common::v1::Transform*) const;
101};
102
103template <>
105 void operator()(const WorldState&, common::v1::WorldState*) const;
106};
107
108template <>
109struct from_proto_impl<common::v1::WorldState> {
110 WorldState operator()(const common::v1::WorldState*) const;
111};
112
113} // namespace proto_convert_details
114} // namespace sdk
115} // 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:47
pose_in_frame pose_in_observer_frame
The pose of this frame relative to the observer's frame.
Definition world_state.hpp:51
std::string reference_frame
The name of this reference frame.
Definition world_state.hpp:49
boost::optional< GeometryConfig > physical_object
An optional geometry representing the physical object at this transform's location.
Definition world_state.hpp:53
Definition pose.hpp:39