9 data_header =
"index | step_x step_y step_yaw | dx dy dyaw | swing_distance duration";
36 if (!execute_goal.goal.step_plan.steps.empty())
43 msgs::Step start_left, start_right;
48 step_feedback_map[initial.step_index-1] = initial.foot.foot_index == msgs::Foot::LEFT ? start_right : start_left;
49 step_feedback_map[initial.step_index] = initial.foot.foot_index == msgs::Foot::LEFT ? start_left : start_right;
67 for (std::vector<msgs::Step>::const_iterator itr = feedback.steps.begin(); itr != feedback.steps.end(); itr++)
74 bool WalkAnalyzer::analyze(
const msgs::Step& previous,
const msgs::Step& current,
const msgs::Step& next, std::string& result)
const 76 std::ostringstream ss;
77 ss << std::fixed << std::setprecision(6);
78 std::ostringstream temp;
79 temp << std::fixed << std::setprecision(6);
82 geometry_msgs::Pose dswing;
83 getDeltaStep(previous.foot, next.foot, dswing);
88 double swing_r, swing_p, swing_y;
92 geometry_msgs::Pose dstep;
93 getDeltaStep(current.foot, next.foot, dstep);
98 double step_r, step_p, step_y;
102 ss << next.step_index <<
" | " 103 << dstep.position.x <<
" " << dstep.position.y <<
" " 105 << dswing.position.x <<
" " << dswing.position.y <<
" " 107 << sqrt(dswing.position.x*dswing.position.x + dswing.position.y*dswing.position.y) <<
" " 109 << next.step_duration;
111 if (!temp.str().empty())
114 temp <<
"{" << sqrt(dswing.position.x*dswing.position.x + dswing.position.y*dswing.position.y) <<
", " << next.step_duration <<
"}";
133 std::map<int, msgs::Step>::const_iterator itr = data.begin();
134 msgs::Step previous = itr->second; itr++;
135 msgs::Step current = itr->second; itr++;
137 for (; itr != data.end(); itr++)
139 const msgs::Step& next = itr->second;
141 if (current.step_index+1 != next.step_index)
143 ROS_ERROR(
"[WalkAnalyzer] analyzeData: Inconsistent data record! Stopping analysis.");
148 if (!
analyze(previous, current, next, temp))
167 ROS_ERROR(
"[WalkAnalyzer] Error while analyzing data!");
176 std::string
filename = logging_dir +
"/" + date_time +
".txt";
177 std::ofstream file(filename);
181 file << data_header +
"\n";
184 ROS_INFO(
"[WalkAnalyzer] Written step plan result in '%s'", filename.c_str());
187 ROS_ERROR(
"[WalkAnalyzer] Can't open file '%s'", filename.c_str());
190 filename = logging_dir +
"/overall.txt";
191 file.open(filename, std::ios_base::app);
195 file << result <<
"\n";
197 ROS_INFO(
"[WalkAnalyzer] Written step plan result in '%s'", filename.c_str());
200 ROS_ERROR(
"[WalkAnalyzer] Can't open file '%s'", filename.c_str());
205 time_t now = time(0);
208 tstruct = *localtime(&now);
209 strftime(buf,
sizeof(buf),
"%Y-%m-%d.%X", &tstruct);
static void quaternionMsgToTF(const geometry_msgs::Quaternion &msg, Quaternion &bt)
void getRPY(tfScalar &roll, tfScalar &pitch, tfScalar &yaw, unsigned int solution_number=1) const
bool getParam(const std::string &key, std::string &s) const