22 #include <ISM/utility/GeometryHelper.hpp> 28 #include <Eigen/Geometry> 29 #include <boost/filesystem.hpp> 30 #include <boost/filesystem/path.hpp> 31 #include <boost/algorithm/string.hpp> 32 #include <boost/random/uniform_real.hpp> 33 #include <boost/random/mersenne_twister.hpp> 34 #include <boost/random/variate_generator.hpp> 51 if(attributed_point_cloud.elements.size() == 0 || result->referencePose ==
nullptr)
53 ROS_ERROR(
"No matching scene for prediction. Skipping visualization");
63 for (asr_msgs::AsrAttributedPoint attributed_point: attributed_point_cloud.elements)
65 ISM::PointPtr ism_point_ptr(
new ISM::Point(attributed_point.pose.position.x,
66 attributed_point.pose.position.y,
67 attributed_point.pose.position.z));
68 ISM::QuaternionPtr ism_quat_ptr(
new ISM::Quaternion(attributed_point.pose.orientation.w,
69 attributed_point.pose.orientation.x,
70 attributed_point.pose.orientation.y,
71 attributed_point.pose.orientation.z));
72 ISM::PosePtr ism_pose_ptr(
new ISM::Pose(ism_point_ptr, ism_quat_ptr));
74 ISM::Object oPtr(attributed_point.type, ism_pose_ptr, attributed_point.identifier,
mesh_resource_paths_[attributed_point.type].string());
77 std::vector<ISM::PosePtr> temp_vector;
86 if(valid_position_viz){
112 std::string voter_namespace;
118 std::vector<std::string> object_axis;
121 std::map<std::string, int> axis_map;
122 for(uint k = 0; k < object_axis.size(); k++){
123 if(!object_axis[k].empty()){
124 std::vector<std::string> temp_tokens;
125 boost::split(temp_tokens, object_axis[k], boost::is_any_of(
"-"));
126 if(!temp_tokens[0].empty() && !temp_tokens[1].empty()){
128 if(temp_tokens[1].compare(
"X") == 0) axis = 0;
129 else if(temp_tokens[1].compare(
"Y") == 0) axis = 1;
130 else if(temp_tokens[1].compare(
"Z") == 0) axis = 2;
131 axis_map.insert(std::make_pair(temp_tokens[0], axis));
140 voter_namespace =
"positions_of_" + voter_to_pose_map_iter.first.type;
147 if(axis_map.find(voter_to_pose_map_iter.first.type) != axis_map.end()){
148 axis = axis_map[voter_to_pose_map_iter.first.type];
150 for(ISM::PosePtr pose : voter_to_pose_map_iter.second){
152 MarkerArray temp_marker =
VizHelperRVIZ::createPositionVector(pose,
base_frame_, voter_namespace, vp_vector_color, udg,
object_sampels_, axis,
id,
sphere_radius_ *
sample_scale_,
max_angle_scale_ * sample_scale_,
sphere_radius_,
marker_lifetime_);
154 ret_marker.markers.insert(ret_marker.markers.end(), temp_marker.markers.begin(), temp_marker.markers.end());
174 std::string marker_namespace =
"selected_prediction_pose";
177 boost::filesystem::path object_ressource_path = object_ptr.ressourcePath;
189 ring_marker =
VizHelperRVIZ::createRingMarker(pose,
base_frame_,
"ring_marker", 0.1, color_red, color_red, color_red, color_red, color_red, color_red,
marker_lifetime_);
208 ISM::PointPtr camera_point_ptr = camera_object_ptr->pose->point;
210 ISM::QuaternionPtr camera_quat_ptr = camera_object_ptr->pose->quat;
223 Eigen::Quaternion<double> rot = ISM::GeometryHelper::quatToEigenQuat(quat_ptr);
224 Eigen::Matrix3d euler_angle = rot.toRotationMatrix();
225 Eigen::Vector3d vector = euler_angle.eulerAngles(2, 0, 2);
227 Eigen::Quaternion<double> camera_rot = ISM::GeometryHelper::quatToEigenQuat(camera_quat_ptr);
228 Eigen::Matrix3d camera_euler_angle = camera_rot.toRotationMatrix();
229 Eigen::Vector3d camera_vector = camera_euler_angle.eulerAngles(2, 0, 2);
247 std::string voter_namespace;
252 voter_namespace =
"prediction_of_" + iter.first.type;
256 std::vector<std::pair<ISM::PointPtr, std::vector<ISM::PosePtr>>> pose_vector;
257 pose_vector.push_back(std::make_pair(result->referencePose->point, iter.second));
260 ret_marker.markers.insert(ret_marker.markers.end(), temp_arrow_markers.markers.begin(), temp_arrow_markers.markers.end());
void publishCollectedMarkers()
static MarkerArray createRingMarker(ISM::PosePtr pose, std::string baseFrame, std::string markerNamespace, float scale, ColorRGBA x, ColorRGBA y, ColorRGBA z, ColorRGBA a, ColorRGBA b, ColorRGBA g, double markerLifetime)
static ColorRGBA hsvToRGBA(double hue, double saturation, double value)
std::string object_axis_map_
VP stuff.
static ColorRGBA getColorOfObject(const ISM::Object &object)
MarkerArray generatePredictionMarker(ISM::RecognitionResultPtr result)
generates prediction markers
visualization_msgs::Marker Marker
std::map< std::string, boost::filesystem::path > mesh_resource_paths_
void updateObjectMarker()
updates marker of selected object
static Marker createSphereMarker(ISM::PointPtr point, std::string baseFrame, std::string markerNamespace, int id, float radius, ColorRGBA color, double markerLifetime)
static MarkerArray createCoordinateArrow(std::vector< std::pair< ISM::PointPtr, std::vector< ISM::PosePtr > > > poses_vec, std::string baseFrame, std::string markerNamespace, float arrowScale, float axisScale, ColorRGBA color, double markerLifetime)
MarkerArray generateValidPositions(ISM::RecognitionResultPtr result)
generates markers for validPositionSpace visualization
static ColorRGBA createColorRGBA(float red, float green, float blue, float alpha)
std::map< ISM::Object, std::vector< ISM::PosePtr > > object_type_to_poses_map_
void nextObject()
increments object counter and uptates object marker
std_msgs::ColorRGBA ColorRGBA
std::vector< ColorRGBA > dist_color_
visualization_msgs::MarkerArray MarkerArray
void addMarker(visualization_msgs::Marker marker)
static Marker createMeshMarker(ISM::PosePtr pose, std::string baseFrame, std::string markerNamespace, int id, ColorRGBA color, double markerLifetime, std::string resourcePath)
void calculateDistColor(ISM::ObjectPtr camera_object_ptr)
double pose_prediction_value_
double pose_prediction_alpha_
void addVisualization(ISM::RecognitionResultPtr result, asr_msgs::AsrAttributedPointCloud attributed_point_cloud, bool valid_position_viz)
boost::variate_generator< boost::mt19937, boost::uniform_real<> > UniformDistributionGenerator
void nextPose()
increments posecounter and uptates object marker
static MarkerArray createPositionVector(ISM::PosePtr pose, std::string baseFrame, std::string markerNamespace, ColorRGBA color, UniformDistributionGenerator *udg, int sampels, int axis, int id, float length, float openAngle, float sphereRadius, double markerLifetime)
double max_distance_in_overlay_
std::string base_frame_
PP stuff.
std::map< int, ISM::Object > id_to_object_name_map_