lanelet2_map_server v1.2.3
Loading...
Searching...
No Matches
rviz_rendering::Lanelet2Map Class Reference

#include <lanelet2_map.hpp>

Classes

struct  RenderingOptions
 

Public Member Functions

 Lanelet2Map (Ogre::SceneManager *manager, Ogre::SceneNode *parent_node, Lanelet2Map::RenderingOptions rend_opts, lanelet::LaneletMapConstPtr map_ptr)
 Create an RViz scene representation for a lanelet map.
 
 ~Lanelet2Map ()
 Destroy the scene representation and its OGRE objects.
 
 Lanelet2Map (const Lanelet2Map &)=delete
 Copy construction is disabled because the map owns OGRE scene objects.
 
Lanelet2Map & operator= (const Lanelet2Map &)=delete
 Copy assignment is disabled because the map owns OGRE scene objects.
 
 Lanelet2Map (Lanelet2Map &&)=delete
 Move construction is disabled because OGRE scene ownership is pointer-based.
 
Lanelet2Map & operator= (Lanelet2Map &&)=delete
 Move assignment is disabled because OGRE scene ownership is pointer-based.
 
void clearObjects ()
 Remove all OGRE objects owned by this map.
 
Ogre::SceneNode * getSceneNode ()
 Return the root scene node used by this map.
 
void updateMap (RenderingOptions rend_opts, lanelet::LaneletMapConstPtr map_ptr)
 Replace the rendered map and apply the given rendering options.
 
void updateVisibility (const RenderingOptions &rend_opts)
 Update object visibility from the supplied rendering options.
 

Static Public Attributes

static int manual_object_counter_ {0}
 

Private Member Functions

void create (lanelet::LaneletMapConstPtr map_ptr)
 Create OGRE objects for all supported lanelet map layers.
 
void updateVisibility (ObjectClassification classification, bool visible)
 Set visibility for one object classification.
 

Private Attributes

Lanelet2Map::RenderingOptions rend_opts_
 
Ogre::SceneManager * scene_manager_
 
Ogre::SceneNode * scene_node_
 
std::vector< ClassifiedMovableObject > objects_
 
std::shared_ptr< Ogre::Material > material_surface_
 
std::shared_ptr< Ogre::Material > material_line_
 
std::unique_ptr< detail::Lanelet2MapHelpers > bsd_helpers_
 

Friends

class detail::Lanelet2MapHelpers
 

Detailed Description

Definition at line 44 of file lanelet2_map.hpp.

Constructor & Destructor Documentation

◆ Lanelet2Map() [1/3]

rviz_rendering::Lanelet2Map::Lanelet2Map ( Ogre::SceneManager * manager,
Ogre::SceneNode * parent_node,
Lanelet2Map::RenderingOptions rend_opts,
lanelet::LaneletMapConstPtr map_ptr )

Create an RViz scene representation for a lanelet map.

Definition at line 23 of file lanelet2_map.cpp.

