9 #define VP_DEBUG_MODE 45 33 : TrajectoryToFill_(aTrajectoryToFill),
35 float_str_re(
"[-0-9]+\\.[0-9]*"),
38 seq_str_re(
"([0-9]+)"),
39 timestamp_str_re(
"(" + float_str_re +
"),(" + float_str_re +
")"),
40 frame_id_str_re(
"[a-zA-z_0-9]*"),
41 header_str_re(
"\\(" + seq_str_re +
"\\,\\(" + timestamp_str_re +
"\\),(" +
42 frame_id_str_re +
")\\)\\,\\("),
45 joint_name_str_re(
"([a-zA-Z0-9_]+)"),
46 list_of_jn_str_re(joint_name_str_re +
"(\\,|\\))"),
49 point_value_str_re(
"(" + float_str_re +
"+)|(?:)"),
50 list_of_pv_str_re(point_value_str_re +
"(\\,|\\))"),
53 comma_pt_str_re(
"\\,\\("),
56 bg_liste_of_pts_str_re(
"\\,\\("),
59 header_re(header_str_re),
60 list_of_jn_re(list_of_jn_str_re),
61 list_of_pv_re(list_of_pv_str_re),
62 bg_pt_re(bg_pt_str_re),
63 end_pt_re(end_pt_str_re),
64 comma_pt_re(comma_pt_str_re),
65 bg_liste_of_pts_re(bg_liste_of_pts_str_re) {}
68 std::string &text, boost::match_results<std::string::const_iterator> &what,
69 boost::regex &e, std::string &sub_text) {
70 unsigned nb_failures = 0;
72 boost::match_flag_type flags = boost::match_extra;
73 if (boost::regex_search(text, what, e, flags)) {
75 std::cout <<
"** Match found **\n Sub-Expressions:" << what.size()
77 for (
unsigned int i = 0;
i < what.size(); ++
i)
78 std::cout <<
" $" <<
i <<
" = \"" << what[
i] <<
"\" " 79 << what.position(
i) <<
" " << what.length(
i) <<
"\n";
81 if (what.size() >= 1) {
82 unsigned int all_text = 0;
83 boost::match_results<std::string::const_iterator>::difference_type
pos =
84 what.position(all_text);
85 boost::match_results<std::string::const_iterator>::difference_type len =
86 what.length(all_text);
87 sub_text = text.substr(pos + len);
91 if (
dbg_level > 5) std::cout <<
"** No Match found **\n";
94 if (nb_failures > 100)
return false;
100 std::string &sub_text1) {
101 std::istringstream is;
102 boost::match_results<std::string::const_iterator> what;
117 <<
" " << is.str() << std::endl;
121 std::cout <<
"sub_text1:" << sub_text1 << std::endl;
127 std::string &trajectory, std::string &sub_text1,
129 std::istringstream is;
130 boost::match_results<std::string::const_iterator> what;
131 bool joint_names_loop =
true;
136 joint_name = what[1];
137 joint_names.push_back(joint_name);
139 std::string sep_char;
142 if (sep_char ==
")") joint_names_loop =
false;
144 std::cout <<
"joint_name:" << joint_name <<
" " << sep_char
146 std::cout <<
"sub_text1:" << sub_text1 << std::endl;
149 trajectory = sub_text1;
151 }
while (joint_names_loop);
155 std::string &sub_text1,
156 std::vector<double> &seq) {
157 boost::match_results<std::string::const_iterator> what;
158 bool joint_seq_loop =
true;
159 std::istringstream is;
160 std::string sub_text2 = trajectory;
161 sub_text1 = trajectory;
164 std::string sep_char;
166 std::cout <<
"size:" << what.size() << std::endl;
169 if (what.size() == 3) {
170 std::string aString(what[1]);
171 if (aString.size() > 0) {
177 std::cout << aString <<
" | " << aValue << std::endl;
180 seq.push_back(aValue);
183 }
else if (what.size() == 1)
186 if (sep_char ==
")") joint_seq_loop =
false;
191 sub_text2 = sub_text1;
192 }
while (joint_seq_loop);
197 std::string &sub_text1) {
198 std::vector<double> position, velocities, acceleration, effort;
199 std::string sub_text2;
200 boost::match_results<std::string::const_iterator> what;
205 sub_text2 = sub_text1;
208 sub_text2 = sub_text1;
212 sub_text2 = sub_text1;
215 sub_text2 = sub_text1;
219 sub_text2 = sub_text1;
222 sub_text2 = sub_text1;
226 sub_text2 = sub_text1;
234 std::string &sub_text1) {
235 boost::match_results<std::string::const_iterator> what;
236 bool joint_points_loop =
true;
237 std::istringstream is;
241 std::string sub_text2 = sub_text1;
246 sub_text2 = sub_text1;
248 if (!
parse_point(sub_text2, sub_text1))
return false;
249 sub_text2 = sub_text1;
253 sub_text2 = sub_text1;
257 sub_text2 = sub_text1;
258 std::string sep_char;
261 if (sep_char ==
")") joint_points_loop =
false;
263 }
while (joint_points_loop);
269 std::string sub_text1, sub_text2;
271 sub_text1 = sub_text2;
276 for (std::vector<std::string>::size_type
i = 0;
i <
joint_names.size();
i++)
280 sub_text1 = sub_text2;
295 std::string aStr = is.str();
303 unsigned int index = 0;
304 os <<
"-- Trajectory --" << std::endl;
305 for (std::vector<std::string>::const_iterator it_joint_name =
306 joint_names_.begin();
307 it_joint_name != joint_names_.end(); it_joint_name++, index++)
308 os <<
"Joint(" << index <<
")=" << *(it_joint_name) << std::endl;
310 os <<
" Number of points: " << points_.size() << std::endl;
311 for (std::vector<JointTrajectoryPoint>::const_iterator it_point =
313 it_point != points_.end(); it_point++) {
314 it_point->display(os);
int deserialize(std::istringstream &is)
std::vector< double > efforts_
std::vector< std::string > joint_names
bool parse_points(std::string &trajectory, std::string &sub_text1)
Extract a sequence of points.
boost::regex list_of_jn_re
std::vector< double > positions_
std::vector< std::string > joint_names_
void parse_string(std::string &atext)
parse_string will fill TrajectoryToFill with string atext.
boost::regex header_re
Boost regular expressions implementing the grammar.
bool search_exp_sub_string(std::string &text, boost::match_results< std::string::const_iterator > &what, boost::regex &e, std::string &sub_text)
General parsing method of text with regexp e. The results are given in what. The remaining text is le...
void display(std::ostream &) const
boost::regex list_of_pv_re
std::vector< double > velocities_
std::vector< JointTrajectoryPoint > points_
bool parse_point(std::string &trajectory, std::string &sub_text1)
Extract a point description.
boost::regex bg_liste_of_pts_re
void parse_header(std::string &text, std::string &sub_text1)
Find and store the header. This method is looking for: unsigned int seq. unsigned int sec...
RulesJointTrajectory(Trajectory &TrajectoryToFill)
Constructor TrajectoryToFill is the structure where to store the parsed information.
Trajectory & TrajectoryToFill_
void parse_joint_names(std::string &text, std::string &sub_text1, std::vector< std::string > &joint_names)
Understand joint_names. Extract a list of strings.
bool parse_seq(std::string &text, std::string &sub_text1, std::vector< double > &seq)
Extract a sequence of doubles. To be used for position, velocities, accelerations and effort...
std::vector< double > accelerations_