Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts for managing and processing logs parameterized #21

Open
wants to merge 74 commits into
base: melodic-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
9103e32
`evaluation` - parameterized scripts for managing and processing logs
rayvburn Aug 10, 2023
72cc224
`evaluation` - version bumped
rayvburn Sep 25, 2023
4785fe1
`evaluation` - added `PassingSpeedDiscomfort` metric, adjusted script…
rayvburn Oct 2, 2023
87bfce3
`evaluation` - explicit initialization of all member variables in `Fo…
rayvburn Oct 2, 2023
f20c76f
`evaluation` - explicit initialization of all member variables in `He…
rayvburn Oct 2, 2023
8d712e7
`evaluation` - explicit initialization of all member variables in `Pe…
rayvburn Oct 2, 2023
17bc89d
`evaluation` - added an extensive usage note in `create_excel_from_re…
rayvburn Oct 4, 2023
4e24b6b
`evaluation` - added a note about the spreadsheet created with the `c…
rayvburn Oct 4, 2023
f909a8e
`evaluation` - more robust reading of sheet values in `create_latex_t…
rayvburn Oct 4, 2023
3bbe883
`evaluation` - metrics included in the `create_latex_table_from_resul…
rayvburn Oct 4, 2023
628f9ab
`evaluation` - updated LaTeX dependencies for the table generated by …
rayvburn Oct 4, 2023
0a81211
`evaluation` - created a shared file with the Excel table placement, …
rayvburn Oct 4, 2023
d6fd7e9
`evaluation` - `create_latex_table_from_results`: remake of SRPB metr…
rayvburn Oct 4, 2023
3a67cbf
`evaluation` - `create_excel_from_results`: simplified `prepare_sheet…
rayvburn Oct 4, 2023
674ec46
`evaluation` - `create_latex_table_from_results`: added logging of pl…
rayvburn Oct 4, 2023
b58a649
`evaluation` - added a script for renaming directories matching the p…
rayvburn Oct 5, 2023
b842345
`evaluation` - `create_excel_from_results`: multiple adjustments to i…
rayvburn Oct 5, 2023
f94709c
`evaluation` - scripts now handle copying and evaluation of logs divi…
rayvburn Nov 21, 2023
95dfe00
`evaluation` - version bumped
rayvburn Oct 2, 2023
d62a39a
`logger` - added `latch` method in `RobotLogger` to synchronize bette…
rayvburn Nov 20, 2023
4a0cb9c
`logger` & `evaluation` - added logging of the global path planner fe…
rayvburn Nov 20, 2023
ac5ea9d
`evaluation` - global path planner logs loaded into the main executab…
rayvburn Nov 21, 2023
5ae7b0a
`evaluation` - fixed typo in `create_excel_from_results` (metric name)
rayvburn Dec 6, 2023
1728b74
`evaluation` - script for renaming directories made more robust
rayvburn Dec 6, 2023
eaa6d00
`evaluation` - version bumped
rayvburn Dec 6, 2023
381d670
`logger` - `srpb` params put into a namespace
rayvburn Dec 27, 2023
9f7202b
`logger` - `RobotData` class extended with the `getPoseWithCovariance…
rayvburn Dec 27, 2023
f26074c
`logger` - `RobotLogger` extended with a feature of receiving computa…
rayvburn Dec 27, 2023
c3f205a
`logger` - version bumped
rayvburn Dec 27, 2023
3512e9a
`logger` - `RobotLogger` collects raw velocity commands of the local …
rayvburn Dec 27, 2023
871fa88
`logger` - added a unit test for `RobotLogger` conversions
rayvburn Dec 27, 2023
8f63b72
`logger` - version bumped
rayvburn Dec 27, 2023
85549be
`evaluation` - extended the list of metrics saved in the `results` fi…
rayvburn Dec 27, 2023
0776834
`evaluation` - version bumped
rayvburn Dec 27, 2023
7d02ca6
`logger` - optimized `transformPose` for the cases where transforming…
rayvburn Jan 11, 2024
f1d805e
`logger` - whole planned path is saved by the `GlobalPlannerLogger`
rayvburn Jan 11, 2024
b461d45
`evaluation` - renamed `excel_sheet_defines` to `excel_sheet_utils`
rayvburn Jan 22, 2024
e7265a4
`evaluation` - `load_data_from_excel` moved to `excel_sheet_utils`
rayvburn Jan 22, 2024
3caabd0
`evaluation` - `MetricGaussian` renamed to `MetricStatistics`, adjust…
rayvburn Jan 23, 2024
b071729
`evaluation` - added more unit tests for `calculateStatistics` when v…
rayvburn Jan 24, 2024
785606c
`evaluation` - fixed the calculation of the timing-corrected threshol…
rayvburn Jan 24, 2024
c5dc6ba
`evaluation` - reworked the `ObstacleSafety` metric class to obtain m…
rayvburn Jan 24, 2024
1852051
`evaluation` - fixed a description in the `evaluate_all_dirs` script
rayvburn Jan 24, 2024
f758ec3
`evaluation` - added `SrpbMetrics` class for usage in Python processi…
rayvburn Jan 24, 2024
c6f0d7e
`evaluation` - modernized the script creating a LaTeX table from a re…
rayvburn Jan 24, 2024
e45ea51
`evaluation` - zero `dt` handled in the `VelocitySmoothness` and `Hea…
rayvburn Jan 29, 2024
12603aa
`evaluation` - scripts creating Excel spreadsheet from results loads …
rayvburn Jan 31, 2024
f1c7ec4
`evaluation` - `GoalReached` metric prints distance differences betwe…
rayvburn Feb 2, 2024
0874845
`evaluation` - experiment duration logged in `rewind_experiment` script
rayvburn Feb 12, 2024
c939eef
`evaluation` - extended spreadsheet tooling, added function to read a…
rayvburn Feb 18, 2024
ba84c66
`evaluation` - modernized `create_excel_from_results` script (`cell_c…
rayvburn Feb 18, 2024
65b0c4c
`evaluation` - version bumped
rayvburn Feb 18, 2024
c90e14e
`evaluation` - added script creating a violin/box plot from a spreads…
rayvburn Feb 18, 2024
5a9dd12
`evaluation` - added main guard in `create_excel_from_results` Python…
rayvburn Feb 21, 2024
c20dfc8
`evaluation` - `excel_sheet_utils`: internal lambdas from `read_data_…
rayvburn Feb 21, 2024
040653d
`evaluation` - added a script that clears out a spreadsheet from metr…
rayvburn Feb 21, 2024
e3ef324
`evaluation` - configurable font family in the `rewind_experiment` sc…
rayvburn Feb 23, 2024
46c850f
`evaluation` - configurable output fig. extension and DPI in the `rew…
rayvburn Feb 23, 2024
bba17bf
`evaluation` - added usage note in script creating a violin/box plot …
rayvburn Apr 23, 2024
f179b61
`evaluation` - `excel_sheet_utils` detects failed trials during the p…
rayvburn Apr 24, 2024
72dbf54
`evaluation` - adjusted `create_box_plot` to handle incomplete data (…
rayvburn Apr 24, 2024
80ab616
`evaluation` - added `create_bar_plot` script to create simple bar pl…
rayvburn Apr 24, 2024
c1507e4
`evaluation` - fixed inverse height/width of the figure in the `creat…
rayvburn Apr 24, 2024
525d018
`evaluation` - added configurable figure size in the `create_bar_plot…
rayvburn Apr 24, 2024
631a197
`evaluation` - fixed `create_bar_plot` script's omitting the unremapp…
rayvburn Apr 24, 2024
b3f33b8
`evaluation` - `create_box_plot` script's extended to handle multiple…
rayvburn Apr 24, 2024
98ef0c7
`evaluation` - refined `create_bar_plot` script's: unified the font o…
rayvburn Apr 24, 2024
4fb4020
`evaluation` - added font configuration and x labels rotation in the …
rayvburn Apr 24, 2024
2bbdc23
`evaluation` - fixes in the script creating LaTeX table: dynamically …
rayvburn May 5, 2024
77d168c
`evaluation` - extended the script creating LaTeX table: capable of a…
rayvburn May 5, 2024
46f0e41
`evaluation` - fixes in the script creating LaTeX table: fixed newlin…
rayvburn May 5, 2024
24bcaf8
`evaluation` - fixed script creating LaTeX table: lack of best metric…
rayvburn May 7, 2024
07a40dc
`evaluation` - version bumped
rayvburn Jun 3, 2024
96e3cbe
README updated (preliminary usage instructions)
rayvburn Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ rosinstall -n . srpb/srpb/srpb.rosinstall

## Usage

### Setup

A log file is saved once the goal is reached by the `srpb_move_base` node. Renewing the goal pose before reaching the previous one does not cause the files to be divided into parts.

TBD...
### Typical workflow

If one intends to collect a bunch of logs, this is the correct workflow:

* instead of running the typical `move_base`, run the `srpb_move_base` node that aggregates the `srpb_logger` modules,
* after each trial, run the `scripts/copy_logs.sh` to copy the logs related to the newest trial into a separate directory,
* if one wishes to be extra safe, one might want to evaluate the newest logs at this point with `scripts/evaluate_from_dir.sh <PATH TO THE DIR WITH LOGS COPIED INTO>` OR (typically) once all trials were completed, run the `scripts/evaluate_all_dirs.sh <PATH TO THE MAIN DIR WITH LOGS GROUPED INTO DIRS>`,
* now an Excel sheet can be created with `python3 create_excel_from_results.py` script.

## Acknowledgments

Expand Down
10 changes: 5 additions & 5 deletions srpb_evaluation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ include_directories(
add_library(${PROJECT_NAME}_lib
# libs
include/${PROJECT_NAME}/metric.h
include/${PROJECT_NAME}/metric_gaussian.h
include/${PROJECT_NAME}/metric_statistics.h
include/${PROJECT_NAME}/rewinder.h
include/${PROJECT_NAME}/utils.h
# specific metrics
Expand All @@ -63,7 +63,7 @@ add_library(${PROJECT_NAME}_lib
include/${PROJECT_NAME}/metrics/personal_space_instrusion.h
include/${PROJECT_NAME}/metrics/velocity_smoothness.h
# sources
src/metric_gaussian.cpp
src/metric_statistics.cpp
src/rewinder.cpp
src/utils.cpp
)
Expand Down Expand Up @@ -95,8 +95,8 @@ if (CATKIN_ENABLE_TESTING)
if(TARGET test_utils)
target_link_libraries(test_utils ${PROJECT_NAME}_lib)
endif()
catkin_add_gtest(test_metric_gaussian test/test_metric_gaussian.cpp)
if(TARGET test_metric_gaussian)
target_link_libraries(test_metric_gaussian ${PROJECT_NAME}_lib)
catkin_add_gtest(test_metric_statistics test/test_metric_statistics.cpp)
if(TARGET test_metric_statistics)
target_link_libraries(test_metric_statistics ${PROJECT_NAME}_lib)
endif()
endif()
62 changes: 0 additions & 62 deletions srpb_evaluation/include/srpb_evaluation/metric_gaussian.h

This file was deleted.

66 changes: 66 additions & 0 deletions srpb_evaluation/include/srpb_evaluation/metric_statistics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#pragma once

#include "srpb_evaluation/metric.h"

namespace srpb {
namespace evaluation {

class MetricStatistics: public Metric {
public:
MetricStatistics(
const std::vector<std::pair<double, logger::RobotData>>& robot_data
): Metric(robot_data) {}

MetricStatistics(
const std::vector<std::pair<double, logger::RobotData>>& robot_data,
const std::vector<std::pair<double, people_msgs_utils::Person>>& people_data
): Metric(robot_data, people_data) {}

MetricStatistics(
const std::vector<std::pair<double, logger::RobotData>>& robot_data,
const std::vector<std::pair<double, people_msgs_utils::Person>>& people_data,
const std::vector<std::pair<double, people_msgs_utils::Group>>& groups_data
): Metric(robot_data, people_data, groups_data) {}

/// Returns minimum value obtained throughout the scenario
virtual double getValueMin() const = 0;

/// Returns maximum value obtained throughout the scenario
virtual double getValueMax() const = 0;

/// Returns the percentage of violations obtained throughout the scenario (considering the threshold value)
virtual double getViolations() const = 0;

/// Prints results
virtual void printResults() const = 0;

/**
* @brief Computes min, max, normalized metrics and counts the number of violations (above the certain threshold)
*
* @param timed_values vector of pairs with, first, a timestamp, and second, a container with values
* @param violation_threshold values bigger than that will be considered as violations
* @param violation_above_threshold selects whether the violation is counted when the value is bigger than
* the threshold (true, default) or when the violation is less than the threshold (false).
* This is specific to a certain metric (whether computes "cost" or "reward").
* @param max_method set to true (default) so the max element is used to normalize metrics;
* false means averaging over all values/occurrences in a current time step
*
* @return std::tuple<double, double, double, double> tuple with scores:
* 1) min value,
* 2) max value,
* 3) a metric value normalized according to the duration/execution time,
* 4) timing-corrected percentage of the threshold value violations
*/
static std::tuple<double, double, double, double> calculateStatistics(
std::vector<std::pair<double, std::vector<double>>> timed_values,
double violation_threshold,
bool violation_above_threshold = true,
bool max_method = true
);

protected:
virtual void compute() = 0;
};

} // namespace evaluation
} // namespace srpb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma once

#include "srpb_evaluation/metric_gaussian.h"
#include "srpb_evaluation/metric_statistics.h"

#include <social_nav_utils/formation_space_intrusion.h>

namespace srpb {
namespace evaluation {

/// Similar to personal space intrusion but related to the group space
class FormationSpaceIntrusion: public MetricGaussian {
class FormationSpaceIntrusion: public MetricStatistics {
public:
FormationSpaceIntrusion(
const std::vector<std::pair<double, logger::RobotData>>& robot_data,
Expand All @@ -17,9 +17,13 @@ class FormationSpaceIntrusion: public MetricGaussian {
double group_space_threshold,
bool max_method = true
):
MetricGaussian(robot_data, people_data, groups_data),
MetricStatistics(robot_data, people_data, groups_data),
group_space_threshold_(group_space_threshold),
max_method_(max_method)
max_method_(max_method),
intrusion_min_(0.0),
intrusion_max_(0.0),
intrusion_total_(0.0),
violations_percentage_(0.0)
{
if (people_data.empty() || groups_data.empty()) {
return;
Expand Down Expand Up @@ -118,12 +122,13 @@ class FormationSpaceIntrusion: public MetricGaussian {

rewinder_.perform();

// Gaussian is computed as a "cost"; hence, "violation_above_threshold" is hard-coded to true
std::tie(
intrusion_min_,
intrusion_max_,
intrusion_total_,
violations_percentage_
) = MetricGaussian::calculateGaussianStatistics(timed_gaussians, group_space_threshold_, max_method_);
) = MetricStatistics::calculateStatistics(timed_gaussians, group_space_threshold_, true, max_method_);
}
};

Expand Down
17 changes: 11 additions & 6 deletions srpb_evaluation/include/srpb_evaluation/metrics/goal_reached.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,42 @@ class GoalReached: public Metric {

void printResults() const override {
printf(
"Goal reached = %d [bool] (tolerance violations: position %d, orientation %d)\n",
"Goal reached = %d [bool] "
"(tolerance violations: position %d [offset %7.4f m], orientation %d [offset %7.4f rad])\n",
static_cast<int>(!tolerance_xy_violated_ && !tolerance_yaw_violated_),
static_cast<int>(tolerance_xy_violated_),
static_cast<int>(tolerance_yaw_violated_)
offset_xy_,
static_cast<int>(tolerance_yaw_violated_),
offset_yaw_
);
}

protected:
double tolerance_xy_;
double tolerance_yaw_;
double offset_xy_;
double offset_yaw_;
bool tolerance_xy_violated_;
bool tolerance_yaw_violated_;

void compute() override {
rewinder_.setHandlerLastTimestamp(
[&]() {
double dist_to_goal_xy = std::hypot(
offset_xy_ = std::hypot(
rewinder_.getRobotCurr().getPositionX() - rewinder_.getRobotCurr().getGoalPositionX(),
rewinder_.getRobotCurr().getPositionY() - rewinder_.getRobotCurr().getGoalPositionY()
);

double dist_to_goal_yaw = std::abs(
offset_yaw_ = std::abs(
angles::shortest_angular_distance(
rewinder_.getRobotCurr().getOrientationYaw(),
rewinder_.getRobotCurr().getGoalOrientationYaw()
)
);

// save results
tolerance_xy_violated_ = dist_to_goal_xy > tolerance_xy_;
tolerance_yaw_violated_ = std::abs(dist_to_goal_yaw) > std::abs(tolerance_yaw_);
tolerance_xy_violated_ = offset_xy_ > tolerance_xy_;
tolerance_yaw_violated_ = std::abs(offset_yaw_) > std::abs(tolerance_yaw_);
}
);
rewinder_.perform();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class HeadingChangeSmoothness: public Metric {
rewinder_.setHandlerNextTimestamp(
[&]() {
double dt = rewinder_.getTimestampNext() - rewinder_.getTimestampCurr();
// if we attempt to divide by 0 (due to possibly insufficient sampling rate of the logger), then skip this one;
// however, this sample will still be included in the final result
if (dt <= 0.0) {
return;
}
double dtheta = rewinder_.getRobotNext().getVelocityTheta() - rewinder_.getRobotCurr().getVelocityTheta();
hsm += (std::abs(dtheta) / dt);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma once

#include "srpb_evaluation/metric_gaussian.h"
#include "srpb_evaluation/metric_statistics.h"

#include <social_nav_utils/heading_direction_disturbance.h>

namespace srpb {
namespace evaluation {

/// Related to velocity and direction of the robot movement towards person
class HeadingDirectionDisturbance: public MetricGaussian {
class HeadingDirectionDisturbance: public MetricStatistics {
public:
HeadingDirectionDisturbance(
const std::vector<std::pair<double, logger::RobotData>>& robot_data,
Expand All @@ -20,13 +20,17 @@ class HeadingDirectionDisturbance: public MetricGaussian {
double robot_max_speed = social_nav_utils::HeadingDirectionDisturbance::MAX_SPEED_DEFAULT,
bool max_method = true
):
MetricGaussian(robot_data, people_data),
MetricStatistics(robot_data, people_data),
disturbance_threshold_(disturbance_threshold),
person_occupancy_radius_(person_occupancy_radius),
person_fov_(person_fov),
robot_circumradius_(robot_circumradius),
robot_max_speed_(robot_max_speed),
max_method_(max_method)
max_method_(max_method),
disturbance_min_(0.0),
disturbance_max_(0.0),
disturbance_total_(0.0),
violations_percentage_(0.0)
{
if (people_data.empty()) {
return;
Expand Down Expand Up @@ -127,12 +131,13 @@ class HeadingDirectionDisturbance: public MetricGaussian {
);
rewinder_.perform();

// Gaussian is computed as a "cost"; hence, "violation_above_threshold" is hard-coded to true
std::tie(
disturbance_min_,
disturbance_max_,
disturbance_total_,
violations_percentage_
) = MetricGaussian::calculateGaussianStatistics(timed_disturbances, disturbance_threshold_, max_method_);
) = MetricStatistics::calculateStatistics(timed_disturbances, disturbance_threshold_, true, max_method_);
}
};

Expand Down
Loading