Viam C++ SDK current
Loading...
Searching...
No Matches
framesystem.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <optional>
7#include <string>
8#include <vector>
9
11#include <viam/sdk/common/pose.hpp>
12#include <viam/sdk/common/proto_convert.hpp>
13#include <viam/sdk/common/proto_value.hpp>
15#include <viam/sdk/resource/resource_api.hpp>
16#include <viam/sdk/services/service.hpp>
17
18namespace viam {
19
20namespace robot {
21namespace v1 {
22
23class FrameSystemConfig;
24
25} // namespace v1
26} // namespace robot
27
28namespace sdk {
29
31
42class FrameSystem : public Service {
43 public:
48
51 ProtoStruct kinematics;
52
54 std::optional<KinematicModel> model;
55
56 friend bool operator==(const frame_system_config& lhs, const frame_system_config& rhs);
57 };
58
60 static const std::string kPublicName;
61
64 static Name public_name();
65
67 inline std::vector<frame_system_config> get_frame_system_config() {
68 return get_frame_system_config({});
69 }
70
73 virtual std::vector<frame_system_config> get_frame_system_config(
74 const std::vector<WorldState::transform>& additional_transforms) = 0;
75
78 inline pose_in_frame get_pose(const std::string& component_name) {
79 return get_pose(component_name, "world", {}, {});
80 }
81
87 const std::string& component_name,
88 const std::string& destination_frame,
89 const std::vector<WorldState::transform>& supplemental_transforms) {
90 return get_pose(component_name, destination_frame, supplemental_transforms, {});
91 }
92
99 const std::string& component_name,
100 const std::string& destination_frame,
101 const std::vector<WorldState::transform>& supplemental_transforms,
102 const ProtoStruct& extra) = 0;
103
108 const std::string& destination) {
109 return transform_pose(query, destination, {});
110 }
111
117 const pose_in_frame& query,
118 const std::string& destination,
119 const std::vector<WorldState::transform>& additional_transforms) = 0;
120
126 virtual std::vector<unsigned char> transform_pcd(const std::vector<unsigned char>& pcd,
127 const std::string& source,
128 const std::string& destination) = 0;
129
130 API api() const override;
131
132 protected:
133 explicit FrameSystem(std::string name);
134
135 explicit FrameSystem(const ResourceConfig& cfg);
136};
137
138template <>
140 static API api();
141};
142
143namespace proto_convert_details {
144
145template <>
146struct from_proto_impl<robot::v1::FrameSystemConfig> {
147 FrameSystem::frame_system_config operator()(const robot::v1::FrameSystemConfig*) const;
148};
149
150} // namespace proto_convert_details
151
152} // namespace sdk
153} // 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:42
std::vector< frame_system_config > get_frame_system_config()
Get the configuration of every frame in the frame system.
Definition framesystem.hpp:67
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:107
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:86
pose_in_frame get_pose(const std::string &component_name)
Get the pose of a component in the world reference frame.
Definition framesystem.hpp:78
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:60
A name for specific instances of resources.
Definition resource_api.hpp:61
Definition resource.hpp:42
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:46
std::optional< KinematicModel > model
The resource's kinematic model, absent for resources without kinematics.
Definition framesystem.hpp:54
ProtoStruct kinematics
The resource's kinematics as a raw file, when served by an older viam-server.
Definition framesystem.hpp:51
Represents a pose and two reference frames.
Definition world_state.hpp:49
Definition pose.hpp:39
Defines WorldState.