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 
36  GridMapVisual(Ogre::SceneManager* sceneManager, Ogre::SceneNode* parentNode);
37  virtual ~GridMapVisual();
38 
39  // Copy the grid map data to map_.
40  void setMessage(const grid_map_msgs::GridMap::ConstPtr& msg);
41  // Compute the visualization of map_.
42 
43  void computeVisualization(float alpha, bool showGridLines, bool flatTerrain, std::string heightLayer, bool flatColor, bool noColor,
44  Ogre::ColourValue meshColor, bool mapLayerColor, std::string colorLayer, bool useRainbow, bool invertRainbow,
45  Ogre::ColourValue minColor, Ogre::ColourValue maxColor, bool autocomputeIntensity, float minIntensity,
46  float maxIntensity);
47 
48  // Set the coordinate frame pose.
49  void setFramePosition(const Ogre::Vector3& position);
50  void setFrameOrientation(const Ogre::Quaternion& orientation);
51 
52  // Get grid map layer names.
53  std::vector<std::string> getLayerNames();
54 
55  private:
56  enum class ColoringMethod { FLAT, COLOR_LAYER, INTENSITY_LAYER_MANUAL, INTENSITY_LAYER_RAINBOW, INTENSITY_LAYER_INVERTED_RAINBOW };
57 
58  Ogre::SceneNode* frameNode_;
59  Ogre::SceneManager* sceneManager_;
60 
61  // ManualObject for mesh display.
62  Ogre::ManualObject* manualObject_;
63  Ogre::MaterialPtr material_;
64  std::string materialName_;
65 
66  // Lines for mesh.
68 
69  // Grid map.
71 
72  // Helper methods.
73  bool haveMap_;
78  void initializeAndBeginManualObject(size_t nVertices);
79 
94  ColorArray computeColorValues(Eigen::Ref<const grid_map::Matrix> heightData, Eigen::Ref<const grid_map::Matrix> colorData,
95  GridMapVisual::ColoringMethod coloringMethod, Ogre::ColourValue flatColor, double minIntensity,
96  double maxIntensity, bool autocomputeIntensity, Ogre::ColourValue minColor, Ogre::ColourValue maxColor);
97 
105  void initializeMeshLines(size_t cols, size_t rows, double resolution, double alpha);
106 
112  MaskArray computeIsValidMask(std::vector<std::string> basicLayers);
113 
121  static void normalizeIntensity(float& intensity, float minIntensity, float maxIntensity);
122 
129  static Ogre::ColourValue getRainbowColor(float intensity);
130 
138  Ogre::ColourValue getInterpolatedColor(float intensity, Ogre::ColourValue minColor, Ogre::ColourValue maxColor);
139 };
140 
141 } // namespace grid_map_rviz_plugin
boost::shared_ptr< rviz::BillboardLine > meshLines_
Eigen::Vector3d Vector3
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 Tue Jun 1 2021 02:13:47