19 #include "ISM/utility/GeometryHelper.hpp" 20 #include "Eigen/Geometry" 24 std::string name_space,
26 NAME_SPACE_(name_space),
27 PREDICTOR_TYPE_(predictor_type)
30 ROS_INFO_STREAM(
"Pose prediction is run with database " << database_filename);
31 table_helper_ = ISM::TableHelperPtr(
new ISM::TableHelper(database_filename));
35 for(std::string pattern_name :
table_helper_->getModelPatternNames())
38 ISM::ObjectToVoteMap object_votes =
table_helper_->getVoteSpecifiersForPatternAndObjects(pattern_name, objects_in_pattern);
39 votes_[pattern_name] = object_votes;
41 for (
IsmObject object : objects_in_pattern)
46 .at(
object.second).size();
67 for (
unsigned int i = 0; i < level; ++i)
72 table_helper_->getObjectTypesAndIdsBelongingToPattern(pattern_name);
73 for (
IsmObject object : objects_in_pattern)
81 "There must be more than one predecessor, otherwise all objects are in the reference");
82 ISM::PosePtr current_pose(reference_pose_ptr);
83 for (IsmObjects::iterator predecessors_it = path_to_object.begin();
84 predecessors_it + 1 != path_to_object.end();
88 std::vector<VoteSpecifierPtr> specifiers =
votes_ 89 .at(predecessors_it->first)
90 .at((predecessors_it + 1)->first)
91 .at((predecessors_it + 1)->second);
92 unsigned int index = rand() % specifiers.size();
93 VoteSpecifierPtr specifier = specifiers.at(index);
94 PointPtr absolute_position = GeometryHelper::getSourcePoint(current_pose,
95 specifier->refToObjectQuat,
100 double r_x, r_y, r_z;
105 }
while(std::sqrt(r_x * r_x + r_y * r_y + r_z * r_z) >
SPHERE_RADIUS);
106 absolute_position->eigen.x() = absolute_position->eigen.x() + r_x;
107 absolute_position->eigen.y() = absolute_position->eigen.y() + r_y;
108 absolute_position->eigen.z() = absolute_position->eigen.z() + r_z;
114 q = Eigen::AngleAxisd(GeometryHelper::deg2rad(r_x), Eigen::Vector3d::UnitX())
115 * Eigen::AngleAxisd(GeometryHelper::deg2rad(r_y), Eigen::Vector3d::UnitY())
116 * Eigen::AngleAxisd(GeometryHelper::deg2rad(r_z), Eigen::Vector3d::UnitZ());
119 PosePtr absolute_pose = GeometryHelper::getSourcePose(current_pose, absolute_position, specifier->refToObjectPoseQuat);
120 current_pose = absolute_pose;
123 current_pose->quat = ISM::GeometryHelper::eigenQuatToQuat(ISM::GeometryHelper::quatToEigenQuat(current_pose->quat) * q);
152 return strm << (*pPtr);
157 std::string type_string;
160 case Shortest: type_string =
"ShortestPath";
break;
161 case Best: type_string =
"BestPath";
break;
162 case Random: type_string =
"RandomPath";
break;
163 case PPNonNor: type_string =
"PaperPredictionNonNormalized";
break;
164 case PPNor: type_string =
"PaperPredictionNormalized";
break;
165 default: type_string =
"Unknown Predictor";
167 return strm << type_string;
FoundObjects found_objects_
ISM::PatternToObjectToVoteMap votes_
const std::string NAME_SPACE_
AttributedPointCloud attributed_point_cloud_
std::set< IsmObject > IsmObjectSet
std::ostream & operator<<(std::ostream &strm, const PosePredictor &p)
PosePredictor(std::string database_filename, std::string name_space, PredictorType predictor_type)
void traverseISM(std::string pattern_name, unsigned int level)
AttributedPointCloud getAttributedPointCloud() const
UniformDistributionGenerator * udg_rot_
ISM::PosePtr predictPose(ISM::PosePtr reference_pose_ptr, IsmObjects path_to_object)
UniformDistributionGenerator * udg_dist_
#define ROS_ASSERT_MSG(cond,...)
ISM::TableHelperPtr table_helper_
std::string getMarkerNameSpace() const
SizeMap specifiers_size_map_
#define ROS_DEBUG_STREAM(args)
std::pair< std::string, std::string > IsmObject
const PredictorType PREDICTOR_TYPE_
PredictorType getPredictorType() const
#define ROS_INFO_STREAM(args)
std::vector< FoundObject > FoundObjects
std::vector< IsmObject > IsmObjects
void setFoundObjects(const FoundObjects &value)
asr_msgs::AsrAttributedPointCloud AttributedPointCloud