27 : rend_opts_(rend_opts), scene_manager_(manager), bsd_helpers_(std::make_unique<detail::Lanelet2MapHelpers>(*this)) {
28 std::string ll_map_name = "Lanelet2Map";
29
30 if (parent_node == nullptr) {
31 parent_node = scene_manager_->getRootSceneNode();
32 }
33
34 scene_node_ = parent_node->createChildSceneNode();
35
36 const std::string mat_surface_name = ll_map_name + "SurfaceMaterial";
37 const std::string mat_line_name = ll_map_name + "LineMaterial";
38
39 {
40 auto res = Ogre::MaterialManager::getSingleton().createOrRetrieve(mat_surface_name, "rviz_rendering");
41 auto mat = std::dynamic_pointer_cast<Ogre::Material>(res.first);
42 if (mat) {
44 material_surface_->setReceiveShadows(false);
45 material_surface_->getTechnique(0)->setLightingEnabled(false);
46 material_surface_->getTechnique(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
47 material_surface_->getTechnique(0)->setDepthWriteEnabled(true);
48 material_surface_->getTechnique(0)->getPass(0)->setVertexColourTracking(Ogre::TVC_AMBIENT + Ogre::TVC_DIFFUSE);
49 material_surface_->getTechnique(0)->setCullingMode(Ogre::CULL_NONE);
50 material_surface_->getTechnique(0)->getPass(0)->setDepthBias(1.0F, 1.0F);
51 }
52 }
53
54 {
55 auto res = Ogre::MaterialManager::getSingleton().createOrRetrieve(mat_line_name, "rviz_rendering");
56 auto mat = std::dynamic_pointer_cast<Ogre::Material>(res.first);
57 if (mat) {
58 material_line_ = mat;
59 material_line_->setReceiveShadows(false);
60 material_line_->getTechnique(0)->setLightingEnabled(false);
61 material_line_->getTechnique(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
62 material_line_->getTechnique(0)->setDepthWriteEnabled(false);
63 material_line_->getTechnique(0)->setDepthCheckEnabled(true);
64 material_line_->getTechnique(0)->getPass(0)->setVertexColourTracking(Ogre::TVC_AMBIENT + Ogre::TVC_DIFFUSE);
65 material_line_->getTechnique(0)->setCullingMode(Ogre::CULL_NONE);
66 material_line_->getTechnique(0)->getPass(0)->setDepthBias(2.0F, 1.0F);
67 }
68 }
69
70 create(map_ptr);
72}
Lanelet2Map::RenderingOptions rend_opts_
Ogre::SceneNode * scene_node_
std::unique_ptr< detail::Lanelet2MapHelpers > bsd_helpers_
std::shared_ptr< Ogre::Material > material_line_
std::shared_ptr< Ogre::Material > material_surface_
void updateVisibility(const RenderingOptions &rend_opts)
Update object visibility from the supplied rendering options.
void create(lanelet::LaneletMapConstPtr map_ptr)
Create OGRE objects for all supported lanelet map layers.
Ogre::SceneManager * scene_manager_

◆ ~Lanelet2Map()

rviz_rendering::Lanelet2Map::~Lanelet2Map ( )

Destroy the scene representation and its OGRE objects.

Definition at line 74 of file lanelet2_map.cpp.

74 {
76
77 scene_node_->removeAndDestroyAllChildren();
78 scene_node_->getParentSceneNode()->removeChild(scene_node_);
79 scene_manager_->destroySceneNode(scene_node_);
80
82 material_surface_->unload();
83 }
84 if (material_line_) {
85 material_line_->unload();
86 }
87}
void clearObjects()
Remove all OGRE objects owned by this map.

◆ Lanelet2Map() [2/3]

rviz_rendering::Lanelet2Map::Lanelet2Map ( const Lanelet2Map & )
delete

Copy construction is disabled because the map owns OGRE scene objects.

◆ Lanelet2Map() [3/3]

rviz_rendering::Lanelet2Map::Lanelet2Map ( Lanelet2Map && )
delete

Move construction is disabled because OGRE scene ownership is pointer-based.

Member Function Documentation

◆ clearObjects()

void rviz_rendering::Lanelet2Map::clearObjects ( )

Remove all OGRE objects owned by this map.

Definition at line 89 of file lanelet2_map.cpp.

89{ bsd_helpers_->clearObjects(); }

◆ create()

void rviz_rendering::Lanelet2Map::create ( lanelet::LaneletMapConstPtr map_ptr)
private

Create OGRE objects for all supported lanelet map layers.

Definition at line 120 of file lanelet2_map.cpp.

120 {
121 Ogre::ManualObject* map_manual_object =
122 scene_manager_->createManualObject("llet_object_" + std::to_string(manual_object_counter_++));
123 Ogre::ManualObject* separator_manual_object =
124 scene_manager_->createManualObject("llet_object_" + std::to_string(manual_object_counter_++));
125 Ogre::ManualObject* area_manual_object =
126 scene_manager_->createManualObject("llet_object_" + std::to_string(manual_object_counter_++));
127 Ogre::ManualObject* parking_manual_object =
128 scene_manager_->createManualObject("llet_object_" + std::to_string(manual_object_counter_++));
129 Ogre::ManualObject* lane_fill_manual_object =
130 scene_manager_->createManualObject("llet_object_" + std::to_string(manual_object_counter_++));
131 Ogre::ManualObject* sidewalk_manual_object =
132 scene_manager_->createManualObject("llet_object_" + std::to_string(manual_object_counter_++));
133 Ogre::ManualObject* crosswalk_manual_object =
134 scene_manager_->createManualObject("llet_object_" + std::to_string(manual_object_counter_++));
135
136 if (map_ptr == nullptr) {
137 scene_manager_->destroyManualObject(map_manual_object);
138 scene_manager_->destroyManualObject(separator_manual_object);
139 scene_manager_->destroyManualObject(area_manual_object);
140 scene_manager_->destroyManualObject(parking_manual_object);
141 scene_manager_->destroyManualObject(lane_fill_manual_object);
142 scene_manager_->destroyManualObject(sidewalk_manual_object);
143 scene_manager_->destroyManualObject(crosswalk_manual_object);
144 return;
145 }
146
147 map_manual_object->begin(material_line_->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST, "rviz_rendering");
148 separator_manual_object->begin(material_line_->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST, "rviz_rendering");
149 area_manual_object->begin(material_surface_->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST, "rviz_rendering");
150 parking_manual_object->begin(material_surface_->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST, "rviz_rendering");
151 lane_fill_manual_object->begin(material_surface_->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST, "rviz_rendering");
152 sidewalk_manual_object->begin(material_surface_->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST, "rviz_rendering");
153 crosswalk_manual_object->begin(material_surface_->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST, "rviz_rendering");
154
155 const uint8_t q_surfaces = Ogre::RENDER_QUEUE_MAIN;
156 const uint8_t q_lines = Ogre::RENDER_QUEUE_MAIN + 5;
157 lane_fill_manual_object->setRenderQueueGroup(q_surfaces);
158 area_manual_object->setRenderQueueGroup(q_surfaces);
159 parking_manual_object->setRenderQueueGroup(q_surfaces);
160 sidewalk_manual_object->setRenderQueueGroup(q_surfaces);
161 crosswalk_manual_object->setRenderQueueGroup(q_surfaces);
162 map_manual_object->setRenderQueueGroup(q_lines);
163 separator_manual_object->setRenderQueueGroup(q_lines);
164
165 for (const lanelet::ConstLanelet& lanelet : map_ptr->laneletLayer) {
166 bsd_helpers_->addLaneletToManualObject(lanelet, map_manual_object);
167 bsd_helpers_->addSeperatorToManualObject(lanelet, separator_manual_object);
169 bsd_helpers_->addLaneFillToManualObject(lanelet, lane_fill_manual_object);
170 }
171 bsd_helpers_->addRegulatoryElements(lanelet, scene_node_);
172 bsd_helpers_->attachLaneletIdToSceneNode(lanelet, scene_node_);
173 }
174
175 for (const lanelet::ConstArea& area : map_ptr->areaLayer) {
176 auto attributes = area.attributes();
177 const auto subtype = attributes[lanelet::AttributeName::Subtype];
178 // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
179 if (subtype == lanelet::AttributeValueString::Parking) {
180 bsd_helpers_->addParkingAreaToManualObject(area, parking_manual_object);
181 } else if (rend_opts_.renderCrosswalks && (subtype == "crosswalk")) {
182 bsd_helpers_->addCrosswalkToManualObject(area, crosswalk_manual_object);
183 } else if (rend_opts_.renderSidewalks && (subtype == "sidewalk" || subtype == "walkway" || subtype == "footway")) {
184 bsd_helpers_->addSidewalkToManualObject(area, sidewalk_manual_object);
185 } else {
186 bsd_helpers_->addAreaToManualObject(area, area_manual_object);
187 }
188 }
189
190 map_manual_object->end();
191 separator_manual_object->end();
192 area_manual_object->end();
193 parking_manual_object->end();
194 lane_fill_manual_object->end();
195 sidewalk_manual_object->end();
196 crosswalk_manual_object->end();
197
198 auto attach_if_populated = [this](Ogre::ManualObject* manual_object, ObjectClassification classification) {
199 // NOLINTNEXTLINE(clang-diagnostic-deprecated-declarations)
200 if (manual_object->getNumSections() != 0U) {
201 scene_node_->attachObject(manual_object);
202 objects_.push_back(std::make_pair(classification, manual_object));
203 } else {
204 scene_manager_->destroyManualObject(manual_object);
205 }
206 };
207
208 attach_if_populated(map_manual_object, ObjectClassification::MAP);
209 attach_if_populated(separator_manual_object, ObjectClassification::SEPERATOR);
210 attach_if_populated(area_manual_object, ObjectClassification::AREA);
211 attach_if_populated(parking_manual_object, ObjectClassification::PARKINGAREA);
212 attach_if_populated(lane_fill_manual_object, ObjectClassification::LANEFILL);
213 attach_if_populated(sidewalk_manual_object, ObjectClassification::SIDEWALK);
214 attach_if_populated(crosswalk_manual_object, ObjectClassification::CROSSWALK);
215}
std::vector< ClassifiedMovableObject > objects_

