ogre_slice.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef CARTOGRAPHER_RVIZ_SRC_OGRE_SLICE_H_
00018 #define CARTOGRAPHER_RVIZ_SRC_OGRE_SLICE_H_
00019 
00020 #include "Eigen/Core"
00021 #include "Eigen/Geometry"
00022 #include "OgreManualObject.h"
00023 #include "OgreMaterial.h"
00024 #include "OgreQuaternion.h"
00025 #include "OgreSceneManager.h"
00026 #include "OgreSceneNode.h"
00027 #include "OgreTexture.h"
00028 #include "OgreVector3.h"
00029 #include "cartographer/io/submap_painter.h"
00030 #include "cartographer/mapping/id.h"
00031 
00032 namespace cartographer_rviz {
00033 
00034 Ogre::Vector3 ToOgre(const Eigen::Vector3d& v);
00035 Ogre::Quaternion ToOgre(const Eigen::Quaterniond& q);
00036 
00037 // A class containing the Ogre code to visualize a slice texture of a submap.
00038 // Member functions are expected to be called from the Ogre thread.
00039 class OgreSlice {
00040  public:
00041   // Attaches a node visualizing the submap 'id' to the 'submap_node' which is
00042   // expected to represent the submap frame.
00043   OgreSlice(const ::cartographer::mapping::SubmapId& id, int slice_id,
00044             Ogre::SceneManager* const scene_manager,
00045             Ogre::SceneNode* const submap_node);
00046   ~OgreSlice();
00047 
00048   OgreSlice(const OgreSlice&) = delete;
00049   OgreSlice& operator=(const OgreSlice&) = delete;
00050 
00051   // Updates the texture and pose of the submap using new data from
00052   // 'submap_texture'.
00053   void Update(const ::cartographer::io::SubmapTexture& submap_texture);
00054 
00055   // Changes the opacity of the submap to 'alpha'.
00056   void SetAlpha(float alpha);
00057 
00058   // Sets the local visibility of this slice.
00059   void SetVisibility(bool visibility);
00060 
00061   // Updates the SceneNode to be visible if the submap and this slice are
00062   // visible.
00063   void UpdateOgreNodeVisibility(bool submap_visibility);
00064 
00065  private:
00066   // TODO(gaschler): Pack both ids into a struct.
00067   const ::cartographer::mapping::SubmapId id_;
00068   const int slice_id_;
00069   Ogre::SceneManager* const scene_manager_;
00070   Ogre::SceneNode* const submap_node_;
00071   Ogre::SceneNode* const slice_node_;
00072   Ogre::ManualObject* const manual_object_;
00073   Ogre::TexturePtr texture_;
00074   Ogre::MaterialPtr material_;
00075   bool visibility_ = true;
00076 };
00077 
00078 }  // namespace cartographer_rviz
00079 
00080 #endif  // CARTOGRAPHER_RVIZ_SRC_OGRE_SLICE_H_


cartographer_rviz
Author(s): The Cartographer Authors
autogenerated on Wed Jul 10 2019 04:10:34