Skip to content

Commit

Permalink
Fixed some linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mihirk284 committed Jun 21, 2020
1 parent ca86a29 commit cee20c0
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 57 deletions.
32 changes: 20 additions & 12 deletions include/ignition/rendering/LidarVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef IGNITION_RENDERING_LIDARVISUAL_HH_
#define IGNITION_RENDERING_LIDARVISUAL_HH_

#include <vector>
#include <ignition/common/Time.hh>
#include <ignition/math/Color.hh>
#include <ignition/math/Vector3.hh>
Expand All @@ -33,8 +34,7 @@ namespace ignition
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
//
/// \brief Enum for LidarVisual types
typedef MarkerType LidarVisualType;

typedef MarkerType LidarVisualType;

/// \class LidarVisual LidarVisual.hh ignition/rendering/LidarVisual
/// \brief A LidarVisual geometry class. The visual appearance is based
Expand All @@ -59,47 +59,53 @@ namespace ignition

/// \brief Set minimum vertical angle
/// \param[in] _minVerticalAngle Minimum vertical angle
public: virtual void SetMinVerticalAngle(const double _minVerticalAngle) = 0;
public: virtual void SetMinVerticalAngle(
const double _minVerticalAngle) = 0;

/// \brief Get minimum vertical angle
/// \return The minimum vertical angle value of the lidar visual
public: virtual double MinVerticalAngle() = 0;

/// \brief Set maximum vertical angle
/// \param[in] _maxVerticalAngle Maximum vertical angle value
public: virtual void SetMaxVerticalAngle(const double _maxVerticalAngle) = 0;
public: virtual void SetMaxVerticalAngle(
const double _maxVerticalAngle) = 0;

/// \brief Get minimum vertical angle
/// \return The maximum vertical angle value of the lidar visual
public: virtual double MaxVerticalAngle() = 0;

/// \brief Set minimum horizontal angle
/// \param[in] _minHorizontalAngle Minimum horizontal angle value
public: virtual void SetMinHorizontalAngle(const double _minHorizontalAngle) = 0;
public: virtual void SetMinHorizontalAngle(
const double _minHorizontalAngle) = 0;

/// \brief Get minimum horizontal angle
/// \return The minimum horizontal angle value of the lidar visual
public: virtual double MinHorizontalAngle() = 0;

/// \brief Set maximum horizontal angle
/// \param[in] _maxHorizontalAngle Maximum horizontal angle value
public: virtual void SetMaxHorizontalAngle(const double _maxHorizontalAngle) = 0;
public: virtual void SetMaxHorizontalAngle(
const double _maxHorizontalAngle) = 0;

/// \brief Get maximum horizontal angle
/// \return The maximum horizontal angle value of the lidar visual
public: virtual double MaxHorizontalAngle() = 0;

/// \brief Set number of vertical rays
/// \param[in] _verticalRayCount Number of vertical rays
public: virtual void SetVerticalRayCount(const unsigned int _verticalRayCount) = 0;
public: virtual void SetVerticalRayCount(
const unsigned int _verticalRayCount) = 0;

/// \brief Get number of vertical rays
/// \return The number of vertical rays
public: virtual unsigned int VerticalRayCount() = 0;

/// \brief Set number of horizontal rays
/// \return _horizontalRayCount Number of vertical rays
public: virtual void SetHorizontalRayCount(const unsigned int _horizontalRayCount) = 0;
public: virtual void SetHorizontalRayCount(
const unsigned int _horizontalRayCount) = 0;

/// \brief Get number of horizontal rays
/// \return The number of horizontal rays
Expand All @@ -123,23 +129,26 @@ namespace ignition

/// \brief Set vertical step angle
/// \param[in] _verticalAngleStep Difference in vertical angle between two rays
public: virtual void SetVerticalAngleStep(const double _verticalAngleStep) = 0;
public: virtual void SetVerticalAngleStep(
const double _verticalAngleStep) = 0;

/// \brief Get vertical step angle
/// \return The difference in vertical angle between two rays
public: virtual double VerticalAngleStep() = 0;

/// \brief Set horizontal step angle
/// \param[in] _horizontalAngleStep Difference in horizontal angle between two rays
public: virtual void SetHorizontalAngleStep(const double _horizontalAngleStep) = 0;
public: virtual void SetHorizontalAngleStep(
const double _horizontalAngleStep) = 0;

/// \brief Get horizontal step angle
/// \return The difference in horizontal angle between two rays
public: virtual double HorizontalAngleStep() = 0;

/// \brief Set offset of visual
/// \param[in] _offset The offset of the lidar rays from the visual origin
public: virtual void SetOffset(const ignition::math::Pose3d _offset) = 0;
public: virtual void SetOffset(
const ignition::math::Pose3d _offset) = 0;

