Loading...
Searching...
No Matches
yaml.h
Go to the documentation of this file.
1/*
2 * Copyright 2012-2020 CNRS-UM LIRMM, CNRS-AIST JRL
3 */
4
5#pragma once
6
7#include <RBDyn/MultiBody.h>
11
12namespace YAML
13{
14class Node;
15}
16
17namespace rbd
18{
19
20namespace parsers
21{
22
24{
25public:
26 RBDynFromYAML(const std::string & input,
27 ParserInput input_type = ParserInput::File,
28 bool fixed = true,
29 const std::vector<std::string> & filtered_links = {},
30 bool transform_inertia = true,
31 const std::string & base_link = "",
32 bool with_virtual_links = true,
33 const std::string & spherical_suffix = "_spherical",
34 bool remove_filtered_links = true);
35
37 {
38 return res;
39 }
40
41 operator std::tuple<rbd::MultiBody &, rbd::MultiBodyConfig &, rbd::MultiBodyGraph &>()
42 {
43 return std::tie(res.mb, res.mbc, res.mbg);
44 }
45
46private:
47 ParserResult res;
48 bool verbose_;
49 bool transform_inertia_;
50 bool angles_in_degrees_;
51 std::string base_link_;
52 size_t link_idx_;
53 size_t joint_idx_;
54 std::map<std::string, rbd::Joint::Type> joint_types_;
55 std::vector<std::string> filtered_links_;
56 bool remove_filtered_links_;
57 bool with_virtual_links_;
58 const std::string & spherical_suffix_;
59 std::unordered_map<std::string, Material> materials_;
60 std::vector<std::string> fixed_links_;
61 std::vector<std::string> removed_links_;
62
63 Eigen::Matrix3d makeInertia(double ixx, double iyy, double izz, double iyz, double ixz, double ixy);
64
65 Eigen::Matrix3d MatrixFromRPY(double r, double p, double y);
66
67 void parseFrame(const YAML::Node & frame, const std::string & name, Eigen::Vector3d & xyz, Eigen::Vector3d & rpy);
68
69 void parseInertia(const YAML::Node & inertia, Eigen::Matrix3d & inertia_mat);
70
71 void parseInertial(const YAML::Node & inertial,
72 const std::string & name,
73 double & mass,
74 Eigen::Vector3d & xyz,
75 Eigen::Vector3d & rpy,
76 Eigen::Matrix3d & inertia);
77
78 bool parseGeometry(const YAML::Node & geometry, Geometry & data);
79
80 void parseVisuals(const YAML::Node & visuals,
81 std::map<std::string, std::vector<Visual>> & data,
82 const std::string & name);
83
85 void parseMaterial(const YAML::Node & material);
86
91 void parseMaterial(const YAML::Node & material, Material & out, bool cache = true);
92
93 void parseLink(const YAML::Node & link);
94
95 bool parseJointType(const YAML::Node & type,
96 const std::string & name,
97 rbd::Joint::Type & joint_type,
98 std::string & type_name,
99 bool force_fixed);
100
101 void parseJointAxis(const YAML::Node & axis, const std::string & name, Eigen::Vector3d & joint_axis);
102
103 void parseJointLimits(const YAML::Node & limits,
104 const std::string & name,
105 const rbd::Joint & joint,
106 bool is_continuous);
107
108 void parseJoint(const YAML::Node & joint);
109};
110
111RBDYN_PARSERS_DLLAPI ParserResult from_yaml(const std::string & content,
112 bool fixed = true,
113 const std::vector<std::string> & filteredLinksIn = {},
114 bool transformInertia = true,
115 const std::string & baseLinkIn = "",
116 bool withVirtualLinks = true,
117 const std::string & sphericalSuffix = "_spherical");
118
120 bool fixed = true,
121 const std::vector<std::string> & filteredLinksIn = {},
122 bool transformInertia = true,
123 const std::string & baseLinkIn = "",
124 bool withVirtualLinks = true,
125 const std::string & sphericalSuffix = "_spherical");
126
127RBDYN_PARSERS_DLLAPI ParserResult from_yaml(const std::string & content, const ParserParameters & params);
128
129RBDYN_PARSERS_DLLAPI ParserResult from_yaml_file(const std::string & file_path, const ParserParameters & params);
130
132
133} // namespace parsers
134
135} // namespace rbd
#define RBDYN_PARSERS_DLLAPI
Definition api.h:43
Definition Joint.h:36
Type
Joint type.
Definition Joint.h:40
Definition yaml.h:24
ParserResult & result()
Definition yaml.h:36
RBDynFromYAML(const std::string &input, ParserInput input_type=ParserInput::File, bool fixed=true, const std::vector< std::string > &filtered_links={}, bool transform_inertia=true, const std::string &base_link="", bool with_virtual_links=true, const std::string &spherical_suffix="_spherical", bool remove_filtered_links=true)
Definition yaml.h:13
RBDYN_PARSERS_DLLAPI ParserResult from_yaml(const std::string &content, bool fixed=true, const std::vector< std::string > &filteredLinksIn={}, bool transformInertia=true, const std::string &baseLinkIn="", bool withVirtualLinks=true, const std::string &sphericalSuffix="_spherical")
RBDYN_PARSERS_DLLAPI ParserResult from_yaml_file(const std::string &file_path, bool fixed=true, const std::vector< std::string > &filteredLinksIn={}, bool transformInertia=true, const std::string &baseLinkIn="", bool withVirtualLinks=true, const std::string &sphericalSuffix="_spherical")
ParserInput
Definition common.h:27
RBDYN_PARSERS_DLLAPI std::string to_yaml(const ParserResult &res)
Definition common.h:21
Definition common.h:42
Definition common.h:106
Definition common.h:142
Definition common.h:229