Skip to content
Snippets Groups Projects
Commit d26d6dfd authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Merge branch 'grasp-planner-evaluation-cpp'

parents f40b0648 f7d55834
No related branches found
No related tags found
No related merge requests found
......@@ -47,35 +47,43 @@ endif()
SET(SOURCES
ConvexHullGenerator.cpp
ContactConeGenerator.cpp
ApproachMovementGenerator.cpp
ApproachMovementSurfaceNormal.cpp
MeshConverter.cpp
GraspPlanner/GraspPlanner.cpp
GraspPlanner/GenericGraspPlanner.cpp
GraspQuality/GraspEvaluationPoseUncertainty.cpp
GraspQuality/GraspQualityMeasure.cpp
GraspQuality/GraspQualityMeasureWrenchSpace.cpp
GraspQuality/GraspQualityMeasureWrenchSpaceNotNormalized.cpp
Visualization/ConvexHullVisualization.cpp
ApproachMovementGenerator.cpp
ApproachMovementSurfaceNormal.cpp
ContactConeGenerator.cpp
ConvexHullGenerator.cpp
MeshConverter.cpp
GraspPlanner/GenericGraspPlanner.cpp
GraspPlanner/GraspPlanner.cpp
GraspPlanner/GraspPlannerEvaluation.cpp
GraspQuality/GraspEvaluationPoseUncertainty.cpp
GraspQuality/GraspQualityMeasure.cpp
GraspQuality/GraspQualityMeasureWrenchSpace.cpp
GraspQuality/GraspQualityMeasureWrenchSpaceNotNormalized.cpp
Visualization/ConvexHullVisualization.cpp
)
SET(INCLUDES
GraspStudio.h
ConvexHullGenerator.h
ContactConeGenerator.h
ApproachMovementGenerator.h
ApproachMovementSurfaceNormal.h
MeshConverter.h
GraspPlanner/GraspPlanner.h
GraspPlanner/GenericGraspPlanner.h
GraspPlanner/GraspPlannerEvaluation.h
GraspQuality/GraspEvaluationPoseUncertainty.h
GraspQuality/GraspQualityMeasure.h
GraspQuality/GraspQualityMeasureWrenchSpace.h
GraspQuality/GraspQualityMeasureWrenchSpaceNotNormalized.h
Visualization/ConvexHullVisualization.h
GraspStudio.h
ApproachMovementGenerator.h
ApproachMovementSurfaceNormal.h
ContactConeGenerator.h
ConvexHullGenerator.h
MeshConverter.h
GraspPlanner/GenericGraspPlanner.h
GraspPlanner/GraspPlanner.h
GraspPlanner/GraspPlannerEvaluation.h
GraspQuality/GraspEvaluationPoseUncertainty.h
GraspQuality/GraspQualityMeasure.h
GraspQuality/GraspQualityMeasureWrenchSpace.h
GraspQuality/GraspQualityMeasureWrenchSpaceNotNormalized.h
Visualization/ConvexHullVisualization.h
)
......
/**
* This file is part of Simox.
*
* Simox is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Simox is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package GraspStudio
* @author Nikolaus Vahrenkamp
* @copyright 2017 Nikolaus Vahrenkamp
* GNU Lesser General Public License
*
*/
#include "GraspPlannerEvaluation.h"
namespace GraspStudio
{
GraspPlannerEvaluation::GraspPlannerEvaluation()
{
nrGraspsGenerated = 0;
nrGraspsValid = 0;
nrGraspsInvalidCollision = 0;
nrGraspsInvalidFC = 0;
nrGraspsInvalidContacts = 0;
nrGraspsValidPrecision = 0;
nrGraspsValidPower = 0;
fcCheck = false;
minQuality = 0.0f;
}
void GraspPlannerEvaluation::print()
{
std::cout << (*this) << std::endl;
}
std::string GraspPlannerEvaluation::GetCSVHeader()
{
std::stringstream fs;
fs << "minQuality" << ","
<< "nrGraspsGenerated" << ","
<< "nrGraspsValid" << ","
<< "nrGraspsInValid" << ","
<< "nrGraspsValidPrecision" << ","
<< "nrGraspsValidPower" << ","
<< "nrGraspsInvalidCollision" << ","
<< "nrGraspsInvalidFC" << ","
<< "nrGraspsInvalidContacts" << ","
<< "AverageDurationMS" << ","
<< "percPowerGrasps" << ","
<< "percPrecGraps" << ","
<< "avgScore";
return fs.str();
}
std::string GraspPlannerEvaluation::toCSVString() const
{
float timeAcc = 0;
float avgTime = 0;
float scoreAcc = 0;
int nrGrasps = static_cast<int>(timeGraspMS.size());
int nrValid = 0;
int nrPower = 0;
int nrPrecision = 0;
for (size_t i = 0; i < timeGraspMS.size(); i++)
{
timeAcc+=timeGraspMS.at(i);
if (graspValid.at(i))
{
nrValid++;
scoreAcc+=graspScore.at(i);
}
if (graspTypePower.at(i))
nrPower++;
else
nrPrecision++;
}
float percPower = 0;
float percPrec = 0;
if (nrGrasps > 0)
{
percPower = static_cast<float>(nrPower) / static_cast<float>(nrGrasps);
percPrec = static_cast<float>(nrPrecision) / static_cast<float>(nrGrasps);
avgTime = timeAcc / static_cast<float>(nrGrasps);
}
float avgScore = 0;
if (nrValid > 0)
{
avgScore = scoreAcc / nrValid;
}
std::stringstream fs;
fs << minQuality << ","
<< nrGraspsGenerated << ","
<< nrGraspsValid << ","
<< (nrGraspsInvalidCollision+nrGraspsInvalidFC+nrGraspsInvalidContacts) << ","
<< nrGraspsValidPrecision << ","
<< nrGraspsValidPower << ","
<< nrGraspsInvalidCollision << ","
<< nrGraspsInvalidFC << ","
<< nrGraspsInvalidContacts << ","
<< avgTime << ","
<< percPower << ","
<< percPrec << ","
<< avgScore;
return fs.str();
}
std::ostream& operator<<(std::ostream& os, const GraspPlannerEvaluation& rhs)
{
os << "---------------- GRASP PLANNER EVALUATION -----------" << std::endl;
if (rhs.fcCheck)
os << "ForceClosure check: true" << std::endl;
else
os << "ForceClosure check: false" << std::endl;
os << "Min Quality: " << rhs.minQuality << std::endl;
os << "nrGraspsGenerated: " << rhs.nrGraspsGenerated << std::endl;
os << "nrGraspsValid: " << rhs.nrGraspsValid << std::endl;
os << "nrGraspsInValid: " << (rhs.nrGraspsInvalidCollision + rhs.nrGraspsInvalidFC
+ rhs.nrGraspsInvalidContacts) << std::endl;
os << "nrGraspsValidPrecision: " << rhs.nrGraspsValidPrecision << std::endl;
os << "nrGraspsValidPower: " << rhs.nrGraspsValidPower << std::endl;
os << "nrGraspsInvalidCollision: " << rhs.nrGraspsInvalidCollision << std::endl;
os << "nrGraspsInvalidFC: " << rhs.nrGraspsInvalidFC << std::endl;
os << "nrGraspsInvalidContacts: " << rhs.nrGraspsInvalidContacts << std::endl;
VR_ASSERT (rhs.timeGraspMS.size() == rhs.graspScore.size());
VR_ASSERT (rhs.timeGraspMS.size() == rhs.graspValid.size());
VR_ASSERT (rhs.timeGraspMS.size() == rhs.graspTypePower.size());
float timeAcc = 0;
float scoreAcc = 0;
int nrGrasps = static_cast<int>(rhs.timeGraspMS.size());
int nrValid = 0;
int nrPower = 0;
int nrPrecision = 0;
for (size_t i = 0; i < rhs.timeGraspMS.size(); i++)
{
timeAcc += rhs.timeGraspMS.at(i);
if (rhs.graspValid.at(i))
{
nrValid++;
scoreAcc += rhs.graspScore.at(i);
}
if (rhs.graspTypePower.at(i))
nrPower++;
else
nrPrecision++;
}
os << "Time complete: " << timeAcc << " ms" << std::endl;
if (nrGrasps > 0)
{
os << "Avg time per grasp (valid&invalid): " <<
static_cast<float>(timeAcc) / static_cast<float>(nrGrasps) << " ms" << std::endl;
float percPower = static_cast<float>(nrPower) / static_cast<float>(nrGrasps);
float percPrec = static_cast<float>(nrPrecision) / static_cast<float>(nrGrasps);
os << "Precision grasps: " << nrPrecision << " -> " << percPrec*100 << "%" << std::endl;
os << "Power grasps: " << nrPower << " -> " << percPower*100 << "%" << std::endl;
}
if (nrValid > 0)
{
os << "Avg score (valid):" << scoreAcc / nrValid << std::endl;
}
if (rhs.nrGraspsGenerated > 0)
os << "Percentage of valid grasps: "
<< static_cast<float>(rhs.nrGraspsValid) / static_cast<float>(rhs.nrGraspsGenerated) * 100.0f
<< "%" << std::endl;
return os;
}
}
......@@ -23,173 +23,45 @@
#pragma once
#include "../GraspStudio.h"
#include <vector>
namespace GraspStudio
{
struct GraspPlannerEvaluation
namespace GraspStudio
{
GraspPlannerEvaluation()
{
nrGraspsGenerated = 0;
nrGraspsValid = 0;
nrGraspsInvalidCollision = 0;
nrGraspsInvalidFC = 0;
nrGraspsInvalidContacts = 0;
nrGraspsValidPrecision = 0;
nrGraspsValidPower = 0;
fcCheck = false;
minQuality = 0.0f;
}
void print()
struct GraspPlannerEvaluation
{
std::cout << "---------------- GRASP PLANNER EVALUATION -----------" << std::endl;
if (fcCheck)
std::cout << "ForceClosure check: true" << std::endl;
else
std::cout << "ForceClosure check: false" << std::endl;
std::cout << "Min Quality: " << minQuality << std::endl;
std::cout << "nrGraspsGenerated:" << nrGraspsGenerated << std::endl;
std::cout << "nrGraspsValid:" << nrGraspsValid << std::endl;
std::cout << "nrGraspsInValid:" << nrGraspsInvalidCollision+nrGraspsInvalidFC+nrGraspsInvalidContacts << std::endl;
std::cout << "nrGraspsValidPrecision:" << nrGraspsValidPrecision << std::endl;
std::cout << "nrGraspsValidPower:" << nrGraspsValidPower << std::endl;
std::cout << "nrGraspsInvalidCollision:" << nrGraspsInvalidCollision << std::endl;
std::cout << "nrGraspsInvalidFC:" << nrGraspsInvalidFC << std::endl;
std::cout << "nrGraspsInvalidContacts:" << nrGraspsInvalidContacts << std::endl;
VR_ASSERT (timeGraspMS.size() == graspScore.size());
VR_ASSERT (timeGraspMS.size() == graspValid.size());
VR_ASSERT (timeGraspMS.size() == graspTypePower.size());
float timeAcc = 0;
float scoreAcc = 0;
int nrGrasps = (int)timeGraspMS.size();
int nrValid = 0;
int nrPower = 0;
int nrPrecision = 0;
for (size_t i=0;i<timeGraspMS.size();i++)
{
timeAcc+=timeGraspMS.at(i);
if (graspValid.at(i))
{
nrValid++;
scoreAcc+=graspScore.at(i);
}
if (graspTypePower.at(i))
nrPower++;
else
nrPrecision++;
}
std::cout << "Time complete: " << timeAcc << " ms" << std::endl;
if (nrGrasps>0)
{
std::cout << "Avg time per grasp (valid&invalid):" << (float)timeAcc / (float)nrGrasps << " ms" << std::endl;
float percPower = (float)nrPower / (float)nrGrasps;
float percPrec = (float)nrPrecision / (float)nrGrasps;
std::cout << "Precision grasps:" << nrPrecision << " -> " << percPrec*100 << "%" << std::endl;
std::cout << "Power grasps:" << nrPower << " -> " << percPower*100 << "%" << std::endl;
}
if (nrValid>0)
{
std::cout << "Avg score (valid):" << scoreAcc / nrValid << std::endl;
}
if (nrGraspsGenerated>0)
std::cout << "Percentage of valid grasps:" << (float)nrGraspsValid / (float)nrGraspsGenerated * 100.0f << "%" << std::endl;
}
static std::string GetCSVHeader()
{
std::stringstream fs;
fs << "minQuality" << ","
<< "nrGraspsGenerated" << ","
<< "nrGraspsValid" << ","
<< "nrGraspsInValid" << ","
<< "nrGraspsValidPrecision" << ","
<< "nrGraspsValidPower" << ","
<< "nrGraspsInvalidCollision" << ","
<< "nrGraspsInvalidFC" << ","
<< "nrGraspsInvalidContacts" << ","
<< "AverageDurationMS" << ","
<< "percPowerGrasps" << ","
<< "percPrecGraps" << ","
<< "avgScore";
return fs.str();
}
std::string toCSVString() const
{
float timeAcc = 0;
float avgTime = 0;
float scoreAcc = 0;
int nrGrasps = (int)timeGraspMS.size();
int nrValid = 0;
int nrPower = 0;
int nrPrecision = 0;
for (size_t i=0;i<timeGraspMS.size();i++)
{
timeAcc+=timeGraspMS.at(i);
if (graspValid.at(i))
{
nrValid++;
scoreAcc+=graspScore.at(i);
}
if (graspTypePower.at(i))
nrPower++;
else
nrPrecision++;
}
float percPower = 0;
float percPrec = 0;
if (nrGrasps>0)
{
percPower = (float)nrPower / (float)nrGrasps;
percPrec = (float)nrPrecision / (float)nrGrasps;
avgTime = timeAcc / (float)nrGrasps;
}
float avgScore = 0;
if (nrValid>0)
{
avgScore = scoreAcc / nrValid;
}
std::stringstream fs;
fs << minQuality << ","
<< nrGraspsGenerated << ","
<< nrGraspsValid << ","
<< (nrGraspsInvalidCollision+nrGraspsInvalidFC+nrGraspsInvalidContacts) << ","
<< nrGraspsValidPrecision << ","
<< nrGraspsValidPower << ","
<< nrGraspsInvalidCollision << ","
<< nrGraspsInvalidFC << ","
<< nrGraspsInvalidContacts << ","
<< avgTime << ","
<< percPower << ","
<< percPrec << ","
<< avgScore;
return fs.str();
}
int nrGraspsGenerated;
int nrGraspsValid;
int nrGraspsInvalidCollision;
int nrGraspsInvalidFC; // or quality
int nrGraspsInvalidContacts;
int nrGraspsValidPrecision;
int nrGraspsValidPower;
std::vector<float> timeGraspMS; // time per grasp generation
std::vector<float> graspScore; //grasp quality
std::vector<bool> graspValid; //grasp valid
std::vector<bool> graspTypePower; //grasp type
bool fcCheck;
float minQuality;
};
GraspPlannerEvaluation();
void print();
static std::string GetCSVHeader();
std::string toCSVString() const;
int nrGraspsGenerated;
int nrGraspsValid;
int nrGraspsInvalidCollision;
int nrGraspsInvalidFC; // or quality
int nrGraspsInvalidContacts;
int nrGraspsValidPrecision;
int nrGraspsValidPower;
std::vector<float> timeGraspMS; // time per grasp generation
std::vector<float> graspScore; //grasp quality
std::vector<bool> graspValid; //grasp valid
std::vector<bool> graspTypePower; //grasp type
bool fcCheck;
float minQuality;
};
std::ostream& operator<< (std::ostream& os, const GraspPlannerEvaluation& rhs);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment