xml_testdata_loader.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Pilz GmbH & Co. KG
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef XML_TESTDATA_LOADER_H
18 #define XML_TESTDATA_LOADER_H
19 
20 #include <string>
21 #include <vector>
22 #include <functional>
23 #include <map>
24 #include <memory>
25 
26 #include <boost/property_tree/ptree.hpp>
27 
29 
30 namespace pt = boost::property_tree;
32 {
33 
104 {
105 public:
106  XmlTestdataLoader(const std::string &path_filename);
107  XmlTestdataLoader(const std::string &path_filename,
108  const moveit::core::RobotModelConstPtr& robot_model);
110 
111 public:
112  virtual JointConfiguration getJoints(const std::string &pos_name,
113  const std::string &group_name) const override;
114 
115  virtual CartesianConfiguration getPose(const std::string &pos_name,
116  const std::string &group_name) const override;
117 
118  virtual PtpJoint getPtpJoint(const std::string& cmd_name) const override;
119  virtual PtpCart getPtpCart(const std::string& cmd_name) const override;
120  virtual PtpJointCart getPtpJointCart(const std::string& cmd_name) const override;
121 
122  virtual LinJoint getLinJoint(const std::string& cmd_name) const override;
123  virtual LinCart getLinCart(const std::string& cmd_name) const override;
124  virtual LinJointCart getLinJointCart(const std::string& cmd_name) const override;
125 
126  virtual CircCenterCart getCircCartCenterCart(const std::string &cmd_name) const override;
127  virtual CircInterimCart getCircCartInterimCart(const std::string &cmd_name) const override;
128  virtual CircJointCenterCart getCircJointCenterCart(const std::string &cmd_name) const override;
129  virtual CircJointInterimCart getCircJointInterimCart(const std::string &cmd_name) const override;
130 
131  virtual Sequence getSequence(const std::string &cmd_name) const override;
132 
133  virtual Gripper getGripper(const std::string &cmd_name) const override;
134 
135 private:
143  const pt::ptree::value_type &findNodeWithName(const boost::property_tree::ptree &tree,
144  const std::string &name,
145  const std::string &key,
146  const std::string &path = "") const;
147 
151  const pt::ptree::value_type &findCmd(const std::string &cmd_name,
152  const std::string& cmd_path,
153  const std::string &cmd_key) const;
154 
155  CartesianCenter getCartesianCenter(const std::string &cmd_name,
156  const std::string &planning_group) const;
157 
158  CartesianInterim getCartesianInterim(const std::string &cmd_name,
159  const std::string &planning_group) const;
160 
161 private:
162  JointConfiguration getJoints(const boost::property_tree::ptree& joints_tree,
163  const std::string &group_name) const;
164 
165 private:
169  inline static std::vector<double> strVec2doubleVec(std::vector<std::string> &strVec);
170 
171 public:
178  {
179  public:
180  virtual CmdVariant getCmd(const std::string& /*cmd_name*/) const = 0;
181  virtual ~AbstractCmdGetterAdapter() = default;
182  };
183 
184 private:
185  std::string path_filename_;
186  pt::ptree tree_ {};
187 
188  using AbstractCmdGetterUPtr = std::unique_ptr<AbstractCmdGetterAdapter>;
189 
195  std::map<std::string, AbstractCmdGetterUPtr> cmd_getter_funcs_;
196 
197 private:
198  const pt::ptree::value_type empty_value_type_ {};
199  const pt::ptree empty_tree_ {};
200 };
201 
202 std::vector<double> XmlTestdataLoader::strVec2doubleVec(std::vector<std::string> &strVec)
203 {
204  std::vector<double> vec;
205 
206  vec.resize(strVec.size());
207  std::transform(strVec.begin(), strVec.end(), vec.begin(), [](const std::string& val)
208  {
209  return std::stod(val);
210  });
211 
212  return vec;
213 }
214 
215 using XmlTestDataLoaderUPtr = std::unique_ptr<TestdataLoader>;
216 
217 }
218 
219 #endif // XML_TESTDATA_LOADER_H
static std::vector< double > strVec2doubleVec(std::vector< std::string > &strVec)
Converts string vector to double vector.
virtual CircInterimCart getCircCartInterimCart(const std::string &cmd_name) const override
std::map< std::string, AbstractCmdGetterUPtr > cmd_getter_funcs_
CartesianInterim getCartesianInterim(const std::string &cmd_name, const std::string &planning_group) const
virtual LinCart getLinCart(const std::string &cmd_name) const override
virtual CircCenterCart getCircCartCenterCart(const std::string &cmd_name) const override
Returns the command with the specified name from the test data.
std::unique_ptr< TestdataLoader > XmlTestDataLoaderUPtr
Data class storing all information regarding a Circ command.
Definition: circ.h:32
vec
virtual LinJoint getLinJoint(const std::string &cmd_name) const override
Returns the command with the specified name from the test data.
virtual PtpCart getPtpCart(const std::string &cmd_name) const override
virtual LinJointCart getLinJointCart(const std::string &cmd_name) const override
boost::variant< PtpJoint, PtpJointCart, PtpCart, LinJoint, LinCart, CircCenterCart, CircInterimCart, CircJointCenterCart, CircJointInterimCart, Gripper > CmdVariant
name
planning_group
Implements a test data loader which uses a xml file to store the test data.
Data class storing all information regarding a linear command.
Definition: lin.h:31
Abstract base class providing a GENERIC getter-function signature which can be used to load DIFFERENT...
Class to define a robot configuration in space with the help of joint values.
virtual JointConfiguration getJoints(const std::string &pos_name, const std::string &group_name) const override
virtual Sequence getSequence(const std::string &cmd_name) const override
Returns the command with the specified name from the test data.
const pt::ptree::value_type & findNodeWithName(const boost::property_tree::ptree &tree, const std::string &name, const std::string &key, const std::string &path="") const
Use this function to search for a node (like an pos or cmd) with a given name.
Data class storing all information regarding a Sequence command.
Definition: sequence.h:36
virtual CircJointCenterCart getCircJointCenterCart(const std::string &cmd_name) const override
virtual CircJointInterimCart getCircJointInterimCart(const std::string &cmd_name) const override
Abstract base class describing the interface to access test data like robot poses and robot commands...
const pt::ptree::value_type & findCmd(const std::string &cmd_name, const std::string &cmd_path, const std::string &cmd_key) const
Use this function to search for a cmd-node with a given name.
Class to define a point on the circle on which the robot is supposed to move via circ command...
Definition: interim.h:30
virtual CartesianConfiguration getPose(const std::string &pos_name, const std::string &group_name) const override
Class to define a robot configuration in space with the help of cartesian coordinates.
Class to define the center point of the circle on which the robot is supposed to move via circ comman...
Definition: center.h:30
virtual Gripper getGripper(const std::string &cmd_name) const override
Returns the command with the specified name from the test data.
virtual PtpJointCart getPtpJointCart(const std::string &cmd_name) const override
CartesianCenter getCartesianCenter(const std::string &cmd_name, const std::string &planning_group) const
std::unique_ptr< AbstractCmdGetterAdapter > AbstractCmdGetterUPtr
virtual PtpJoint getPtpJoint(const std::string &cmd_name) const override
Returns the command with the specified name from the test data.


pilz_industrial_motion_testutils
Author(s):
autogenerated on Mon Apr 6 2020 03:17:28