/// \brief Get offset of visual
/// \return The offset of the lidar rays from visual origin
Expand All @@ -148,7 +157,6 @@ namespace ignition
/// \brief Get number of points in laser data
/// \return The number of points in the laser data
public: virtual unsigned int GetPointCount() = 0;

};
}
}
Expand Down
30 changes: 19 additions & 11 deletions include/ignition/rendering/base/BaseLidarVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef IGNITION_RENDERING_BASELIDARVISUAL_HH_
#define IGNITION_RENDERING_BASELIDARVISUAL_HH_

#include <vector>
#include "ignition/rendering/LidarVisual.hh"
#include "ignition/rendering/base/BaseObject.hh"
#include "ignition/rendering/base/BaseRenderTypes.hh"
Expand Down Expand Up @@ -57,37 +58,43 @@ namespace ignition
public: virtual void Init();

// Documentation inherited
public: virtual void SetMinVerticalAngle(const double _minVerticalAngle);
public: virtual void SetMinVerticalAngle(
const double _minVerticalAngle);

// Documentation inherited
public: virtual double MinVerticalAngle();

// Documentation inherited
public: virtual void SetMaxVerticalAngle(const double _maxVerticalAngle);
public: virtual void SetMaxVerticalAngle(
const double _maxVerticalAngle);

// Documentation inherited
public: virtual double MaxVerticalAngle();

// Documentation inherited
public: virtual void SetMinHorizontalAngle(const double _minHorizontalAngle);
public: virtual void SetMinHorizontalAngle(
const double _minHorizontalAngle);

// Documentation inherited
public: virtual double MinHorizontalAngle();

// Documentation inherited
public: virtual void SetMaxHorizontalAngle(const double _maxHorizontalAngle);
public: virtual void SetMaxHorizontalAngle(
const double _maxHorizontalAngle);

// Documentation inherited
public: virtual double MaxHorizontalAngle();

// Documentation inherited
public: virtual void SetVerticalRayCount(const unsigned int _verticalRayCount);
public: virtual void SetVerticalRayCount(
const unsigned int _verticalRayCount);

// Documentation inherited
public: virtual unsigned int VerticalRayCount();

// Documentation inherited
public: virtual void SetHorizontalRayCount(const unsigned int _horizontalRayCount);
public: virtual void SetHorizontalRayCount(
const unsigned int _horizontalRayCount);

// Documentation inherited
public: virtual unsigned int HorizontalRayCount();
Expand All @@ -105,19 +112,22 @@ namespace ignition
public: virtual double MaxRange();

// Documentation inherited
public: virtual void SetVerticalAngleStep(const double _verticalAngleStep);
public: virtual void SetVerticalAngleStep(
const double _verticalAngleStep);

// Documentation inherited
public: virtual double VerticalAngleStep();

// Documentation inherited
public: virtual void SetHorizontalAngleStep(const double _horizontalAngleStep);
public: virtual void SetHorizontalAngleStep(
const double _horizontalAngleStep);

// Documentation inherited
public: virtual double HorizontalAngleStep();

// Documentation inherited
public: virtual void SetOffset(const ignition::math::Pose3d _offset);
public: virtual void SetOffset(
const ignition::math::Pose3d _offset);

// Documentation inherited
public: virtual ignition::math::Pose3d Offset();
Expand Down Expand Up @@ -157,7 +167,6 @@ namespace ignition

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

};

/////////////////////////////////////////////////
Expand Down Expand Up @@ -376,7 +385,6 @@ namespace ignition
{
return this->offset;
}

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ogre/include/ignition/rendering/ogre/OgreLidarVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef IGNITION_RENDERING_OGRE_OGRELIDARVISUAL_HH_
#define IGNITION_RENDERING_OGRE_OGRELIDARVISUAL_HH_

#include <vector>
#include <memory>
#include "ignition/rendering/base/BaseLidarVisual.hh"
#include "ignition/rendering/ogre/OgreVisual.hh"
Expand Down Expand Up @@ -52,7 +53,6 @@ namespace ignition
// Documentation inherited.
public: virtual void Destroy() override;


// Documentation inherited
public: virtual void Update() override;

Expand Down
27 changes: 3 additions & 24 deletions ogre/src/OgreLidarVisual.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class ignition::rendering::OgreLidarVisualPrivate

/// \brief True if new message is received
public: bool receivedMsg;

};

using namespace ignition;
Expand All @@ -63,13 +62,12 @@ OgreLidarVisual::~OgreLidarVisual()
//////////////////////////////////////////////////
void OgreLidarVisual::PreRender()
{
//no ops
// no ops
}

//////////////////////////////////////////////////
void OgreLidarVisual::Destroy()
{

for (auto ray : this->dataPtr->noHitRayStrips)
{
ray.get()->Clear();
Expand All @@ -95,7 +93,6 @@ void OgreLidarVisual::Destroy()
}

this->ClearPoints();

}