◆ getSceneNode()

Ogre::SceneNode * rviz_rendering::Lanelet2Map::getSceneNode ( )
inline

Return the root scene node used by this map.

Definition at line 119 of file lanelet2_map.hpp.

119{ return scene_node_; }

◆ operator=() [1/2]

Lanelet2Map & rviz_rendering::Lanelet2Map::operator= ( const Lanelet2Map & )
delete

Copy assignment is disabled because the map owns OGRE scene objects.

◆ operator=() [2/2]

Lanelet2Map & rviz_rendering::Lanelet2Map::operator= ( Lanelet2Map && )
delete

Move assignment is disabled because OGRE scene ownership is pointer-based.

◆ updateMap()

void rviz_rendering::Lanelet2Map::updateMap ( Lanelet2Map::RenderingOptions rend_opts,
lanelet::LaneletMapConstPtr map_ptr )

Replace the rendered map and apply the given rendering options.

Definition at line 91 of file lanelet2_map.cpp.

91 {
92 rend_opts_ = rend_opts;
94 create(map_ptr);
96}

◆ updateVisibility() [1/2]

void rviz_rendering::Lanelet2Map::updateVisibility ( const RenderingOptions & rend_opts)

Update object visibility from the supplied rendering options.

Definition at line 98 of file lanelet2_map.cpp.

