Viam C++ SDK current
Loading...
Searching...
No Matches
framesystem.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <string>
7#include <vector>
8
9#include <boost/optional/optional.hpp>
10
12#include <viam/sdk/common/pose.hpp>
13#include <viam/sdk/common/proto_convert.hpp>
14#include <viam/sdk/common/proto_value.hpp>
16#include <viam/sdk/resource/resource_api.hpp>
17#include <viam/sdk/services/service.hpp>
18
19namespace viam {
20
21namespace robot {
22namespace v1 {
23
24class FrameSystemConfig;
25
26} // namespace v1
27} // namespace robot
28
29namespace sdk {
30
32
43class FrameSystem : public Service {
44 public:
49
52 ProtoStruct kinematics;
53
55 boost::optional<KinematicModel> model;
56
57 friend bool operator==(const frame_system_config& lhs, const frame_system_config& rhs);
58 };
59
61 static const std::string kPublicName;
62
65 static Name public_name();
66
68 inline std::vector<frame_system_config> get_frame_system_config() {
69 return get_frame_system_config({});
70 }
71
74 virtual std::vector<frame_system_config> get_frame_system_config(
75 const std::vector<WorldState::transform>& additional_transforms) = 0;
76
79 inline pose_in_frame get_pose(const std::string& component_name) {
80 return get_pose(component_name, "world", {}, {});
81 }
82
88 const std::string& component_name,
89 const std::string& destination_frame,
90 const std::vector<WorldState::transform>& supplemental_transforms) {
91 return get_pose(component_name, destination_frame, supplemental_transforms, {});
92 }
93
100 const std::string& component_name,
101 const std::string& destination_frame,
102 const std::vector<WorldState::transform>& supplemental_transforms,
103 const ProtoStruct& extra) = 0;
104
109 const std::string& destination) {
110 return transform_pose(query, destination, {});
111 }
112
118 const pose_in_frame& query,
119 const std::string& destination,
120 const std::vector<WorldState::transform>& additional_transforms) = 0;
121
127 virtual std::vector<unsigned char> transform_pcd(const std::vector<unsigned char>& pcd,
128 const std::string& source,
129 const std::string& destination) = 0;
130
131 API api() const override;
132
133 protected:
134 explicit FrameSystem(std::string name);
135
136 explicit FrameSystem(const ResourceConfig& cfg);
137};
138
139template <>
141 static API api();
142};
143
144namespace proto_convert_details {
145
146template <>
147struct from_proto_impl<robot::v1::FrameSystemConfig> {
148 FrameSystem::frame_system_config operator()(const robot::v1::FrameSystemConfig*) const;
149};
150
151} // namespace proto_convert_details
152
153} // namespace sdk
154} // namespace viam
Definition resource_api.hpp:21
The machine's frame system: the tree of reference frames viam-server builds from the frame config of ...
Definition framesystem.hpp:43
std::vector< frame_system_config > get_frame_system_config()
Get the configuration of every frame in the frame system.
Definition framesystem.hpp:68
virtual pose_in_frame get_pose(const std::string &component_name, const std::string &destination_frame, const std::vector< WorldState::transform > &supplemental_transforms, const ProtoStruct &extra)=0
Get the pose of a component in the desired reference frame.
virtual std::vector< frame_system_config > get_frame_system_config(const std::vector< WorldState::transform > &additional_transforms)=0
Get the configuration of every frame in the frame system.
pose_in_frame transform_pose(const pose_in_frame &query, const std::string &destination)
Express a pose in a different reference frame.
Definition framesystem.hpp:108
pose_in_frame get_pose(const std::string &component_name, const std::string &destination_frame, const std::vector< WorldState::transform > &supplemental_transforms)
Get the pose of a component in the desired reference frame.
Definition framesystem.hpp:87
pose_in_frame get_pose(const std::string &component_name)
Get the pose of a component in the world reference frame.
Definition framesystem.hpp:79
virtual std::vector< unsigned char > transform_pcd(const std::vector< unsigned char > &pcd, const std::string &source, const std::string &destination)=0
Express a point cloud in a different reference frame.
static Name public_name()
The full resource name of the machine's frame system. Its short name is kPublicName.
virtual pose_in_frame transform_pose(const pose_in_frame &query, const std::string &destination, const std::vector< WorldState::transform > &additional_transforms)=0
Express a pose in a different reference frame.
API api() const override
Returns the API associated with a particular resource.
static const std::string kPublicName
The reserved name viam-server publishes the machine's frame system under.
Definition framesystem.hpp:61
A name for specific instances of resources.
Definition resource_api.hpp:61
Definition resource.hpp:43
virtual std::string name() const
Return the resource's name.
Definition service.hpp:10
Kinematics data types shared by the components that serve GetKinematics.
Definition resource_api.hpp:46
One frame of the frame system, with the kinematics of the resource it belongs to.
Definition framesystem.hpp:47
ProtoStruct kinematics
The resource's kinematics as a raw file, when served by an older viam-server.
Definition framesystem.hpp:52
boost::optional< KinematicModel > model
The resource's kinematic model, absent for resources without kinematics.
Definition framesystem.hpp:55
Represents a pose and two reference frames.
Definition world_state.hpp:47
Definition pose.hpp:39
Defines WorldState.