//////////////////////////////////////////////////
Expand All @@ -110,7 +107,6 @@ void OgreLidarVisual::Create()
{
this->ClearPoints();
this->dataPtr->receivedMsg = false;

}

//////////////////////////////////////////////////
Expand All @@ -137,27 +133,23 @@ void OgreLidarVisual::SetLidarMessage(std::vector<double> &_msg)
//////////////////////////////////////////////////
void OgreLidarVisual::Update()
{

// TODO if(!this->dataPtr->laserMsg for checking is required in the later stage)
if(!this->dataPtr->receivedMsg || this->dataPtr->laserMsg.size() == 0)
{
ignerr << "Message not received. Exiting Updat function"
<< std::endl;
return;
}


this->dataPtr->receivedMsg = false;
double horizontalAngle = this->minHorizontalAngle;
double verticalAngle = this->minVerticalAngle;

if (this->dataPtr->laserMsg.size() != this->verticalCount * this->horizontalCount)
{
ignerr << "Size of laser message and count of vertical and horizontal rays inconsistent"
ignerr << "Size of laser message inconsistent with ray count"
<< std::endl;
return;
}


// Process each point from message
// Every line segment, and every individual triangle is saved separately as a pointer to a DynamicLine
Expand All @@ -174,36 +166,29 @@ void OgreLidarVisual::Update()
std::shared_ptr<Ogre::MovableObject> mv = std::dynamic_pointer_cast<Ogre::MovableObject>(line);
this->Node()->attachObject(mv.get());
this->dataPtr->rayStrips.push_back(line);



line = std::shared_ptr<OgreDynamicLines>(new OgreDynamicLines(MT_TRIANGLE_STRIP));
line->setMaterial("Lidar/LightBlueLaser");
mv = std::dynamic_pointer_cast<Ogre::MovableObject>(line);
this->Node()->attachObject(mv.get());
this->dataPtr->noHitRayStrips.push_back(line);


line = std::shared_ptr<OgreDynamicLines>(new OgreDynamicLines(MT_TRIANGLE_FAN));
line->setMaterial("Lidar/BlackTransparent");
mv = std::dynamic_pointer_cast<Ogre::MovableObject>(line);
this->Node()->attachObject(mv.get());
this->dataPtr->deadZoneRayFans.push_back(line);
this->dataPtr->deadZoneRayFans[j]->AddPoint(ignition::math::Vector3d::Zero);




line = std::shared_ptr<OgreDynamicLines>(new OgreDynamicLines(MT_LINE_LIST));
line->setMaterial("Lidar/Blue");
mv = std::dynamic_pointer_cast<Ogre::MovableObject>(line);
this->Node()->attachObject(mv.get());
this->dataPtr->rayLines.push_back(line);


this->SetVisibilityFlags(0x0FFFFFFF);

}

this->dataPtr->deadZoneRayFans[j]->SetPoint(0, this->offset.Pos());


Expand All @@ -214,7 +199,6 @@ void OgreLidarVisual::Update()
//calculate range of the ray
double r = this->dataPtr->laserMsg[j * this->verticalCount + i];


if (verticalAngle > this->maxVerticalAngle)
{
ignerr << "Vertical angle exceeds maximum limits. Please check the input"
Expand All @@ -240,7 +224,6 @@ void OgreLidarVisual::Update()
}

bool inf = std::isinf(r);

ignition::math::Quaterniond ray(
ignition::math::Vector3d(0.0, -verticalAngle, horizontalAngle));

Expand All @@ -261,7 +244,6 @@ void OgreLidarVisual::Update()

// Compute the end point of the no-hit ray
ignition::math::Vector3d noHitPt = (axis * noHitRange) + this->offset.Pos();


// Draw the lines and strips that represent each simulated ray
if (i >= this->dataPtr->rayLines[j]->PointCount()/2)
Expand All @@ -274,7 +256,6 @@ void OgreLidarVisual::Update()

this->dataPtr->noHitRayStrips[j]->AddPoint(startPt);
this->dataPtr->noHitRayStrips[j]->AddPoint(inf ? noHitPt : pt);

}
else
{
Expand All @@ -286,7 +267,6 @@ void OgreLidarVisual::Update()

this->dataPtr->noHitRayStrips[j]->SetPoint(i*2, startPt);
this->dataPtr->noHitRayStrips[j]->SetPoint(i*2+1, inf ? noHitPt : pt);

}

// Draw the triangle fan that indicates the dead zone.
Expand All @@ -305,7 +285,6 @@ void OgreLidarVisual::Update()
}
verticalAngle += this->verticalAngleStep;
}

}

//////////////////////////////////////////////////
Expand Down
1 change: 0 additions & 1 deletion ogre2/include/ignition/rendering/ogre2/Ogre2LidarVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ namespace ignition

/// \brief Marker should only be created by scene.
private: friend class Ogre2Scene;

};
}
}
Expand Down
Loading

0 comments on commit cee20c0

Please sign in to comment.