Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types for lidar visual #114

Merged
merged 17 commits into from
Jul 22, 2020
Merged
15 changes: 14 additions & 1 deletion examples/lidar_visual/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,20 @@ void buildScene(ScenePtr _scene)
lidar->SetMaxVerticalAngle(vMaxAngle);
lidar->SetMaxRange(maxRange);
lidar->SetMinRange(minRange);

// the types can be set as follows:-
// LVT_POINTS -> Lidar Points at the range value
// LVT_RAY_LINES -> Lines along the lidar sensor to the obstacle
// LVT_TRIANGLE_STRIPS -> Coloured triangle strips denoting hitting and
// non-hitting parts of the scan
lidar->SetType(LidarVisualType::LVT_RAY_LINES);
mihirk284 marked this conversation as resolved.
Show resolved Hide resolved
lidar->SetPoints(pts);

// set this value to false if only the rays that are hitting another obstacle
// are to be displayed.
// This does NOT work for LVT_TRIANGLE_STRIPS
lidar->SetDisplayNonHitting(false);

lidar->SetWorldPosition(testPose.Pos());
lidar->SetWorldRotation(testPose.Rot());
root->AddChild(lidar);
Expand Down Expand Up @@ -266,4 +279,4 @@ int main(int _argc, char** _argv)
}
run(cameras);
return 0;
}
}
35 changes: 34 additions & 1 deletion include/ignition/rendering/LidarVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ namespace ignition
namespace rendering
{
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
//
/// \brief Enum for LidarVisual types
enum IGNITION_RENDERING_VISIBLE LidarVisualType
{
/// \brief No type
LVT_NONE = 0,

/// \brief Ray line visual
LVT_RAY_LINES = 1,

/// \brief Points visual
LVT_POINTS = 2,

/// \brief Triangle strips visual
LVT_TRIANGLE_STRIPS = 3
};

/// \class LidarVisual LidarVisual.hh ignition/rendering/LidarVisual
/// \brief A LidarVisual geometry class. The visual appearance is based
/// on the type specified.
Expand Down Expand Up @@ -139,9 +156,25 @@ namespace ignition
/// \brief Get the points in laser data
/// \return The points in the laser data
public: virtual std::vector<double> Points() const = 0;

/// \brief Set type for lidar visual
/// \param[in] _type The type of visualisation for lidar data
public: virtual void SetType(const LidarVisualType _type) = 0;

/// \brief Get the type for lidar visual
/// \return The type for lidar visual
public: virtual LidarVisualType Type() const = 0;

/// \brief Set if non-hitting rays will be displayed
/// (this does not work for TRIANGLE_STRIPS visual)
mihirk284 marked this conversation as resolved.
Show resolved Hide resolved
/// \param[in] _display Boolean value to display non hitting visuals
public: virtual void SetDisplayNonHitting(bool _display) = 0;

/// \brief Get if non-hitting rays will be displayed
/// \return Boolean value if non-hitting rays will be displayed
public: virtual bool DisplayNonHitting() const = 0;
};
}
}
}

#endif
47 changes: 47 additions & 0 deletions include/ignition/rendering/base/BaseLidarVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,21 @@ namespace ignition
// Documentation inherited
public: virtual std::vector<double> Points() const override;

// Documentation inherited
public: virtual void SetType(const LidarVisualType _type) override;

// Documentation inherited
public: virtual LidarVisualType Type() const override;

/// \brief Create predefined materials for lidar visual
public: virtual void CreateMaterials();

// Documentation inherited
public: virtual void SetDisplayNonHitting(bool _display) override;

// Documentation inherited
public: virtual bool DisplayNonHitting() const override;

/// \brief Vertical minimal angle
protected: double minVerticalAngle = 0;

Expand Down Expand Up @@ -160,8 +172,15 @@ namespace ignition
/// \brief Maximum Range
protected: double maxRange = 0;

/// \brief Minimum Range
mihirk284 marked this conversation as resolved.
Show resolved Hide resolved
protected: bool displayNonHitting = true;

/// \brief Offset of visual
protected: ignition::math::Pose3d offset = ignition::math::Pose3d::Zero;

/// \brief Type of lidar visualisation
protected: LidarVisualType lidarVisualType =
LidarVisualType::LVT_TRIANGLE_STRIPS;
};

/////////////////////////////////////////////////
Expand Down Expand Up @@ -386,6 +405,34 @@ namespace ignition
return this->offset;
}

/////////////////////////////////////////////////
template <class T>
void BaseLidarVisual<T>::SetType(const LidarVisualType _type)
{
this->lidarVisualType = _type;
}

/////////////////////////////////////////////////
template <class T>
LidarVisualType BaseLidarVisual<T>::Type() const
{
return this->lidarVisualType;
}

/////////////////////////////////////////////////
template <class T>
void BaseLidarVisual<T>::SetDisplayNonHitting(bool _display)
{
this->displayNonHitting = _display;
}

/////////////////////////////////////////////////
template <class T>
bool BaseLidarVisual<T>::DisplayNonHitting() const
{
return this->displayNonHitting;
}

/////////////////////////////////////////////////
template <class T>
void BaseLidarVisual<T>::CreateMaterials()
Expand Down