1 #ifndef _H_PLAY_MOTION_BUILDER_MOTION_MODEL 2 #define _H_PLAY_MOTION_BUILDER_MOTION_MODEL 5 #include <sensor_msgs/JointState.h> 7 #include <unordered_map> 9 #include <yaml-cpp/yaml.h> 76 : lower_limit_(lower_limit), upper_limit_(upper_limit)
82 return lower_limit_ <= position && upper_limit_ >= position;
94 : joint_name_(joint_name), position_(position)
107 void addPosition(
const std::string& name,
double position);
108 double getJointPosition(
const std::string& joint)
const;
109 void cleanUnused(
const std::map<std::string, bool>& used_joints);
110 PrintPoint print(
double basetime,
double downshift,
const std::vector<std::string>& names)
const;
111 PrintMotion print(
const std::vector<std::string>& names)
const;
115 return time_increment_;
119 time_increment_ = time_increment;
143 Motion(
const std::string& robot_description,
const std::string& robot_description_semantic,
144 const std::vector<std::string>& extra_joints);
146 const std::string& robot_description_semantic,
147 const std::vector<std::string>& extra_joints);
149 void setMotionGroups(
const std::string& robot_description,
150 const std::string& robot_description_semantic);
152 void addKeyFrame(
const sensor_msgs::JointStateConstPtr& msg,
float time_increment = DEFAULT_TIME);
153 void updateKeyFrame(
const sensor_msgs::JointStateConstPtr& msg,
int frame);
154 void addJointModel(
const std::string& joint_name,
const JointModel& joint_model);
155 void changeTime(
int frame,
float time_increment);
156 double changeJoint(
int frame,
const std::string& joint_name,
double position);
157 void removeKeyFrame(
int frame);
158 void copyFrame(
int frame,
int new_frame_pos = -1);
159 void loadFrame(
int frame)
const;
160 void loadYAML(
double downshift)
const;
161 void extendFrames(
const sensor_msgs::JointStateConstPtr& msg);
164 const std::string& description,
double downshift = 1.0)
const;
166 void removeAllKeyFrames();
167 void addJointToGroup(
const std::string& group,
const std::string& joint);
168 bool addGroupToGroup(
const std::string& group,
const std::string& subgroup);
176 return !joint_groups_.empty();
180 return getKeyFrame(keyframes_.size() - 1);
184 return keyframes_[i];
188 std::vector<std::string> joints;
191 if (group_used_ !=
"")
193 joints.insert(joints.end(), joint_groups_.at(group_used_).begin(),
194 joint_groups_.at(group_used_).end());
198 for (
const auto& extra_joint : extra_joints_)
200 if (extra_joint.second)
201 joints.push_back(extra_joint.first);
208 return keyframes_.size();
220 if (joint_groups_.find(group) != joint_groups_.end())
232 if (extra_joints_.find(joint_name) != extra_joints_.end())
233 return extra_joints_.at(joint_name);
234 else if (group_used_ !=
"")
235 return std::find(joint_groups_.at(group_used_).begin(),
236 joint_groups_.at(group_used_).end(),
237 joint_name) != joint_groups_.at(group_used_).end();
243 if (extra_joints_.find(name) != extra_joints_.end())
245 extra_joints_[name] = used;
255 std::vector<std::string> joint_groups;
256 for (
const auto& pair : joint_groups_)
258 joint_groups.push_back(pair.first);
265 std::vector<std::string> extra_joints;
266 for (
const auto& pair : extra_joints_)
268 extra_joints.push_back(pair.first);
275 std::vector<std::string> joints;
276 for (
const auto& pair : joint_groups_)
278 for (
const auto& joint : pair.second)
280 if (std::find(joints.begin(), joints.end(), joint) == joints.end())
282 joints.push_back(joint);
288 for (
const auto& pair : extra_joints_)
290 joints.push_back(pair.first);
306 void loadParams(
const YAML::Emitter& param,
const std::string& filename);
307 std::string
cleanName(
const std::string& name);
308 std::string
rosifyName(
const std::string& name);
std::vector< std::string > joints_
static const std::string POINTS_KEY
static const std::string TIME_KEY
std::vector< std::string > joints_
std::string rosifyName(const std::string &name)
Emitter & operator<<(YAML::Emitter &out, const pal::PrintMeta &m)
JointModel(double lower_limit, double upper_limit)
std::vector< KeyFrame > keyframes_
std::vector< std::string > getAvailableJoints()
double toDouble(XmlRpc::XmlRpcValue &value)
std::vector< std::string > getJoints() const
std::vector< JointPosition > & getJoints()
std::unordered_map< std::string, std::vector< std::string > > joint_groups_
JointGroup(const std::string &name)
ROSCONSOLE_DECL void print(FilterBase *filter, void *logger, Level level, const char *file, int line, const char *function, const char *fmt,...) ROSCONSOLE_PRINTF_ATTRIBUTE(7
bool setCurrentGroup(const std::string &group)
bool isJointUsed(const std::string &joint_name) const
std::string cleanName(const std::string &name)
static const std::string POSITIONS_KEY
const KeyFrame & getLastKeyFrame() const
std::vector< JointPosition > joints_
std::vector< double > positions_
const std::string & getParamName() const
std::unordered_map< std::string, JointModel > joint_models_
bool setExtraJointUsedState(const std::string &name, bool used)
const std::string & getCurrentGroup()
std::unordered_map< std::string, bool > extra_joints_
const std::vector< JointPosition > & getJoints() const
const std::vector< KeyFrame > getKeyframes() const
static const float DEFAULT_TIME
std::vector< PrintPoint > points_
bool inLimits(double position)
void loadParams(const YAML::Emitter ¶m, const std::string &filename)
const KeyFrame & getKeyFrame(int i) const
std::vector< std::string > getExtraJoints()
std::vector< std::string > getJointGroups()
void setTime(float time_increment)
JointPosition(const std::string &joint_name, double position)
static const std::string JOINTS_KEY