21 #include <robot_model_services/robot_model/impl/MILDRobotState.hpp> 28 ROS_ERROR(
"DefaultRatingModule constructor: mDebugHelperPtr is null");
32 bool useTargetRobotState,
33 const robot_model_services::RobotModelPtr &robotModelPtr,
57 mDebugHelperPtr->writeNoticeably(
"STARTING DEFAULTRATINGMODULE::SET-BEST-SCORE-CONTAINER METHOD",
70 for (ObjectTypePowerSet::iterator subSetIter = powerSetPtr->begin(); subSetIter != powerSetPtr->end(); ++subSetIter) {
82 if (!viewport.
score) {
83 ROS_ERROR(
"Single score result is nullpointer.");
86 viewports->push_back(viewport);
90 mDebugHelperPtr->writeNoticeably(
"ENDING DEFAULTRATINGMODULE::SET-BEST-SCORE-CONTAINER METHOD",
96 mDebugHelperPtr->writeNoticeably(
"STARTING DEFAULTRATINGMODULE::GET-BEST-VIEWPORT METHOD",
100 if (viewports->size() == 0) {
101 mDebugHelperPtr->writeNoticeably(
"ENDING DEFAULTRATINGMODULE::GET-BEST-VIEWPORT METHOD",
107 float utilityNormalization = 0.0;
110 float utility = viewport.
score->getUnweightedUnnormalizedUtility();
111 if (utility > utilityNormalization) {
112 utilityNormalization = utility;
117 viewport.
score->setUtilityNormalization(utilityNormalization);
119 float weightedNormalizedUtility =
mOmegaUtility * viewport.
score->getUnweightedUnnormalizedUtility() / utilityNormalization;
120 viewport.
score->setWeightedNormalizedUtility(weightedNormalizedUtility);
130 for (
unsigned int i = 0; i < viewportsSorted->size(); i++) {
131 mDebugHelperPtr->write(std::stringstream() <<
"THIS IS VIEWPORT NR. " << i+1 <<
" IN THE SORTED LIST.",
147 mDebugHelperPtr->writeNoticeably(
"ENDING DEFAULTRATINGMODULE::GET-BEST-VIEWPORT METHOD",
158 ROS_ERROR(
"Score container a is nullpointer");
162 ROS_ERROR(
"Score container b is nullpointer");
168 return ratingA < ratingB;
179 float maxUtility = 0.0;
185 maxUtility = std::max(this->
getNormalUtility(viewport, objectNormalVector, objectPosition), maxUtility);
214 SimpleVector3 objectToCameraVector = cameraPosition - objectPosition;
220 float distanceToMid = std::abs(projection-(
mFcp+
mNcp)/2.0);
221 float distanceThreshold = std::abs((
mFcp-
mNcp)/2.0);
238 SimpleVector3 objectToCameraVector = cameraPosition - objectPosition;
239 SimpleVector3 objectToCameraVectorNormalized = objectToCameraVector.normalized();
254 float utility = sideUtility * proximityUtility;
267 ROS_ERROR(
"Score container is nullpointer");
271 ROS_ERROR(
"Omega parameters were not set correctly");
274 float result = (a->getWeightedNormalizedUtility() + a->getWeightedInverseCosts()) /
mRatingNormalization;
290 defRatingPtr->setUnweightedUnnormalizedUtility(utility);
292 BOOST_FOREACH(std::string objectType, *(candidateViewport.
object_type_set)) {
301 defRatingPtr->setWeightedInverseCosts(costs);
308 candidateViewport.
score = defRatingPtr;
352 if (deviation < threshold) {
353 return .5 + .5 * cos(deviation * M_PI / threshold);
359 double utility = 0.0;
362 BOOST_FOREACH(std::string objectType, *(candidateViewport.
object_type_set)) {
378 BOOST_FOREACH(
int index, *(candidateViewport.
child_indices)) {
381 if (objectPoint.
type != objectType) {
424 robot_model_services::MILDRobotStatePtr state = boost::static_pointer_cast<robot_model_services::MILDRobotState>(
mTargetState);
428 mDebugHelperPtr->write(std::stringstream() <<
"View removed because the calculated robot state isn't reachable.",
439 throw "Maximum recognition costs are 0.";
444 BOOST_FOREACH(std::string objectType, *(targetViewport.
object_type_set)) {
449 return normalizedRecognitionCosts;
498 double maxRecognitionCosts = 0;
499 std::vector<std::string> types;
501 BOOST_FOREACH(
ObjectPoint objectPoint, *(inputCloud)) {
503 if (std::find(types.begin(), types.end(), objectPoint.
type) == types.end()) {
505 types.push_back(objectPoint.
type);
void setUnweightedUnnormalizedObjectUtilities(const ViewportPoint &candidateViewport, std::string objectType)
sets the mObjectUtilities member.
void setFrustumParameters(double fovV, double fovH, double fcp, double ncp)
double getNormalAngleThreshold()
float getRating(const BaseScoreContainerPtr &a)
returns the weighted rating of a rating object.
float getFrustumPositionUtility(const ViewportPoint &viewport, ObjectPoint &objectPoint)
returns the utility of the position of an object in the frustum of a given camera viewport...
float getOrientationUtility(const ViewportPoint &viewport, ObjectPoint &objectPoint)
returns the orientation utility of an object point for a given camera viewport. The orientation utili...
bool getBestViewport(ViewportPointCloudPtr &viewports, ViewportPoint &bestViewport)
Sets the best viewport from the given viewports cloud.
Precision mUnweightedInverseMovementCostsPTU
void setRatingNormalization()
sets the mRatingNormalization member
Precision mUnweightedInverseMovementCostsBaseRotation
bool mUseProximityUtility
MapHelperPtr mMapHelperPtr
double mWeightedInverseMovementCosts
SimpleVector3CollectionPtr normal_vectors
ViewportPointCloud::Ptr ViewportPointCloudPtr
Eigen::Matrix< Precision, 3, 1 > SimpleVector3
static Precision getAngle(const SimpleVector3 &X, const SimpleVector3 &Y)
virtual ObjectPointCloudPtr & getInputCloud()
void setInputCloud(const ObjectPointCloudPtr &pointCloudPtr)
setting the input cloud.
bool mUseOrientationUtility
void setMaxRecognitionCosts()
sets the mMaxRecognitionCosts member. Must be called before calling getNormalizedRecognitionCosts eve...
double mRatingNormalization
float getNormalizedRating(float deviation, float threshold)
returns the normalized rating for a given deviation from the optimum and a threshold for the deviatio...
double mNormalAngleThreshold
CameraModelFilterPtr mCameraModelFilterPtr
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
bool setBestScoreContainer(const ViewportPoint ¤tViewport, ViewportPoint &candidateViewport)
Sets the best score for the given candidate camera viewport by choosing the best combination of objec...
SimpleQuaternion getSimpleQuaternion() const
BaseScoreContainerPtr getScoreContainerInstance()
DefaultScoreContainerPtr score
TFSIMD_FORCE_INLINE Vector3 normalized() const
boost::shared_ptr< DefaultScoreContainer > DefaultScoreContainerPtr
Definition for the shared pointer type of the class.
float getSideUtility(const ViewportPoint &viewport, const ObjectPoint &objectPoint)
returns the side utility of a given object point for a given camera viewport. The side utility is alw...
virtual ~DefaultRatingModule()
bool compareScoreContainer(const BaseScoreContainerPtr &a, const BaseScoreContainerPtr &b)
compares two ratings.
virtual bool compareViewports(const ViewportPoint &a, const ViewportPoint &b)=0
compares two viewports
this namespace contains all generally usable classes.
void setRobotState(robot_model_services::RobotStatePtr robotState)
setRobotState sets mRobotModelPtr's state.
pcl::PointCloud< ViewportPoint > ViewportPointCloud
void setUtilityParameters(bool useOrientationUtility=true, bool useProximityUtility=true, bool useSideUtility=true)
DebugHelperPtr mDebugHelperPtr
DefaultScoreContainer implements the BaseScoreContainer base class.
static boost::shared_ptr< DebugHelper > getInstance()
static SimpleVector3 getVisualAxis(const SimpleQuaternion &orientation)
robot_model_services::RobotModelPtr mRobotModelPtr
bool filterObjectPointCloudByTypes(const ObjectTypeSetPtr &objectTypeSetPtr, ViewportPoint &viewportPoint)
filters all the objects in this viewport with one of the given types and puts them in a new viewport...
void resetCache()
resets the cached data for a call of setBestScoreContainer
bool compareViewports(const ViewportPoint &a, const ViewportPoint &b)
compares two viewports
std::map< std::string, float > mUnweightedUnnormalizedObjectUtilities
SimpleVector3 getPosition() const
double mMaxRecognitionCosts
static double degToRad(double input)
static double getDotProduct(SimpleVector3 v1, SimpleVector3 v2)
SimpleVector3 getPosition() const
void setUseTargetRobotState(bool useTargetRobotState)
double mUnweightedInverseRecognitionCosts
void setWeightedInverseMovementCosts()
sets the mMovementCosts member. Must be called before calling setRatingNormalization.
ObjectPointCloud::Ptr ObjectPointCloudPtr
double intermediate_object_weight
double getUnweightedInverseRecognitionCosts(const ViewportPoint &targetViewport)
returns the inverse recognition costs for the objects in the target viewport
virtual void setInputCloud(const ObjectPointCloudPtr &pointCloudPtr)
setting the input cloud.
double getUnweightedUnnormalizedUtility(const ViewportPoint &candidateViewport)
returns the utility for the given candidate camera viewport.
float getProximityUtility(const ViewportPoint &viewport, const ObjectPoint &objectPoint)
returns the proximity utility of a given object point for a given camera viewport. The proximizy utility is always between 0.0 and 1.0. Depends on the distance between the object and the camera.
float getNormalizedAngleUtility(const SimpleVector3 v1, const SimpleVector3 v2, double angleThreshold)
returns a rating for the difference between the two given normals.
Eigen::Quaternion< Precision > SimpleQuaternion
RatingModule is a generalization for the rating of the point cloud objects and viewports.
double getWeightedInverseCosts(const ViewportPoint &sourceViewport, const ViewportPoint &targetViewport)
returns the inverse costs for the movement from the source to the target viewport and the recognition...
robot_model_services::RobotStatePtr mTargetState
IndicesPtr active_normal_vectors
void setNormalAngleThreshold(double angle)
sets the threshold for the angle between the orientation of an object and the camera orientation...
DefaultRatingModule implements the functionlities offered by RatingModule.
ObjectTypeSetPtr object_type_set
bool setSingleScoreContainer(const ViewportPoint ¤tViewport, ViewportPoint &candidateViewport)
sets the score container for one filtered camera viewport Before calling this method, the method resetCache() should be called.
bool mUseTargetRobotState
Precision mUnweightedInverseMovementCostsBaseTranslation
float getNormalUtility(const ViewportPoint &viewport, const SimpleVector3 &objectNormalVector, const SimpleVector3 &objectPosition)
returns the utility of one object normal for a given camera viewport. The normal utility is always be...
void setOmegaParameters(double omegaUtility, double omegaPan, double omegaTilt, double omegaRot, double omegaBase, double omegaRecognition)
Set the weights of the movements of each component.