Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
Signed-off-by: Mihir Kulkarni <mihirk284@gmail.com>
  • Loading branch information
mihirk284 committed Jul 12, 2020
1 parent 625fc0b commit e1e1ae0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
13 changes: 12 additions & 1 deletion examples/lidar_visual/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,20 @@ void buildScene(ScenePtr _scene)
lidar->SetMaxVerticalAngle(vMaxAngle);
lidar->SetMaxRange(maxRange);
lidar->SetMinRange(minRange);
lidar->SetType(LidarVisualType::LVT_RAY_LINES);

// 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_POINTS);
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
17 changes: 10 additions & 7 deletions ogre/src/OgreLidarVisual.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void OgreLidarVisual::Update()
return;
}

// if visual type is changed, clear all DynamicLines
if (this->lidarVisualType != this->dataPtr->lidarVisType)
{
this->ClearVisualData();
Expand Down Expand Up @@ -191,8 +192,7 @@ void OgreLidarVisual::Update()
// Process each point from received data
// Every line segment, and every triangle is saved separately,
// as a pointer to a DynamicLine
// This initializes and updates only the required DynamicLine variable as selected
// using the API
// This initializes and updates only the selected DynamicLine variables
for (unsigned int j = 0; j < this->verticalCount; ++j)
{
horizontalAngle = this->minHorizontalAngle;
Expand All @@ -217,6 +217,7 @@ void OgreLidarVisual::Update()
this->dataPtr->rayLines.push_back(line);
}
}

else if (this->dataPtr->lidarVisType ==
LidarVisualType::LVT_TRIANGLE_STRIPS)
{
Expand Down Expand Up @@ -286,6 +287,7 @@ void OgreLidarVisual::Update()
}
this->dataPtr->deadZoneRayFans[j]->SetPoint(0, this->offset.Pos());
}

else if (this->dataPtr->lidarVisType ==
LidarVisualType::LVT_POINTS)
{
Expand Down Expand Up @@ -348,15 +350,15 @@ void OgreLidarVisual::Update()
{
if (i >= this->dataPtr->rayLines[j]->PointCount()/2)
{
if(this->displayNonHitting || !inf)
if (this->displayNonHitting || !inf)
{
this->dataPtr->rayLines[j]->AddPoint(startPt);
this->dataPtr->rayLines[j]->AddPoint(inf ? noHitPt : pt);
}
}
else
{
if(this->displayNonHitting || !inf)
if (this->displayNonHitting || !inf)
{
this->dataPtr->rayLines[j]->SetPoint(i*2, startPt);
this->dataPtr->rayLines[j]->SetPoint(i*2+1, inf ? noHitPt : pt);
Expand Down Expand Up @@ -391,7 +393,8 @@ void OgreLidarVisual::Update()
this->dataPtr->rayStrips[j]->SetPoint(i*2+1, inf ? startPt : pt);

this->dataPtr->noHitRayStrips[j]->SetPoint(i*2, startPt);
this->dataPtr->noHitRayStrips[j]->SetPoint(i*2+1, inf ? noHitPt : pt);
this->dataPtr->noHitRayStrips[j]->SetPoint(i*2+1,
inf ? noHitPt : pt);
}
}
// Draw the triangle fan that indicates the dead zone.
Expand All @@ -407,14 +410,14 @@ void OgreLidarVisual::Update()
{
if (i >= this->dataPtr->points[j]->PointCount())
{
if(this->displayNonHitting || !inf)
if (this->displayNonHitting || !inf)
{
this->dataPtr->points[j]->AddPoint(inf ? noHitPt : pt);
}
}
else
{
if(this->displayNonHitting || !inf)
if (this->displayNonHitting || !inf)
{
this->dataPtr->points[j]->SetPoint(i, inf ? noHitPt : pt);
}
Expand Down
15 changes: 15 additions & 0 deletions src/LidarVisual_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,21 @@ void LidarVisualTest::LidarVisual(const std::string &_renderEngine)
lidar->SetMinRange(0.54);
EXPECT_DOUBLE_EQ(lidar->MinRange(), 0.54);

lidar->SetDisplayNonHitting(false);
EXPECT_EQ(lidar->DisplayNonHitting(), false);
lidar->SetDisplayNonHitting(true);
EXPECT_EQ(lidar->DisplayNonHitting(), true);

lidar->SetType(LVT_NONE);
EXPECT_EQ(lidar->Type(), LVT_NONE);
lidar->SetType(LVT_POINTS);
EXPECT_EQ(lidar->Type(), LVT_POINTS);
lidar->SetType(LVT_POINTS);
EXPECT_EQ(lidar->Type(), LVT_POINTS);
lidar->SetType(LVT_TRIANGLE_STRIPS);
EXPECT_EQ(lidar->Type(), LVT_TRIANGLE_STRIPS);


ignition::math::Pose3d p(0.5, 2.56, 3.67, 1.4, 2, 4.5);
lidar->SetOffset(p);
EXPECT_EQ(lidar->Offset(), p);
Expand Down

0 comments on commit e1e1ae0

Please sign in to comment.