rviz_visual_tools.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2015, University of Colorado, Boulder
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the Univ of CO, Boulder nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 /* Author: Dave Coleman <dave@dav.ee>, Andy McEvoy
00036    Desc:   Helper functions for displaying basic shape markers in Rviz
00037 */
00038 
00039 #ifndef RVIZ_VISUAL_TOOLS_RVIZ_VISUAL_TOOLS_H
00040 #define RVIZ_VISUAL_TOOLS_RVIZ_VISUAL_TOOLS_H
00041 
00042 #include <ros/ros.h>
00043 
00044 // C++
00045 #include <string>
00046 #include <vector>
00047 
00048 // Eigen
00049 #include <Eigen/Geometry>
00050 
00051 // Rviz
00052 #include <visualization_msgs/Marker.h>
00053 #include <visualization_msgs/MarkerArray.h>
00054 
00055 // Boost
00056 #include <boost/shared_ptr.hpp>
00057 
00058 // Messages
00059 #include <std_msgs/ColorRGBA.h>
00060 #include <graph_msgs/GeometryGraph.h>
00061 #include <geometry_msgs/PoseArray.h>
00062 #include <geometry_msgs/PoseStamped.h>
00063 #include <geometry_msgs/Polygon.h>
00064 #include <trajectory_msgs/JointTrajectory.h>
00065 
00066 // rviz_visual_tools
00067 #include <rviz_visual_tools/deprecation.h>
00068 
00069 namespace rviz_visual_tools
00070 {
00071 // Default constants
00072 static const std::string RVIZ_MARKER_TOPIC = "/rviz_visual_tools";
00073 static const double SMALL_SCALE = 0.001;
00074 static const double LARGE_SCALE = 100;
00075 
00076 // Note: when adding new colors to colors, also add them to getRandColor() function
00077 enum colors
00078 {
00079   BLACK = 0,
00080   BROWN = 1,
00081   BLUE = 2,
00082   CYAN = 3,
00083   GREY = 4,
00084   DARK_GREY = 5,
00085   GREEN = 6,
00086   LIME_GREEN = 7,
00087   MAGENTA = 8,
00088   ORANGE = 9,
00089   PURPLE = 10,
00090   RED = 11,
00091   PINK = 12,
00092   WHITE = 13,
00093   YELLOW = 14,
00094   TRANSLUCENT = 15,
00095   TRANSLUCENT_LIGHT = 16,
00096   TRANSLUCENT_DARK = 17,
00097   RAND = 18,
00098   CLEAR = 19,
00099   DEFAULT = 20 // i.e. 'do not change default color'
00100 };
00101 
00102 enum scales
00103 {
00104   XXSMALL,
00105   XSMALL,
00106   SMALL,
00107   REGULAR,
00108   LARGE,
00109   xLARGE,
00110   xxLARGE,
00111   xxxLARGE,
00112   XLARGE,
00113   XXLARGE
00114 };
00115 
00119 struct RandomPoseBounds
00120 {
00121   double x_min_, x_max_;
00122   double y_min_, y_max_;
00123   double z_min_, z_max_;
00124   double elevation_min_, elevation_max_;
00125   double azimuth_min_, azimuth_max_;
00126   double angle_min_, angle_max_;
00127 
00128   RandomPoseBounds(double x_min = 0.0, double x_max = 1.0, double y_min = 0.0, double y_max = 1.0, double z_min = 0.0,
00129                    double z_max = 1.0, double elevation_min = 0.0, double elevation_max = M_PI,
00130                    double azimuth_min = 0.0, double azimuth_max = 2 * M_PI, double angle_min = 0.0,
00131                    double angle_max = 2 * M_PI)
00132   {
00133     x_min_ = x_min;
00134     x_max_ = x_max;
00135     y_min_ = y_min;
00136     y_max_ = y_max;
00137     z_min_ = z_min;
00138     z_max_ = z_max;
00139     elevation_min_ = elevation_min;
00140     elevation_max_ = elevation_max;
00141     azimuth_min_ = azimuth_min;
00142     azimuth_max_ = azimuth_max;
00143     angle_min_ = angle_min;
00144     angle_max_ = angle_max;
00145   }
00146 };
00147 
00151 struct RandomCuboidBounds
00152 {
00153   double cuboid_size_min_, cuboid_size_max_;
00154 
00155   explicit RandomCuboidBounds(double cuboid_size_min = 0.02, double cuboid_size_max = 0.15)
00156   {
00157     cuboid_size_min_ = cuboid_size_min;
00158     cuboid_size_max_ = cuboid_size_max;
00159   }
00160 };
00161 
00162 class RvizVisualTools
00163 {
00164 private:
00168   void initialize();
00169 
00170 public:
00176   explicit RvizVisualTools(const std::string &base_frame, const std::string &marker_topic = RVIZ_MARKER_TOPIC);
00180   ~RvizVisualTools()
00181   {
00182   }
00183 
00188   bool deleteAllMarkers();
00189 
00194   void resetMarkerCounts();
00195 
00200   bool loadRvizMarkers();
00201 
00203   void setMarkerTopic(const std::string& topic)
00204   {
00205     marker_topic_ = topic;
00206   }
00207 
00213   void loadMarkerPub(bool wait_for_subscriber = false, bool latched=false);
00214 
00221   bool waitForSubscriber(const ros::Publisher &pub, const double &wait_time = 0.5);
00222 
00227   void setFloorToBaseHeight(double floor_to_base_height);
00228 
00233   void setAlpha(double alpha)
00234   {
00235     alpha_ = alpha;
00236   }
00241   void setLifetime(double lifetime);
00242 
00247   colors getRandColor();
00248 
00254   std_msgs::ColorRGBA getColor(const colors &color);
00255 
00260   std_msgs::ColorRGBA createRandColor();
00261 
00266   double slerp(double start, double end, double range, double value);
00267 
00272   std_msgs::ColorRGBA getColorScale(double value);
00273 
00281   geometry_msgs::Vector3 getScale(const scales &scale, bool arrow_scale = false, double marker_scale = 1.0);
00282 
00289   Eigen::Affine3d getVectorBetweenPoints(Eigen::Vector3d a, Eigen::Vector3d b);
00290 
00297   Eigen::Vector3d getCenterPoint(Eigen::Vector3d a, Eigen::Vector3d b);
00298 
00303   const std::string getBaseFrame()
00304   {
00305     return base_frame_;
00306   }
00312   void setBaseFrame(const std::string &base_frame)
00313   {
00314     base_frame_ = base_frame;
00315     loadRvizMarkers();
00316   }
00317 
00321   double getGlobalScale()
00322   {
00323     return global_scale_;
00324   }
00328   void setGlobalScale(double global_scale)
00329   {
00330     global_scale_ = global_scale;
00331   }
00337   bool publishMarker(visualization_msgs::Marker &marker);
00338 
00344   void enableBatchPublishing(bool enable = true);
00345 
00350   bool triggerBatchPublish();
00351 
00358   bool triggerBatchPublishAndDisable();
00359 
00365   bool publishMarkers(visualization_msgs::MarkerArray &markers);
00366 
00374   bool publishCone(const Eigen::Affine3d &pose, double angle, const rviz_visual_tools::colors &color = TRANSLUCENT,
00375                    double scale = 1.0);
00376   bool publishCone(const geometry_msgs::Pose &pose, double angle, const rviz_visual_tools::colors &color = TRANSLUCENT,
00377                    double scale = 1.0);
00378 
00386   bool publishXYPlane(const Eigen::Affine3d &pose, const rviz_visual_tools::colors &color = TRANSLUCENT,
00387                       double scale = 1.0);
00388   bool publishXYPlane(const geometry_msgs::Pose &pose, const rviz_visual_tools::colors &color = TRANSLUCENT,
00389                       double scale = 1.0);
00390 
00398   bool publishXZPlane(const Eigen::Affine3d &pose, const rviz_visual_tools::colors &color = TRANSLUCENT,
00399                       double scale = 1.0);
00400   bool publishXZPlane(const geometry_msgs::Pose &pose, const rviz_visual_tools::colors &color = TRANSLUCENT,
00401                       double scale = 1.0);
00402 
00410   bool publishYZPlane(const Eigen::Affine3d &pose, const rviz_visual_tools::colors &color = TRANSLUCENT,
00411                       double scale = 1.0);
00412   bool publishYZPlane(const geometry_msgs::Pose &pose, const rviz_visual_tools::colors &color = TRANSLUCENT,
00413                       double scale = 1.0);
00414 
00425   bool publishSphere(const Eigen::Affine3d &pose, const colors &color = BLUE, const scales &scale = REGULAR,
00426                      const std::string &ns = "Sphere", const std::size_t &id = 0);
00427   bool publishSphere(const Eigen::Vector3d &point, const colors &color = BLUE, const scales &scale = REGULAR,
00428                      const std::string &ns = "Sphere", const std::size_t &id = 0);
00429   bool publishSphere(const Eigen::Vector3d &point, const colors &color, const double scale,
00430                      const std::string &ns = "Sphere", const std::size_t &id = 0);
00431   bool publishSphere(const geometry_msgs::Point &point, const colors &color = BLUE, const scales &scale = REGULAR,
00432                      const std::string &ns = "Sphere", const std::size_t &id = 0);
00433   bool publishSphere(const geometry_msgs::Pose &pose, const colors &color = BLUE, const scales &scale = REGULAR,
00434                      const std::string &ns = "Sphere", const std::size_t &id = 0);
00435   bool publishSphere(const geometry_msgs::Pose &pose, const colors &color, const double scale,
00436                      const std::string &ns = "Sphere", const std::size_t &id = 0);
00437   bool publishSphere(const geometry_msgs::Pose &pose, const colors &color, const geometry_msgs::Vector3 scale,
00438                      const std::string &ns = "Sphere", const std::size_t &id = 0);
00439   bool publishSphere(const geometry_msgs::Pose &pose, const std_msgs::ColorRGBA &color,
00440                      const geometry_msgs::Vector3 scale, const std::string &ns = "Sphere", const std::size_t &id = 0);
00441   bool publishSphere(const Eigen::Affine3d &pose, const std_msgs::ColorRGBA &color,
00442                      const geometry_msgs::Vector3 scale, const std::string &ns = "Sphere", const std::size_t &id = 0);
00443   bool publishSphere(const geometry_msgs::PoseStamped &pose, const colors &color, const geometry_msgs::Vector3 scale,
00444                      const std::string &ns = "Sphere", const std::size_t &id = 0);
00445 
00454   bool publishSpheres(const std::vector<Eigen::Vector3d> &points, const colors &color = BLUE, const double scale = 0.1,
00455                       const std::string &ns = "Spheres");
00456   bool publishSpheres(const std::vector<geometry_msgs::Point> &points, const colors &color = BLUE,
00457                       const double scale = 0.1, const std::string &ns = "Spheres");
00458   bool publishSpheres(const std::vector<geometry_msgs::Point> &points, const colors &color = BLUE,
00459                       const scales &scale = REGULAR, const std::string &ns = "Spheres");
00460   bool publishSpheres(const std::vector<geometry_msgs::Point> &points, const colors &color,
00461                       const geometry_msgs::Vector3 &scale, const std::string &ns = "Spheres");
00462 
00471   bool publishXArrow(const Eigen::Affine3d &pose, const colors &color = RED, const scales &scale = REGULAR,
00472                      double length = 0.1);
00473   bool publishXArrow(const geometry_msgs::Pose &pose, const colors &color = RED, const scales &scale = REGULAR,
00474                      double length = 0.1);
00475   bool publishXArrow(const geometry_msgs::PoseStamped &pose, const colors &color = RED, const scales &scale = REGULAR,
00476                      double length = 0.1);
00477 
00486   bool publishYArrow(const Eigen::Affine3d &pose, const colors &color = GREEN, const scales &scale = REGULAR,
00487                      double length = 0.1);
00488   bool publishYArrow(const geometry_msgs::Pose &pose, const colors &color = GREEN, const scales &scale = REGULAR,
00489                      double length = 0.1);
00490   bool publishYArrow(const geometry_msgs::PoseStamped &pose, const colors &color = GREEN, const scales &scale = REGULAR,
00491                      double length = 0.1);
00492 
00501   bool publishZArrow(const Eigen::Affine3d &pose, const colors &color = BLUE, const scales &scale = REGULAR,
00502                      double length = 0.1, const std::size_t &id = 0);
00503   bool publishZArrow(const geometry_msgs::Pose &pose, const colors &color = BLUE, const scales &scale = REGULAR,
00504                      double length = 0.1);
00505   bool publishZArrow(const geometry_msgs::PoseStamped &pose, const colors &color = BLUE, const scales &scale = REGULAR,
00506                      double length = 0.1);
00507   bool publishZArrow(const geometry_msgs::PoseStamped &pose, const colors &color = BLUE, const scales &scale = REGULAR,
00508                      double length = 0.1, const std::size_t &id = 0);
00509 
00518   bool publishArrow(const Eigen::Affine3d &pose, const colors &color = BLUE, const scales &scale = REGULAR,
00519                     double length = 0.1, const std::size_t &id = 0);
00520   bool publishArrow(const geometry_msgs::Pose &pose, const colors &color = BLUE, const scales &scale = REGULAR,
00521                     double length = 0.1, const std::size_t &id = 0);
00522   bool publishArrow(const geometry_msgs::PoseStamped &pose, const colors &color = BLUE, const scales &scale = REGULAR,
00523                     double length = 0.1, const std::size_t &id = 0);
00524 
00532   bool publishCuboid(const Eigen::Vector3d &point1, const Eigen::Vector3d &point2, const colors &color = BLUE);
00533   bool publishCuboid(const geometry_msgs::Point &point1, const geometry_msgs::Point &point2,
00534                      const colors &color = BLUE, const std::string &ns = "Cuboid", const std::size_t &id = 0);
00535 
00545   bool publishCuboid(const geometry_msgs::Pose &pose, const double depth, const double width, const double height,
00546                      const colors &color = BLUE);
00547   bool publishCuboid(const Eigen::Affine3d &pose, const double depth, const double width, const double height,
00548                      const colors &color = BLUE);
00549 
00558   bool publishLine(const Eigen::Affine3d &point1, const Eigen::Affine3d &point2, const colors &color = BLUE,
00559                    const scales &scale = REGULAR);
00560   bool publishLine(const Eigen::Vector3d &point1, const Eigen::Vector3d &point2, const colors &color = BLUE,
00561                    const scales &scale = REGULAR);
00562   bool publishLine(const Eigen::Vector3d &point1, const Eigen::Vector3d &point2,
00563                    const std_msgs::ColorRGBA &color, const scales &scale = REGULAR);
00564   bool publishLine(const Eigen::Vector3d &point1, const Eigen::Vector3d &point2,
00565                    const std_msgs::ColorRGBA &color, const double &radius);
00566   bool publishLine(const geometry_msgs::Point &point1, const geometry_msgs::Point &point2, const colors &color = BLUE,
00567                    const scales &scale = REGULAR);
00568   bool publishLine(const geometry_msgs::Point &point1, const geometry_msgs::Point &point2,
00569                    const std_msgs::ColorRGBA &color, const scales &scale = REGULAR);
00570   bool publishLine(const geometry_msgs::Point &point1, const geometry_msgs::Point &point2,
00571                    const std_msgs::ColorRGBA &color, const geometry_msgs::Vector3 &scale);
00572 
00581   bool publishPath(const std::vector<geometry_msgs::Point> &path, const colors &color = RED,
00582                    const scales &scale = REGULAR, const std::string &ns = "Path");
00583 
00584   bool publishPath(const std::vector<Eigen::Vector3d> &path, const colors &color = RED,
00585                    const double radius = 0.01, const std::string &ns = "Path");
00586 
00595   bool publishPolygon(const geometry_msgs::Polygon &polygon, const colors &color = RED, const scales &scale = REGULAR,
00596                       const std::string &ns = "Polygon");
00597 
00606   bool publishBlock(const geometry_msgs::Pose &pose, const colors &color = BLUE, const double &block_size = 0.1);
00607   RVIZ_VISUAL_TOOLS_DEPRECATED
00608   bool publishBlock(const Eigen::Affine3d &pose, const colors &color = BLUE, const double &block_size = 0.1);
00609 
00622   bool publishWireframeCuboid(const Eigen::Affine3d &pose, double depth, double width, double height,
00623                               const rviz_visual_tools::colors &color = BLUE, const std::string &ns = "Wireframe Cuboid",
00624                               const std::size_t &id = 0);
00625 
00637   bool publishWireframeCuboid(const Eigen::Affine3d &pose, const Eigen::Vector3d &min_point,
00638                               const Eigen::Vector3d &max_point, const rviz_visual_tools::colors &color = BLUE,
00639                               const std::string &ns = "Wireframe Cuboid", const std::size_t &id = 0);
00640 
00649   bool publishWireframeRectangle(const Eigen::Affine3d &pose, const double &height, const double &width,
00650                                  const colors &color = BLUE, const scales &scale = REGULAR);
00651   bool publishWireframeRectangle(const Eigen::Affine3d &pose, const Eigen::Vector3d &p1, const Eigen::Vector3d &p2,
00652                                  const Eigen::Vector3d &p3, const Eigen::Vector3d &p4, const colors &color,
00653                                  const scales &scale);
00662   bool publishAxisLabeled(const Eigen::Affine3d &pose, const std::string &label, const scales &scale = SMALL,
00663                           const colors &color = WHITE);
00664   bool publishAxisLabeled(const geometry_msgs::Pose &pose, const std::string &label, const scales &scale = SMALL,
00665                           const colors &color = WHITE);
00666 
00674   bool publishAxis(const geometry_msgs::Pose &pose, double length = 0.1, double radius = 0.01,
00675                    const std::string &ns = "Axis");
00676   bool publishAxis(const Eigen::Affine3d &pose, double length = 0.1, double radius = 0.01,
00677                    const std::string &ns = "Axis");
00678 
00687   bool publishCylinder(const Eigen::Vector3d &point1, const Eigen::Vector3d &point2, const colors &color = BLUE,
00688                        double radius = 0.01, const std::string &ns = "Cylinder");
00689   bool publishCylinder(const Eigen::Vector3d &point1, const Eigen::Vector3d &point2, const std_msgs::ColorRGBA &color,
00690                        double radius = 0.01, const std::string &ns = "Cylinder");
00691 
00700   bool publishCylinder(const Eigen::Affine3d &pose, const colors &color = BLUE, double height = 0.1,
00701                        double radius = 0.01, const std::string &ns = "Cylinder");
00702   bool publishCylinder(const geometry_msgs::Pose &pose, const colors &color = BLUE, double height = 0.1,
00703                        double radius = 0.01, const std::string &ns = "Cylinder");
00704   bool publishCylinder(const geometry_msgs::Pose &pose, const std_msgs::ColorRGBA &color, double height = 0.1,
00705                        double radius = 0.01, const std::string &ns = "Cylinder");
00706 
00718   bool publishMesh(const Eigen::Affine3d &pose, const std::string &file_name, const colors &color = CLEAR,
00719                    double scale = 1, const std::string &ns = "mesh", const std::size_t &id = 0);
00720   bool publishMesh(const geometry_msgs::Pose &pose, const std::string &file_name, const colors &color = CLEAR,
00721                    double scale = 1, const std::string &ns = "mesh", const std::size_t &id = 0);
00722 
00730   bool publishGraph(const graph_msgs::GeometryGraph &graph, const colors &color, double radius);
00731 
00741   bool publishText(const Eigen::Affine3d &pose, const std::string &text, const colors &color = WHITE,
00742                    const scales &scale = REGULAR, bool static_id = true);
00743   bool publishText(const Eigen::Affine3d &pose, const std::string &text, const colors &color,
00744                    const geometry_msgs::Vector3 scale, bool static_id = true);
00745   bool publishText(const geometry_msgs::Pose &pose, const std::string &text, const colors &color = WHITE,
00746                    const scales &scale = REGULAR, bool static_id = true);
00747   bool publishText(const geometry_msgs::Pose &pose, const std::string &text, const colors &color,
00748                    const geometry_msgs::Vector3 scale, bool static_id = true);
00749 
00754   RVIZ_VISUAL_TOOLS_DEPRECATED
00755   bool publishTests();
00756 
00763   geometry_msgs::Pose convertPose(const Eigen::Affine3d &pose);
00764 
00770   static void convertPoseSafe(const Eigen::Affine3d &pose, geometry_msgs::Pose &pose_msg);
00771 
00778   Eigen::Affine3d convertPose(const geometry_msgs::Pose &pose);
00779 
00786   Eigen::Affine3d convertPoint32ToPose(const geometry_msgs::Point32 &point);
00787 
00791   geometry_msgs::Pose convertPointToPose(const geometry_msgs::Point &point);
00792   Eigen::Affine3d convertPointToPose(const Eigen::Vector3d &point);
00793 
00800   geometry_msgs::Point convertPoseToPoint(const Eigen::Affine3d &pose);
00801 
00808   Eigen::Vector3d convertPoint(const geometry_msgs::Point &point);
00809 
00816   Eigen::Vector3d convertPoint32(const geometry_msgs::Point32 &point);
00817 
00824   geometry_msgs::Point32 convertPoint32(const Eigen::Vector3d &point);
00825 
00832   geometry_msgs::Point convertPoint(const geometry_msgs::Vector3 &point);
00833 
00840   geometry_msgs::Point convertPoint(const Eigen::Vector3d &point);
00841 
00847   static Eigen::Affine3d convertFromXYZRPY(const double &x, const double &y, const double &z, const double &roll,
00848                                            const double &pitch, const double &yaw);
00849   static Eigen::Affine3d convertFromXYZRPY(std::vector<double> transform6);
00850 
00857   static void convertToXYZRPY(const Eigen::Affine3d &pose, std::vector<double> &xyzrpy);
00858   static void convertToXYZRPY(const Eigen::Affine3d &pose, double &x, double &y, double &z, double &roll, double &pitch,
00859                               double &yaw);
00865   void generateRandomPose(geometry_msgs::Pose &pose, RandomPoseBounds pose_bounds = RandomPoseBounds());
00866   void generateRandomPose(Eigen::Affine3d &pose, RandomPoseBounds pose_bounds = RandomPoseBounds());
00867 
00871   void generateRandomCuboid(geometry_msgs::Pose &cuboid_pose, double &depth, double &width, double &height,
00872                             RandomPoseBounds pose_bounds = RandomPoseBounds(),
00873                             RandomCuboidBounds cuboid_bounds = RandomCuboidBounds());
00874 
00879   void generateEmptyPose(geometry_msgs::Pose &pose);
00880 
00888   bool posesEqual(const Eigen::Affine3d &pose1, const Eigen::Affine3d &pose2, const double& threshold = 0.000001);
00889 
00893   static double dRand(double min, double max);
00894   static float fRand(float min, float max);
00895   static int iRand(int min, int max);
00896 
00900   static void printTransform(const Eigen::Affine3d &transform);
00901 
00905   static void printTransformRPY(const Eigen::Affine3d &transform);
00906 
00908   const bool& getPsychedelicMode() const
00909   {
00910     return psychedelic_mode_;
00911   }
00912 
00914   void setPsychedelicMode(const bool& psychedelic_mode = true)
00915   {
00916     psychedelic_mode_ = psychedelic_mode;
00917   }
00918 
00919 protected:
00923   void enableInternalBatchPublishing(bool enable);
00924 
00931   bool triggerInternalBatchPublishAndDisable();
00932 
00933   // A shared node handle
00934   ros::NodeHandle nh_;
00935 
00936   // Short name for this class
00937   std::string name_;
00938 
00939   // ROS publishers
00940   ros::Publisher pub_rviz_markers_;  // for rviz visualization markers
00941   bool pub_rviz_markers_connected_;
00942   bool pub_rviz_markers_waited_;
00943 
00944   // Strings
00945   std::string marker_topic_;  // topic to publish to rviz
00946   std::string base_frame_;    // name of base link
00947 
00948   // Duration to have Rviz markers persist, 0 for infinity
00949   ros::Duration marker_lifetime_;
00950 
00951   // Settings
00952   bool batch_publishing_enabled_;
00953   bool internal_batch_publishing_enabled_;  // this allows certain marker functions to batch publish
00954                                             // without breaking external functinality
00955   double alpha_;                            // opacity of all markers
00956   double global_scale_;                     // allow all markers to be increased by a constanct factor
00957 
00958   // Cached Rviz Marker Array
00959   visualization_msgs::MarkerArray markers_;
00960 
00961   // Cached Rviz markers
00962   visualization_msgs::Marker arrow_marker_;
00963   visualization_msgs::Marker sphere_marker_;
00964   visualization_msgs::Marker block_marker_;
00965   visualization_msgs::Marker cylinder_marker_;
00966   visualization_msgs::Marker mesh_marker_;
00967   visualization_msgs::Marker text_marker_;
00968   visualization_msgs::Marker cuboid_marker_;
00969   visualization_msgs::Marker line_strip_marker_;
00970   visualization_msgs::Marker line_list_marker_;
00971   visualization_msgs::Marker spheres_marker_;
00972   visualization_msgs::Marker reset_marker_;
00973   visualization_msgs::Marker triangle_marker_;
00974 
00975   // Cached geometry variables used for conversion
00976   geometry_msgs::Pose shared_pose_msg_;
00977   geometry_msgs::Point shared_point_msg_;
00978   geometry_msgs::Point32 shared_point32_msg_;
00979   Eigen::Affine3d shared_pose_eigen_;
00980   Eigen::Vector3d shared_point_eigen_;
00981 
00982   // Just for fun.
00983   bool psychedelic_mode_;
00984 };  // class
00985 
00986 typedef boost::shared_ptr<RvizVisualTools> RvizVisualToolsPtr;
00987 typedef boost::shared_ptr<const RvizVisualTools> RvizVisualToolsConstPtr;
00988 
00989 }  // namespace rviz_visual_tools
00990 
00991 #endif  // RVIZ_VISUAL_TOOLS_RVIZ_VISUAL_TOOLS_H


rviz_visual_tools
Author(s): Dave Coleman
autogenerated on Thu Jun 6 2019 19:01:23