WebCFace 2.5.2
Web-based Communication Framework & Dashboard-like UI
Loading...
Searching...
No Matches
robot_link.h
Go to the documentation of this file.
1#pragma once
4#include "webcface/geometry.h"
6#ifdef WEBCFACE_MESON
7#include "webcface-config.h"
8#else
9#include "webcface/common/webcface-config.h"
10#endif
11
13namespace internal {
14struct TemporalRobotJointData;
15struct RobotLinkData;
16} // namespace internal
17
18enum class RobotJointType {
20 fixed = 1,
21 rotational = 2,
22 prismatic = 3,
23};
24class RobotLink;
37 std::unique_ptr<internal::TemporalRobotJointData> temp_data;
42 std::shared_ptr<internal::RobotLinkData> msg_data;
43
44 public:
45 friend class RobotLink;
46
47 RobotJoint();
48 explicit RobotJoint(
49 const std::shared_ptr<internal::RobotLinkData> &msg_data);
50 RobotJoint(const SharedString &name, const SharedString &parent_name,
51 RobotJointType type, const Transform &origin, double angle);
53 RobotJoint(const RobotJoint &other);
54 RobotJoint &operator=(const RobotJoint &other);
55
60 const std::string &name() const;
65 const std::wstring &nameW() const;
70 std::optional<RobotLink> parent() const;
75 RobotJointType type() const;
80 Transform origin() const;
85 double angle() const;
86};
87
88inline namespace robot_joints {
96inline RobotJoint fixedAbsolute(const Transform &origin) {
97 return RobotJoint{nullptr, nullptr, RobotJointType::fixed_absolute, origin,
98 0};
99}
107inline RobotJoint fixedAbsolute(const Point &origin) {
108 return fixedAbsolute(Transform{origin, {}});
109}
116inline RobotJoint fixedJoint(std::string_view parent_name,
117 const Transform &origin) {
118 return RobotJoint{nullptr, SharedString::encode(parent_name),
119 RobotJointType::fixed, origin, 0};
120}
128inline RobotJoint fixedJoint(std::wstring_view parent_name,
129 const Transform &origin) {
130 return RobotJoint{nullptr, SharedString::encode(parent_name),
131 RobotJointType::fixed, origin, 0};
132}
138inline RobotJoint fixedJoint(std::string_view parent_name,
139 const Point &origin) {
140 return fixedJoint(parent_name, Transform{origin, {}});
141}
148inline RobotJoint fixedJoint(std::wstring_view parent_name,
149 const Point &origin) {
150 return fixedJoint(parent_name, Transform{origin, {}});
151}
162inline RobotJoint rotationalJoint(std::string_view name,
163 std::string_view parent_name,
164 const Transform &origin, double angle = 0) {
165 return RobotJoint{SharedString::encode(name),
166 SharedString::encode(parent_name),
167 RobotJointType::rotational, origin, angle};
168}
180inline RobotJoint rotationalJoint(std::wstring_view name,
181 std::wstring_view parent_name,
182 const Transform &origin, double angle = 0) {
183 return RobotJoint{SharedString::encode(name),
184 SharedString::encode(parent_name),
185 RobotJointType::rotational, origin, angle};
186}
197inline RobotJoint prismaticJoint(std::string_view name,
198 std::string_view parent_name,
199 const Transform &origin, double angle = 0) {
200 return RobotJoint{SharedString::encode(name),
201 SharedString::encode(parent_name),
202 RobotJointType::prismatic, origin, angle};
203}
215inline RobotJoint prismaticJoint(std::wstring_view name,
216 std::wstring_view parent_name,
217 const Transform &origin, double angle = 0) {
218 return RobotJoint{SharedString::encode(name),
219 SharedString::encode(parent_name),
220 RobotJointType::prismatic, origin, angle};
221}
222} // namespace robot_joints
223
224namespace RobotJoints = robot_joints; // 〜ver1.11
225
235 std::shared_ptr<internal::RobotLinkData> msg_data;
236
237 public:
238 RobotLink();
239 explicit RobotLink(
240 const std::shared_ptr<internal::RobotLinkData> &msg_data);
242 RobotLink(const SharedString &name, const RobotJoint &joint,
243 const Geometry &geometry, ViewColor color);
244
250 std::shared_ptr<internal::RobotLinkData>
251 lockJoints(const std::vector<SharedString> &link_names) const;
252
260 RobotLink(std::string_view name, const RobotJoint &joint,
261 const Geometry &geometry, ViewColor color = ViewColor::inherit)
262 : RobotLink(SharedString::encode(name), joint, geometry, color) {}
263
272 RobotLink(std::wstring_view name, const RobotJoint &joint,
273 const Geometry &geometry, ViewColor color = ViewColor::inherit)
274 : RobotLink(SharedString::encode(name), joint, geometry, color) {}
283 RobotLink(std::string_view name, const Geometry &geometry,
284 ViewColor color = ViewColor::inherit)
285 : RobotLink(name, fixedAbsolute({0, 0, 0}), geometry, color) {}
295 RobotLink(std::wstring_view name, const Geometry &geometry,
296 ViewColor color = ViewColor::inherit)
297 : RobotLink(name, fixedAbsolute({0, 0, 0}), geometry, color) {}
298
303 const std::string &name() const;
308 const std::wstring &nameW() const;
313 RobotJoint joint() const;
318 std::optional<Geometry> geometry() const;
323 ViewColor color() const;
324};
3次元 or 2次元の座標を表すクラス。
Definition transform.h:23
modelの関節1つを表すクラス
Definition robot_link.h:32
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:69
3次元の平行移動と回転
Definition transform.h:615
RobotJoint prismaticJoint(std::string_view name, std::string_view parent_name, const Transform &origin, double angle=0)
直動関節
Definition robot_link.h:197
RobotJoint fixedAbsolute(const Transform &origin)
親リンクをもたず座標を定義する
Definition robot_link.h:96
RobotJoint rotationalJoint(std::string_view name, std::string_view parent_name, const Transform &origin, double angle=0)
回転関節
Definition robot_link.h:162
RobotJoint fixedJoint(std::string_view parent_name, const Transform &origin)
固定された関節
Definition robot_link.h:116
ViewColor
Definition component_view.h:40
RobotJointType
Definition robot_link.h:18
Definition geometry.h:26
#define WEBCFACE_DLL
Definition webcface-config.h:60
#define WEBCFACE_NS_END
Definition webcface-config.h:104
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:103