From 9bc558ece4933e84d31f859c2360341b4242deae Mon Sep 17 00:00:00 2001 From: Raphael Grimm <raphael.grimm@kit.edu> Date: Mon, 5 Aug 2019 14:33:32 +0200 Subject: [PATCH] Add option for less verbose output to several classes and functions --- GraspPlanning/ApproachMovementGenerator.cpp | 4 ++++ GraspPlanning/ApproachMovementGenerator.h | 4 ++++ GraspPlanning/ApproachMovementSurfaceNormal.cpp | 5 ++++- GraspPlanning/GraspPlanner/GenericGraspPlanner.cpp | 5 ++++- GraspPlanning/MeshConverter.cpp | 7 +++++-- GraspPlanning/MeshConverter.h | 2 +- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/GraspPlanning/ApproachMovementGenerator.cpp b/GraspPlanning/ApproachMovementGenerator.cpp index 494996373..0d85c3551 100644 --- a/GraspPlanning/ApproachMovementGenerator.cpp +++ b/GraspPlanning/ApproachMovementGenerator.cpp @@ -13,6 +13,10 @@ using namespace std; namespace GraspStudio { + void ApproachMovementGenerator::setVerbose(bool v) + { + verbose = v; + } ApproachMovementGenerator::ApproachMovementGenerator(VirtualRobot::SceneObjectPtr object, VirtualRobot::EndEffectorPtr eef, const std::string& graspPreshape) : object(object), eef(eef), graspPreshape(graspPreshape) diff --git a/GraspPlanning/ApproachMovementGenerator.h b/GraspPlanning/ApproachMovementGenerator.h index 48b6416e3..b96e98fc3 100644 --- a/GraspPlanning/ApproachMovementGenerator.h +++ b/GraspPlanning/ApproachMovementGenerator.h @@ -89,6 +89,8 @@ namespace GraspStudio // opens hand by setting the preshape (if defined) or just opening the actors in case no preshape has been defined virtual void openHand(); + void setVerbose(bool v); + protected: @@ -104,6 +106,8 @@ namespace GraspStudio std::string name; std::string graspPreshape; + + bool verbose = false; }; } diff --git a/GraspPlanning/ApproachMovementSurfaceNormal.cpp b/GraspPlanning/ApproachMovementSurfaceNormal.cpp index aa428a57e..a596fe387 100644 --- a/GraspPlanning/ApproachMovementSurfaceNormal.cpp +++ b/GraspPlanning/ApproachMovementSurfaceNormal.cpp @@ -62,7 +62,10 @@ namespace GraspStudio storeApproachDir = (objectModel->faces[faceIndex]).normal; if (std::abs(storeApproachDir.squaredNorm() - 1) > 1e-6f) { - std::cout << "Normal in trimesh not normalized! (normalizing it now)\n"; + if (verbose) + { + std::cout << "Normal in trimesh not normalized! (normalizing it now)\n"; + } storeApproachDir.normalize(); } diff --git a/GraspPlanning/GraspPlanner/GenericGraspPlanner.cpp b/GraspPlanning/GraspPlanner/GenericGraspPlanner.cpp index 606c4e81c..1cb1f8178 100644 --- a/GraspPlanning/GraspPlanner/GenericGraspPlanner.cpp +++ b/GraspPlanning/GraspPlanner/GenericGraspPlanner.cpp @@ -164,7 +164,10 @@ namespace GraspStudio // low number of contacts: check if it helps to move away (small object) if (retreatOnLowContacts && contacts.size() < 2) { - VR_INFO << "Low number of contacts, retreating hand (might be useful for a small object)" << endl; + if (verbose) + { + VR_INFO << "Low number of contacts, retreating hand (might be useful for a small object)" << endl; + } if (moveEEFAway(approach->getApproachDirGlobal(), 5.0f, 10)) { contacts = eef->closeActors(object); diff --git a/GraspPlanning/MeshConverter.cpp b/GraspPlanning/MeshConverter.cpp index 913b504c6..865047b66 100644 --- a/GraspPlanning/MeshConverter.cpp +++ b/GraspPlanning/MeshConverter.cpp @@ -114,7 +114,7 @@ namespace GraspStudio return -1; } - VirtualRobot::ObstaclePtr MeshConverter::RefineObjectSurface(VirtualRobot::ObstaclePtr object, float maxDist) + VirtualRobot::ObstaclePtr MeshConverter::RefineObjectSurface(VirtualRobot::ObstaclePtr object, float maxDist, bool verbose) { VirtualRobot::ObstaclePtr res; @@ -130,7 +130,10 @@ namespace GraspStudio return res; } - VR_INFO << "Processing object with " << tm->faces.size() << " triangles" << endl; + if (verbose) + { + VR_INFO << "Processing object with " << tm->faces.size() << " triangles" << endl; + } // first create new object TriMeshModelPtr triMesh2(new TriMeshModel()); diff --git a/GraspPlanning/MeshConverter.h b/GraspPlanning/MeshConverter.h index c29bc391e..4f7f1156c 100644 --- a/GraspPlanning/MeshConverter.h +++ b/GraspPlanning/MeshConverter.h @@ -40,7 +40,7 @@ namespace GraspStudio */ static VirtualRobot::ManipulationObjectPtr CreateManipulationObject(const std::string& name, VirtualRobot::MathTools::ConvexHull3DPtr hull); static VirtualRobot::TriMeshModelPtr CreateTriMeshModel(VirtualRobot::MathTools::ConvexHull3DPtr hull); - static VirtualRobot::ObstaclePtr RefineObjectSurface(VirtualRobot::ObstaclePtr object, float maxDist); + static VirtualRobot::ObstaclePtr RefineObjectSurface(VirtualRobot::ObstaclePtr object, float maxDist, bool verbose = true); //! Returns -1 if obj is not part of vectList, otherwise the index of vectList is returned. static int hasVertex(std::vector< Eigen::Vector3f>& vectList, Eigen::Vector3f& obj); -- GitLab