98 {
99 rend_opts_ = rend_opts;
110}

◆ updateVisibility() [2/2]

void rviz_rendering::Lanelet2Map::updateVisibility ( ObjectClassification classification,
bool visible )
private

Set visibility for one object classification.

Definition at line 112 of file lanelet2_map.cpp.

112 {
113 for (auto object : objects_) {
114 if (object.first == classification) {
115 object.second->setVisible(visible);
116 }
117 }
118}

Friends And Related Symbol Documentation

◆ detail::Lanelet2MapHelpers

friend class detail::Lanelet2MapHelpers
friend

Definition at line 45 of file lanelet2_map.hpp.

Member Data Documentation

◆ bsd_helpers_

std::unique_ptr<detail::Lanelet2MapHelpers> rviz_rendering::Lanelet2Map::bsd_helpers_
private

Definition at line 141 of file lanelet2_map.hpp.

◆ manual_object_counter_

int rviz_rendering::Lanelet2Map::manual_object_counter_ {0}
static

Definition at line 48 of file lanelet2_map.hpp.

◆ material_line_

std::shared_ptr<Ogre::Material> rviz_rendering::Lanelet2Map::material_line_
private

Definition at line 140 of file lanelet2_map.hpp.

◆ material_surface_

std::shared_ptr<Ogre::Material> rviz_rendering::Lanelet2Map::material_surface_
private

Definition at line 139 of file lanelet2_map.hpp.

◆ objects_

std::vector<ClassifiedMovableObject> rviz_rendering::Lanelet2Map::objects_
private

Definition at line 137 of file lanelet2_map.hpp.

◆ rend_opts_

Lanelet2Map::RenderingOptions rviz_rendering::Lanelet2Map::rend_opts_
private

Definition at line 133 of file lanelet2_map.hpp.

◆ scene_manager_

Ogre::SceneManager* rviz_rendering::Lanelet2Map::scene_manager_
private

Definition at line 135 of file lanelet2_map.hpp.

◆ scene_node_

Ogre::SceneNode* rviz_rendering::Lanelet2Map::scene_node_
private

Definition at line 136 of file lanelet2_map.hpp.


The documentation for this class was generated from the following files: