51 catch (
const std::exception& ex)
53 ROS_FATAL(
"Exception during destruction of Visualization: %s", ex.what());
57 ROS_FATAL(
"Exception during destruction of Visualization");
62 const rc_pick_client::LoadCarrier& lc,
const int& lc_no)
64 visualization_msgs::Marker marker;
65 marker.header.frame_id = lc.pose.header.frame_id;
66 marker.type = marker.CUBE;
67 marker.color.r = 0.0f;
68 marker.color.g = 0.20f;
69 marker.color.b = 0.80f;
72 lc.pose.pose.orientation.z, lc.pose.pose.orientation.w),
73 tf2::Vector3(lc.pose.pose.position.x, lc.pose.pose.position.y, lc.pose.pose.position.z));
75 double rim_thickness_x = (lc.outer_dimensions.x - lc.inner_dimensions.x) / 2;
76 double dist_from_center_x = (lc.outer_dimensions.x - rim_thickness_x) / 2;
77 double rim_thickness_y = (lc.outer_dimensions.y - lc.inner_dimensions.y) / 2;
78 double dist_from_center_y = (lc.outer_dimensions.y - rim_thickness_y) / 2;
79 double bottom_thickness = lc.outer_dimensions.z - lc.inner_dimensions.z;
80 tf2::Vector3 pose(0, 0, -(lc.outer_dimensions.z - bottom_thickness) / 2);
83 pose = bin_transform * pose;
85 marker.pose = lc.pose.pose;
86 marker.pose.position.x = pose.getX();
87 marker.pose.position.y = pose.getY();
88 marker.pose.position.z = pose.getZ();
89 marker.scale.x = lc.outer_dimensions.x;
90 marker.scale.y = lc.outer_dimensions.y;
91 marker.scale.z = bottom_thickness;
92 marker_array.markers.push_back(marker);
95 pose = tf2::Vector3(dist_from_center_x, 0, 0);
96 pose = bin_transform * pose;
98 marker.id = lc_no + 1;
99 marker.pose = lc.pose.pose;
100 marker.pose.position.x = pose.getX();
101 marker.pose.position.y = pose.getY();
102 marker.pose.position.z = pose.getZ();
103 marker.scale.x = rim_thickness_x;
104 marker.scale.y = lc.outer_dimensions.y;
105 marker.scale.z = lc.outer_dimensions.z;
106 marker_array.markers.push_back(marker);
108 marker.id = lc_no + 2;
109 pose = tf2::Vector3(-dist_from_center_x, 0, 0);
110 pose = bin_transform * pose;
111 marker.pose.position.x = pose.getX();
112 marker.pose.position.y = pose.getY();
113 marker.pose.position.z = pose.getZ();
114 marker_array.markers.push_back(marker);
117 marker.id = lc_no + 3;
118 pose = tf2::Vector3(0, dist_from_center_y, 0);
119 pose = bin_transform * pose;
120 marker.pose = lc.pose.pose;
121 marker.pose.position.x = pose.getX();
122 marker.pose.position.y = pose.getY();
123 marker.pose.position.z = pose.getZ();
124 marker.scale.x = lc.outer_dimensions.x;
125 marker.scale.y = rim_thickness_y;
126 marker.scale.z = lc.outer_dimensions.z;
127 marker_array.markers.push_back(marker);
129 marker.id = lc_no + 4;
130 pose = tf2::Vector3(0, -dist_from_center_y, 0);
131 pose = bin_transform * pose;
132 marker.pose = lc.pose.pose;
133 marker.pose.position.x = pose.getX();
134 marker.pose.position.y = pose.getY();
135 marker.pose.position.z = pose.getZ();
136 marker.scale.x = lc.outer_dimensions.x;
137 marker_array.markers.push_back(marker);
144 i.action = visualization_msgs::Marker::DELETE;
154 i.action = visualization_msgs::Marker::DELETE;
164 i.action = visualization_msgs::Marker::DELETE;
173 if (!ros_lcs.empty())
176 for (
auto& single_lc : ros_lcs)
179 publishTf(single_lc.pose.pose, single_lc.pose.header.frame_id,
"lc_" + std::to_string(counter));
189 if (!ros_lcs.empty())
192 for (
auto& lc_with_level : ros_lcs)
194 rc_pick_client::LoadCarrier lc;
195 lc.id = lc_with_level.id;
196 lc.outer_dimensions = lc_with_level.outer_dimensions;
197 lc.inner_dimensions = lc_with_level.inner_dimensions;
198 lc.rim_thickness = lc_with_level.rim_thickness;
199 lc.pose = lc_with_level.pose;
200 lc.overfilled = lc_with_level.overfilled;
202 publishTf(lc.pose.pose, lc.pose.header.frame_id,
"lc_" + std::to_string(counter));
213 if (!ros_grasps.empty())
216 visualization_msgs::Marker marker;
217 marker.action = visualization_msgs::Marker::ADD;
218 marker.type = marker.SPHERE;
219 rc_pick_client::Rectangle rect;
220 for (
auto& single_grasp : ros_grasps)
222 rect.x = single_grasp.max_suction_surface_length;
223 rect.y = single_grasp.max_suction_surface_width;
224 setMarker(marker, single_grasp.pose.pose, rect, single_grasp.pose.header.frame_id, counter);
225 publishTf(single_grasp.pose.pose, single_grasp.pose.header.frame_id,
"grasp_" + std::to_string(counter));
236 if (!ros_boxitems.empty())
239 visualization_msgs::Marker marker;
240 marker.type = marker.CUBE;
241 for (
auto& item : ros_boxitems)
243 setMarker(marker, item.pose.pose, item.rectangle, item.pose.header.frame_id, counter);
244 publishTf(item.pose.pose, item.pose.header.frame_id,
"boxitem_" + std::to_string(counter));
253 const rc_pick_client::Rectangle& rectangle, std::string frame_id,
int marker_id)
255 marker.scale.z = 0.001;
256 marker.color.r = 0.800f;
257 marker.color.g = 0.20f;
258 marker.color.b = 0.0f;
259 marker.color.a = 0.80;
260 marker.action = visualization_msgs::Marker::ADD;
261 marker.id = marker_id;
262 marker.header.frame_id = frame_id;
263 marker.pose = item_pose;
264 marker.scale.x = rectangle.x;
265 marker.scale.y = rectangle.y;
271 transform.
setOrigin(
tf::Vector3(ros_pose.position.x, ros_pose.position.y, ros_pose.position.z));
273 tf::Quaternion(ros_pose.orientation.x, ros_pose.orientation.y, ros_pose.orientation.z, ros_pose.orientation.w));
void deleteLoadCarrierMarkers()
void visualizeGrasps(const std::vector< rc_pick_client::SuctionGrasp > &ros_grasps)
void deleteGraspMarkers()
Visualization(const ros::NodeHandle &nh)
void publish(const boost::shared_ptr< M > &message) const
ros::Publisher box_marker_pub_
ros::Publisher lc_marker_pub_
visualization_msgs::MarkerArray markers_lcs_
static void constructLoadCarrier(visualization_msgs::MarkerArray &marker_array, const rc_pick_client::LoadCarrier &lc, const int &lc_no)
void setMarker(visualization_msgs::Marker &marker, const geometry_msgs::Pose &item_pose, const rc_pick_client::Rectangle &rectangle, std::string frame_id, int marker_id)
void publishTf(const geometry_msgs::Pose &ros_pose, std::string frame_id, std::string id)
void visualizeDetectedBoxes(const std::vector< rc_pick_client::Item > &ros_boxitems)
ros::Publisher grasp_marker_pub_
const std::string & getNamespace() const
visualization_msgs::MarkerArray markers_boxes_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void visualizeLoadCarriers(const std::vector< rc_pick_client::LoadCarrier > &ros_lcs)
tf::TransformBroadcaster br_
visualization_msgs::MarkerArray markers_grasps_
void deleteBoxItemMarkers()