jointconfiguration.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2019 Pilz GmbH & Co. KG
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Pilz GmbH & Co. KG nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef JOINTCONFIGURATION_H
36 #define JOINTCONFIGURATION_H
37 
38 #include <string>
39 #include <utility>
40 #include <vector>
41 #include <functional>
42 #include <stdexcept>
43 
44 #include <sensor_msgs/JointState.h>
47 
48 #include "robotconfiguration.h"
49 
51 {
52 class JointConfigurationException : public std::runtime_error
53 {
54 public:
55  JointConfigurationException(const std::string& error_desc) : std::runtime_error(error_desc)
56  {
57  }
58 };
59 
60 using CreateJointNameFunc = std::function<std::string(const size_t&)>;
61 
66 class JointConfiguration : public RobotConfiguration
67 {
68 public:
70 
71  JointConfiguration(const std::string& group_name, const std::vector<double>& config,
72  CreateJointNameFunc&& create_joint_name_func);
73 
74  JointConfiguration(const std::string& group_name, const std::vector<double>& config,
75  const moveit::core::RobotModelConstPtr& robot_model);
76 
77 public:
78  void setJoint(const size_t index, const double value);
79  double getJoint(const size_t index) const;
80  const std::vector<double> getJoints() const;
81 
82  size_t size() const;
83 
84  moveit_msgs::Constraints toGoalConstraints() const override;
85  moveit_msgs::RobotState toMoveitMsgsRobotState() const override;
86 
87  sensor_msgs::JointState toSensorMsg() const;
88 
89  robot_state::RobotState toRobotState() const;
90 
91  void setCreateJointNameFunc(CreateJointNameFunc create_joint_name_func);
92 
93 private:
94  moveit_msgs::RobotState toMoveitMsgsRobotStateWithoutModel() const;
95  moveit_msgs::RobotState toMoveitMsgsRobotStateWithModel() const;
96 
97  moveit_msgs::Constraints toGoalConstraintsWithoutModel() const;
98  moveit_msgs::Constraints toGoalConstraintsWithModel() const;
99 
100 private:
102  std::vector<double> joints_;
103 
105 };
106 
107 std::ostream& operator<<(std::ostream& /*os*/, const JointConfiguration& /*obj*/);
108 
109 inline moveit_msgs::Constraints JointConfiguration::toGoalConstraints() const
110 {
112 }
113 
114 inline moveit_msgs::RobotState JointConfiguration::toMoveitMsgsRobotState() const
115 {
117 }
118 
119 inline void JointConfiguration::setJoint(const size_t index, const double value)
120 {
121  joints_.at(index) = value;
122 }
123 
124 inline double JointConfiguration::getJoint(const size_t index) const
125 {
126  return joints_.at(index);
127 }
128 
129 inline const std::vector<double> JointConfiguration::getJoints() const
130 {
131  return joints_;
132 }
133 
134 inline size_t JointConfiguration::size() const
135 {
136  return joints_.size();
137 }
138 
139 inline void JointConfiguration::setCreateJointNameFunc(CreateJointNameFunc create_joint_name_func)
140 {
141  create_joint_name_func_ = std::move(create_joint_name_func);
142 }
143 } // namespace pilz_industrial_motion_planner_testutils
144 
145 #endif // JOINTCONFIGURATION_H
pilz_industrial_motion_planner_testutils::JointConfiguration::setCreateJointNameFunc
void setCreateJointNameFunc(CreateJointNameFunc create_joint_name_func)
Definition: jointconfiguration.h:171
pilz_industrial_motion_planner_testutils::JointConfiguration::getJoint
double getJoint(const size_t index) const
Definition: jointconfiguration.h:156
pilz_industrial_motion_planner_testutils::JointConfigurationException::JointConfigurationException
JointConfigurationException(const std::string &error_desc)
Definition: jointconfiguration.h:119
robot_state.h
robotconfiguration.h
pilz_industrial_motion_planner_testutils::JointConfiguration::setJoint
void setJoint(const size_t index, const double value)
Definition: jointconfiguration.h:151
pilz_industrial_motion_planner_testutils::JointConfiguration::toSensorMsg
sensor_msgs::JointState toSensorMsg() const
Definition: jointconfiguration.cpp:160
pilz_industrial_motion_planner_testutils::JointConfiguration::JointConfiguration
JointConfiguration()
Definition: jointconfiguration.cpp:73
pilz_industrial_motion_planner_testutils::JointConfiguration::size
size_t size() const
Definition: jointconfiguration.h:166
pilz_industrial_motion_planner_testutils
Definition: basecmd.h:42
pilz_industrial_motion_planner_testutils::RobotConfiguration::robot_model_
moveit::core::RobotModelConstPtr robot_model_
Definition: robotconfiguration.h:132
pilz_industrial_motion_planner_testutils::operator<<
std::ostream & operator<<(std::ostream &, const CartesianConfiguration &)
Definition: cartesianconfiguration.cpp:157
value
float value
pilz_industrial_motion_planner_testutils::JointConfiguration::toGoalConstraints
moveit_msgs::Constraints toGoalConstraints() const override
Definition: jointconfiguration.h:141
pilz_industrial_motion_planner_testutils::JointConfiguration::toRobotState
robot_state::RobotState toRobotState() const
Definition: jointconfiguration.cpp:139
pilz_industrial_motion_planner_testutils::JointConfiguration::toGoalConstraintsWithoutModel
moveit_msgs::Constraints toGoalConstraintsWithoutModel() const
Definition: jointconfiguration.cpp:89
std
pilz_industrial_motion_planner_testutils::JointConfiguration::joints_
std::vector< double > joints_
Joint positions.
Definition: jointconfiguration.h:134
index
unsigned int index
conversions.h
pilz_industrial_motion_planner_testutils::JointConfiguration
Class to define a robot configuration in space with the help of joint values.
Definition: jointconfiguration.h:98
pilz_industrial_motion_planner_testutils::CreateJointNameFunc
std::function< std::string(const size_t &)> CreateJointNameFunc
Definition: jointconfiguration.h:92
pilz_industrial_motion_planner_testutils::JointConfiguration::create_joint_name_func_
CreateJointNameFunc create_joint_name_func_
Definition: jointconfiguration.h:136
pilz_industrial_motion_planner_testutils::JointConfiguration::getJoints
const std::vector< double > getJoints() const
Definition: jointconfiguration.h:161
pilz_industrial_motion_planner_testutils::JointConfiguration::toMoveitMsgsRobotStateWithModel
moveit_msgs::RobotState toMoveitMsgsRobotStateWithModel() const
Definition: jointconfiguration.cpp:152
pilz_industrial_motion_planner_testutils::JointConfiguration::toGoalConstraintsWithModel
moveit_msgs::Constraints toGoalConstraintsWithModel() const
Definition: jointconfiguration.cpp:109
pilz_industrial_motion_planner_testutils::JointConfiguration::toMoveitMsgsRobotStateWithoutModel
moveit_msgs::RobotState toMoveitMsgsRobotStateWithoutModel() const
Definition: jointconfiguration.cpp:123
pilz_industrial_motion_planner_testutils::JointConfiguration::toMoveitMsgsRobotState
moveit_msgs::RobotState toMoveitMsgsRobotState() const override
Definition: jointconfiguration.h:146


pilz_industrial_motion_planner_testutils
Author(s):
autogenerated on Sat May 3 2025 02:28:27