GridMapVisual.hpp
Go to the documentation of this file.
1 /*
2  * GridMapVisual.cpp
3  *
4  * Created on: Aug 3, 2016
5  * Author: Philipp Krüsi, Péter Fankhauser
6  * Institute: ETH Zurich, ANYbotics
7  */
8 
9 #pragma once
10 
11 #include <OGRE/OgreMaterial.h>
12 #include <OGRE/OgreSharedPtr.h>
13 
14 #include <grid_map_msgs/GridMap.h>
16 
17 namespace Ogre {
18 class Vector3;
19 class Quaternion;
20 class ManualObject;
21 class ColourValue;
22 } // namespace Ogre
23 
24 namespace rviz {
25 class BillboardLine;
26 }
27 
28 namespace grid_map_rviz_plugin {
29 
30 // Visualizes a single grid_map_msgs::GridMap message.
32  public:
33  using MaskArray = Eigen::Array<bool, Eigen::Dynamic, Eigen::Dynamic>;
34  using ColorArray = Eigen::Array<Ogre::ColourValue, Eigen::Dynamic, Eigen::Dynamic>;
35  using MatrixConstRef = Eigen::Ref<const grid_map::Matrix>;
36 
37  GridMapVisual(Ogre::SceneManager* sceneManager, Ogre::SceneNode* parentNode);
38  virtual ~GridMapVisual();
39 
40  // Copy the grid map data to map_.
41  void setMessage(const grid_map_msgs::GridMap::ConstPtr& msg);
42  // Compute the visualization of map_.
43 
44  void computeVisualization(float alpha, bool showGridLines, bool flatTerrain, std::string heightLayer, bool flatColor, bool noColor,
45  Ogre::ColourValue meshColor, bool mapLayerColor, std::string colorLayer, std::string colorMap, bool useColorMap,
46  bool invertColorMap, Ogre::ColourValue minColor, Ogre::ColourValue maxColor, bool autocomputeIntensity,
47  float minIntensity, float maxIntensity, float gridLineThickness, int gridCellDecimation);
48 
49  // Set the coordinate frame pose.
50  void setFramePosition(const Ogre::Vector3& position);
51  void setFrameOrientation(const Ogre::Quaternion& orientation);
52 
53  // Get grid map layer names.
54  std::vector<std::string> getLayerNames();
55 
56  private:
57  enum class ColoringMethod { FLAT, COLOR_LAYER, INTENSITY_LAYER_MANUAL, INTENSITY_LAYER_COLORMAP, INTENSITY_LAYER_INVERTED_COLORMAP };
58 
59  Ogre::SceneNode* frameNode_;
60  Ogre::SceneManager* sceneManager_;
61 
62  // ManualObject for mesh display.
63  Ogre::ManualObject* manualObject_;
64  Ogre::MaterialPtr material_;
65  std::string materialName_;
66 
67  // Lines for mesh.
69 
70  // Grid map.
72 
73  // Helper methods.
74  bool haveMap_;
75 
76  // Warning logs
77  static constexpr double warningMessageThrottlePeriod_{10.0};
78 
83  void initializeAndBeginManualObject(size_t nVertices);
84 
100  ColorArray computeColorValues(MatrixConstRef heightData, MatrixConstRef colorData,
101  ColoringMethod coloringMethod, std::string colorMap, Ogre::ColourValue flatColor,
102  double minIntensity, double maxIntensity, bool autocomputeIntensity, Ogre::ColourValue minColor,
103  Ogre::ColourValue maxColor);
104 
113  void initializeMeshLines(size_t cols, size_t rows, double resolution, double alpha, double lineWidth);
114 
120  MaskArray computeIsValidMask(std::vector<std::string> basicLayers);
121 
127  void printMissingBasicLayers(const std::vector<std::string>& basicLayers) const;
128 
136  static void normalizeIntensity(float& intensity, float minIntensity, float maxIntensity);
137 
144  static Ogre::ColourValue getRainbowColor(float intensity);
145 
153  Ogre::ColourValue getInterpolatedColor(float intensity, Ogre::ColourValue minColor, Ogre::ColourValue maxColor);
154 
171  std::vector<Ogre::Vector3> computeMeshLineVertices(int i, int j, int gridCellDecimation, bool isNthRow, bool isNthCol, bool isLastRow,
172  bool isLastCol, double resolution, const grid_map::Position& topLeft,
173  const Eigen::ArrayXXf& heightOrFlatData, const MaskArray& isValid) const;
174 };
175 
176 } // namespace grid_map_rviz_plugin
boost::shared_ptr< rviz::BillboardLine > meshLines_
const std::map< std::string, std::vector< std::vector< float > > > colorMap
Eigen::Vector2d Position
Eigen::Ref< const grid_map::Matrix > MatrixConstRef
Eigen::Array< bool, Eigen::Dynamic, Eigen::Dynamic > MaskArray
Eigen::Array< Ogre::ColourValue, Eigen::Dynamic, Eigen::Dynamic > ColorArray


grid_map_rviz_plugin
Author(s): Philipp Krüsi , Péter Fankhauser
autogenerated on Wed Jul 5 2023 02:23:55