jointconfiguration.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 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 JOINTCONFIGURATION_H
18 #define JOINTCONFIGURATION_H
19 
20 #include <string>
21 #include <vector>
22 #include <functional>
23 #include <stdexcept>
24 
25 #include <sensor_msgs/JointState.h>
28 
29 #include "robotconfiguration.h"
30 
32 {
33 
34 class JointConfigurationException: public std::runtime_error
35 {
36  public:
37  JointConfigurationException(const std::string error_desc)
38  : std::runtime_error(error_desc)
39  {}
40 };
41 
42 using CreateJointNameFunc = std::function<std::string(const size_t&)>;
43 
49 {
50 public:
52 
53  JointConfiguration(const std::string& group_name,
54  const std::vector<double>& config,
55  CreateJointNameFunc&& create_joint_name_func);
56 
57  JointConfiguration(const std::string& group_name,
58  const std::vector<double>& config,
59  const moveit::core::RobotModelConstPtr& robot_model);
60 
61 
62 public:
63  void setJoint(const size_t index, const double value);
64  double getJoint(const size_t index) const;
65  const std::vector<double> getJoints() const;
66 
67  size_t size() const;
68 
69  moveit_msgs::Constraints toGoalConstraints() const override;
70  moveit_msgs::RobotState toMoveitMsgsRobotState() const override;
71 
72  sensor_msgs::JointState toSensorMsg() const;
73 
74  robot_state::RobotState toRobotState() const;
75 
76  void setCreateJointNameFunc(CreateJointNameFunc create_joint_name_func);
77 
78 private:
79  moveit_msgs::RobotState toMoveitMsgsRobotStateWithoutModel() const;
80  moveit_msgs::RobotState toMoveitMsgsRobotStateWithModel() const;
81 
82  moveit_msgs::Constraints toGoalConstraintsWithoutModel() const;
83  moveit_msgs::Constraints toGoalConstraintsWithModel() const;
84 
85 private:
87  std::vector<double> joints_;
88 
90 };
91 
92 std::ostream& operator<<(std::ostream&, const JointConfiguration&);
93 
94 inline moveit_msgs::Constraints JointConfiguration::toGoalConstraints() const
95 {
96  return robot_model_? toGoalConstraintsWithModel() :
97  toGoalConstraintsWithoutModel();
98 }
99 
100 inline moveit_msgs::RobotState JointConfiguration::toMoveitMsgsRobotState() const
101 {
102  return robot_model_? toMoveitMsgsRobotStateWithModel() :
103  toMoveitMsgsRobotStateWithoutModel();
104 }
105 
106 inline void JointConfiguration::setJoint(const size_t index, const double value)
107 {
108  joints_.at(index) = value;
109 }
110 
111 inline double JointConfiguration::getJoint(const size_t index) const
112 {
113  return joints_.at(index);
114 }
115 
116 inline const std::vector<double> JointConfiguration::getJoints() const
117 {
118  return joints_;
119 }
120 
121 inline size_t JointConfiguration::size() const
122 {
123  return joints_.size();
124 }
125 
127 {
128  create_joint_name_func_ = create_joint_name_func;
129 }
130 
131 }
132 
133 #endif // JOINTCONFIGURATION_H
moveit_msgs::Constraints toGoalConstraints() const override
std::vector< double > joints_
Joint positions.
std::size_t size(custom_string const &s)
std::function< std::string(const size_t &)> CreateJointNameFunc
Class to define a robot configuration in space with the help of joint values.
void setCreateJointNameFunc(CreateJointNameFunc create_joint_name_func)
const std::vector< double > getJoints() const
unsigned int index
void setJoint(const size_t index, const double value)
std::ostream & operator<<(std::ostream &, const CartesianConfiguration &)
Class to define robot configuration in space.
config
moveit_msgs::RobotState toMoveitMsgsRobotState() const override
int value


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