13#ifndef LANELET2_RVIZ_DISPLAY__LANELET2_MAP_HELPERS_HPP_
14#define LANELET2_RVIZ_DISPLAY__LANELET2_MAP_HELPERS_HPP_
18#include <OgreColourValue.h>
19#include <OgreManualObject.h>
20#include <OgreSceneNode.h>
21#include <OgreVector.h>
23#include <rviz_rendering/objects/movable_text.hpp>
25#include <lanelet2_core/primitives/BasicRegulatoryElements.h>
26#include <lanelet2_core/primitives/Lanelet.h>
28#include <boost/numeric/conversion/cast.hpp>
75 std::vector<Ogre::Vector3>
ogreLineFromLLetPts(
const lanelet::ConstPoints3d& pts_vector)
const;
82 static std::vector<Ogre::Vector3>
bufferSegment(
const std::vector<Ogre::Vector3>& line,
double buffer_length);
85 template <
typename Iter>
86 static Ogre::Vector3
getNormal(Iter it, Iter begin, Iter end) {
87 Ogre::Vector3 zero(0, 0, 0);
88 auto dir_before = zero;
90 while (it != begin && dir_before == zero) {
91 dir_before = *it - *std::prev(it, i);
95 auto dir_after = zero;
97 while (std::next(it) != end && dir_after == zero) {
98 dir_after = *std::next(it, i) - *it;
102 if (dir_before == zero && dir_after == zero) {
105 if (dir_after == zero) {
106 dir_after = dir_before;
108 if (dir_before == zero) {
109 dir_before = dir_after;
112 auto dir_combined = dir_after * (1 / dir_after.length()) + dir_before * (1 / dir_before.length());
113 dir_combined *= 1 / dir_combined.length();
114 return Ogre::Vector3(dir_combined.y, -dir_combined.x, 0);
118 static void drawLine(
const std::vector<Ogre::Vector3>& line,
119 Ogre::ManualObject* obj,
120 Ogre::ColourValue color = Ogre::ColourValue::White,
122 double z_offset = 0.0);
124 static void drawArea(
const std::vector<Ogre::Vector3>& line,
125 Ogre::ManualObject* obj,
126 Ogre::ColourValue color = Ogre::ColourValue::White,
127 double z_offset = 0.0);
130 Ogre::ManualObject* obj,
131 Ogre::ColourValue color = Ogre::ColourValue::White);
134 const std::vector<Ogre::Vector3>& right,
135 Ogre::ManualObject* obj,
136 Ogre::ColourValue color,
137 double z_offset = 0.0);
static void drawArea(const std::vector< Ogre::Vector3 > &line, Ogre::ManualObject *obj, Ogre::ColourValue color=Ogre::ColourValue::White, double z_offset=0.0)
Draw an area outline or fill into a manual object.
void addLaneFillToManualObject(const lanelet::ConstLanelet &lanelet, Ogre::ManualObject *manual)
Add a filled lanelet surface to a manual object.
void addLaneletToManualObject(const lanelet::ConstLanelet &lanelet, Ogre::ManualObject *manual)
Add lanelet boundary lines to a manual object.
static Ogre::Vector3 ogreVec3FromLLetTrafficLight(lanelet::ConstPoint3d point, double z_offset)
Convert a traffic light point to an OGRE point with a height offset.
std::vector< Ogre::Vector3 > ogreLineFromLLetTrafficLight(const lanelet::ConstPolygon3d &polygon) const
Convert a traffic light polygon to OGRE points.
static Ogre::Vector3 getNormal(Iter it, Iter begin, Iter end)
Return the local 2D normal at an iterator position.
static std::vector< Ogre::Vector3 > bufferSegment(const std::vector< Ogre::Vector3 > &line, double buffer_length)
Create a buffered segment around a line.
static void drawLaneFillStrip(const std::vector< Ogre::Vector3 > &left, const std::vector< Ogre::Vector3 > &right, Ogre::ManualObject *obj, Ogre::ColourValue color, double z_offset=0.0)
Draw a filled strip between lanelet boundaries.
void addCrosswalkToManualObject(const lanelet::ConstArea &area, Ogre::ManualObject *manual)
Add a crosswalk surface to a manual object.
std::vector< Ogre::Vector3 > ogreLineFromLLetPolygon(const lanelet::CompoundPolygon3d &polygon) const
Convert a Lanelet2 polygon to OGRE points.
void addSeperatorToManualObject(const lanelet::ConstLanelet &lanelet, Ogre::ManualObject *manual)
Add lanelet separator lines to a manual object.
std::vector< Ogre::Vector3 > ogreLineFromLLetLineString(const lanelet::ConstLineString3d &line_string) const
Convert a Lanelet2 line string to OGRE points.
Ogre::Vector3 ogreVec3FromLLetPoint(lanelet::ConstPoint3d point) const
Convert a Lanelet2 point to an OGRE point.
void attachTrafficLightsToSceneNode(std::vector< lanelet::ConstPolygon3d > &traffic_lights, Ogre::SceneNode *parent_node)
Attach traffic light geometry to a scene node.
std::vector< Ogre::Vector3 > ogreLineFromLLetPts(const lanelet::ConstPoints3d &pts_vector) const
Convert Lanelet2 points to OGRE points.
Lanelet2MapHelpers(Lanelet2Map &owner)
Create helper routines bound to the owning map renderer.
void clearObjects()
Remove all helper-owned OGRE objects.
static void drawLine(const std::vector< Ogre::Vector3 > &line, Ogre::ManualObject *obj, Ogre::ColourValue color=Ogre::ColourValue::White, double width=0.1, double z_offset=0.0)
Draw a line strip into a manual object.
static void drawMonoPolygon(const std::vector< Ogre::Vector3 > &poly, Ogre::ManualObject *obj, Ogre::ColourValue color=Ogre::ColourValue::White)
Draw a single polygon into a manual object.
void addRegulatoryElements(const lanelet::ConstLanelet &lanelet, Ogre::SceneNode *parent_node)
Attach regulatory element visuals for a lanelet.
void attachRefLinesToSceneNode(std::vector< lanelet::ConstLineString3d > &stop_lines, Ogre::SceneNode *parent_node)
Attach stop-line reference geometry to a scene node.
void addAreaToManualObject(const lanelet::ConstArea &area, Ogre::ManualObject *manual)
Add area outlines or fills to a manual object.
void addSidewalkToManualObject(const lanelet::ConstArea &area, Ogre::ManualObject *manual)
Add a sidewalk surface to a manual object.
void attachLaneletIdToSceneNode(const lanelet::ConstLanelet &lanelet, Ogre::SceneNode *parent_node)
Attach the lanelet ID text to a scene node.
void addParkingAreaToManualObject(const lanelet::ConstArea &area, Ogre::ManualObject *manual)
Add parking area outlines or fills to a manual object.