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 <viam/sdk/common/pose.hpp>
10#include <viam/sdk/common/proto_convert.hpp>
11#include <viam/sdk/common/proto_value.hpp>
13#include <viam/sdk/resource/resource_api.hpp>
14#include <viam/sdk/services/service.hpp>
15
16namespace viam {
17
18namespace robot {
19namespace v1 {
20
21class FrameSystemConfig;
22
23} // namespace v1
24} // namespace robot
25
26namespace sdk {
27
29
40class FrameSystem : public Service {
41 public:
46 ProtoStruct kinematics;
47 friend bool operator==(const frame_system_config& lhs, const frame_system_config& rhs);
48 };
49
51 static const std::string kPublicName;
52
55 static Name public_name();
56
58 inline std::vector<frame_system_config> get_frame_system_config() {
59 return get_frame_system_config({});
60 }
61
64 virtual std::vector<frame_system_config> get_frame_system_config(
65 const std::vector<WorldState::transform>& additional_transforms) = 0;
66
69 inline pose_in_frame get_pose(const std::string& component_name) {
70 return get_pose(component_name, "world", {}, {});
71 }
72
78 const std::string& component_name,
79 const std::string& destination_frame,
80 const std::vector<WorldState::transform>& supplemental_transforms) {
81 return get_pose(component_name, destination_frame, supplemental_transforms, {});
82 }
83
90 const std::string& component_name,
91 const std::string& destination_frame,
92 const std::vector<WorldState::transform>& supplemental_transforms,
93 const ProtoStruct& extra) = 0;
94
99 const std::string& destination) {
100 return transform_pose(query, destination, {});
101 }
102
108 const pose_in_frame& query,
109 const std::string& destination,
110 const std::vector<WorldState::transform>& additional_transforms) = 0;
111
117 virtual std::vector<unsigned char> transform_pcd(const std::vector<unsigned char>& pcd,
118 const std::string& source,
119 const std::string& destination) = 0;
120
121 API api() const override;
122
123 protected:
124 explicit FrameSystem(std::string name);
125
126 explicit FrameSystem(const ResourceConfig& cfg);
127};
128
129template <>
131 static API api();
132};
133
134namespace proto_convert_details {
135
136template <>
137struct from_proto_impl<robot::v1::FrameSystemConfig> {
138 FrameSystem::frame_system_config operator()(const robot::v1::FrameSystemConfig*) const;
139};
140
141} // namespace proto_convert_details
142
143} // namespace sdk
144} // 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:40
std::vector< frame_system_config > get_frame_system_config()
Get the configuration of every frame in the frame system.
Definition framesystem.hpp:58
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:98
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:77
pose_in_frame get_pose(const std::string &component_name)
Get the pose of a component in the world reference frame.
Definition framesystem.hpp:69
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:51
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
Definition resource_api.hpp:46
One frame of the frame system, with the kinematics of the resource it belongs to.
Definition framesystem.hpp:44
Represents a pose and two reference frames.
Definition world_state.hpp:47
Definition pose.hpp:39
Defines WorldState.