77 ROS_WARN(
"Trying to initialize already initialized visualization, doing nothing.");
83 eband_local_planner::EBandPlannerConfig& config)
94 ROS_ERROR(
"Visualization not yet initialized, please call initialize() before using visualization");
98 visualization_msgs::MarkerArray eband_msg;
99 eband_msg.markers.resize(band.size());
101 visualization_msgs::MarkerArray eband_heading_msg;
102 eband_heading_msg.markers.resize(band.size());
103 std::string marker_heading_name_space = marker_name_space;
104 marker_heading_name_space.append(
"_heading");
107 for(
int i = 0; i < ((int) band.size()); i++)
127 ROS_ERROR(
"Visualization not yet initialized, please call initialize() before using visualization");
131 visualization_msgs::Marker bubble_msg;
146 ROS_ERROR(
"Visualization not yet initialized, please call initialize() before using visualization");
150 visualization_msgs::Marker bubble_msg;
153 bubbleToMarker(bubble, bubble_msg, marker_name_space, marker_id, marker_color);
165 ROS_ERROR(
"Visualization not yet initialized, please call initialize() before using visualization");
169 visualization_msgs::MarkerArray forces_msg;
170 forces_msg.markers.resize(forces.size());
174 if(marker_name_space.compare(
"internal_forces") == 0)
177 if(marker_name_space.compare(
"external_forces") == 0)
180 if(marker_name_space.compare(
"resulting_forces") == 0)
181 marker_color =
green;
183 for(
int i = 0; i < ((int) forces.size()); i++)
186 forceToMarker(forces[i], band[i].center.pose, forces_msg.markers[i], marker_name_space, i, marker_color);
198 ROS_ERROR(
"Visualization not yet initialized, please call initialize() before using visualization");
202 visualization_msgs::Marker force_msg;
214 geometry_msgs::Pose2D tmp_pose2d;
218 marker.header.frame_id = bubble.
center.header.frame_id;
221 marker.ns = marker_name_space;
222 marker.id = marker_id;
223 marker.type = visualization_msgs::Marker::SPHERE;
224 marker.action = visualization_msgs::Marker::ADD;
227 marker.pose = bubble.
center.pose;
230 marker.pose.position.z = 0;
237 marker.color.r = 0.0f;
238 marker.color.g = 0.0f;
239 marker.color.b = 0.0f;
242 case red: { marker.color.r = 1.0f;
break; }
243 case green: { marker.color.g = 1.0f;
break; }
244 case blue: { marker.color.b = 1.0f;
break; }
247 marker.color.a = 0.75;
256 geometry_msgs::Pose2D tmp_pose2d;
260 marker.header.frame_id = bubble.
center.header.frame_id;
263 marker.ns = marker_name_space;
264 marker.id = marker_id;
265 marker.type = visualization_msgs::Marker::ARROW;
266 marker.action = visualization_msgs::Marker::ADD;
269 marker.pose = bubble.
center.pose;
274 marker.scale.x = 0.9;
275 marker.scale.y = 0.45;
276 marker.scale.z = 0.45;
279 marker.color.r = 0.0f;
280 marker.color.g = 0.0f;
281 marker.color.b = 0.0f;
284 case red: { marker.color.r = 1.0f;
break; }
285 case green: { marker.color.g = 1.0f;
break; }
286 case blue: { marker.color.b = 1.0f;
break; }
289 marker.color.a = 1.0;
296 void EBandVisualization::forceToMarker(geometry_msgs::WrenchStamped wrench, geometry_msgs::Pose wrench_origin, visualization_msgs::Marker& marker, std::string marker_name_space,
int marker_id,
Color marker_color)
298 geometry_msgs::Pose2D tmp_pose2d;
302 marker.header.frame_id = wrench.header.frame_id;
305 marker.ns = marker_name_space;
306 marker.id = marker_id;
307 marker.type = visualization_msgs::Marker::ARROW;
308 marker.action = visualization_msgs::Marker::ADD;
311 marker.pose.position = wrench_origin.position;
318 if( (wrench.wrench.force.x != 0) || (wrench.wrench.force.y != 0) || (wrench.wrench.torque.z != 0) )
322 Eigen::Vector3d x_axis(1.0, 0.0, 0.0);
324 Eigen::Vector3d rotation_axis(1.0, 0.0, 0.0);
325 double rotation_angle = 0.0;
328 target_vec.normalize();
329 if(!(x_axis == target_vec))
332 rotation_axis = x_axis.cross(target_vec);
333 rotation_angle = x_axis.dot(target_vec);
334 rotation_angle =
acos(rotation_angle);
337 rotation_axis.normalize();
338 const double s =
sin(rotation_angle/2);
339 const double c =
cos(rotation_angle/2);
340 Eigen::Quaterniond rotate_quat(c, s*rotation_axis.x(), s*rotation_axis.y(), s*rotation_axis.z());
344 geometry_msgs::Quaternion orientation_msg;
349 marker.pose.orientation = orientation_msg;
352 double scale =
sqrt( (wrench.wrench.force.x * wrench.wrench.force.x) + (wrench.wrench.force.y * wrench.wrench.force.y) +
354 marker.scale.x = scale;
355 marker.scale.y = scale;
356 marker.scale.z = scale;
359 marker.color.r = 0.0f;
360 marker.color.g = 0.0f;
361 marker.color.b = 0.0f;
364 case red: { marker.color.r = 1.0f;
break; }
365 case green: { marker.color.g = 1.0f;
break; }
366 case blue: { marker.color.b = 1.0f;
break; }
369 marker.color.a = 1.25;
374 marker.pose.orientation = wrench_origin.orientation;
377 marker.scale.x = 0.0;
378 marker.scale.y = 0.0;
379 marker.scale.z = 0.0;
382 marker.color.r = 0.0f;
383 marker.color.g = 0.0f;
384 marker.color.b = 0.0f;
387 marker.color.a = 0.0;
void publish(const boost::shared_ptr< M > &message) const
void reconfigure(EBandPlannerConfig &config)
Reconfigures the parameters of the planner.
void bubbleHeadingToMarker(Bubble bubble, visualization_msgs::Marker &marker, std::string marker_name_space, int marker_id, Color marker_color)
converts the haeding of a bubble into a Arrow-Marker msg - this is visualization-specific ...
void publishBubble(std::string marker_name_space, int marker_id, Bubble bubble)
publishes a single bubble as a Marker
void bubbleToMarker(Bubble bubble, visualization_msgs::Marker &marker, std::string marker_name_space, int marker_id, Color marker_color)
converts a bubble into a Marker msg - this is visualization-specific
void publishBand(std::string marker_name_space, std::vector< Bubble > band)
publishes the bubbles (Position and Expansion) in a band as Marker-Array
double getCircumscribedRadius(costmap_2d::Costmap2DROS &costmap)
Gets the footprint of the robot and computes the circumscribed radius for the eband approach...
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
ros::Publisher one_bubble_pub_
publishes markers to visualize bubbles of elastic band ("modified global plan")
static void quaternionTFToMsg(const Quaternion &bt, geometry_msgs::Quaternion &msg)
costmap_2d::Costmap2DROS * costmap_ros_
pointer to costmap - needed to retrieve information about robot geometry
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
~EBandVisualization()
Default destructor.
void publishForceList(std::string marker_name_space, std::vector< geometry_msgs::WrenchStamped > forces, std::vector< Bubble > band)
publishes the list of forces along the band as Marker-Array
void initialize(ros::NodeHandle &pn, costmap_2d::Costmap2DROS *costmap_ros)
Initializes the visualization class.
INLINE Rall1d< T, V, S > acos(const Rall1d< T, V, S > &x)
void quaternionEigenToTF(const Eigen::Quaterniond &e, tf::Quaternion &t)
void forceToMarker(geometry_msgs::WrenchStamped wrench, geometry_msgs::Pose wrench_origin, visualization_msgs::Marker &marker, std::string marker_name_space, int marker_id, Color marker_color)
converts a wrench into a Marker msg - this is visualization-specific
ros::Publisher bubble_pub_
publishes markers to visualize bubbles of elastic band ("modified global plan")
EBandVisualization()
Default constructor.
geometry_msgs::PoseStamped center
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
void publishForce(std::string marker_name_space, int id, Color marker_color, geometry_msgs::WrenchStamped force, Bubble bubble)
publishes a single force as a Marker
void PoseToPose2D(const geometry_msgs::Pose pose, geometry_msgs::Pose2D &pose2D)
Converts a frame of type Pose to type Pose2D (mainly -> conversion of orientation from quaternions to...