Skip to content

Commit

Permalink
octomap visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
XinkeAE committed Sep 9, 2017
2 parents 20bf272 + 1f90b9a commit 32e0643
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 2 deletions.
8 changes: 8 additions & 0 deletions include/MapDrawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ class MapDrawer
void SetCurrentPath(const std::vector<std::vector<double>> &bPath);
void DrawPath();
void SetCurrentCounter(int counter);
void DrawMapCollision();
void SetCurrentCollision(const std::vector<std::vector<float>> &bCollision);





private:
std::vector<std::vector<double>> mPath;
std::vector<std::vector<float>> mCollisionPts;
float mKeyFrameSize;
float mKeyFrameLineWidth;
float mGraphLineWidth;
Expand All @@ -69,6 +73,8 @@ class MapDrawer
0,-1, 0, 0,
0, 0, 0, 1);

cv::Mat T_sw_mat=(T_ws_mat.inv());

cv::Mat T_cb_mat = (cv::Mat_<float>(4,4) << 0, -1, 0, -0.1, //-0.1,
0, 0, -1, 0,
1,0, 0, -0.22, //-0.22,
Expand All @@ -78,6 +84,8 @@ class MapDrawer
std::mutex mMutexPath;

std::mutex mMutexCounter;

std::mutex mMutexCollision;
};

} //namespace ORB_SLAM
Expand Down
2 changes: 2 additions & 0 deletions include/Tracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class Tracking
// Get Scale Factor
float GetDepthScaleFactor();

void UpdateCollision(const std::vector<std::vector<float>> &bCollision);


public:

Expand Down
34 changes: 34 additions & 0 deletions src/MapDrawer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,40 @@ void MapDrawer::DrawMapPoints()

glEnd();
}
void MapDrawer::SetCurrentCollision(const std::vector<std::vector<float>> &bCollision)
{
unique_lock<mutex> lock(mMutexCollision);
mCollisionPts=bCollision;
//std::cout<<"Octomap Updated in Drawer"<<std::endl;
}

void MapDrawer::DrawMapCollision()
{
//const vector<MapPoint*> &vpMPs = mpMap->GetAllMapPoints();
//const vector<MapPoint*> &vpRefMPs = mpMap->GetReferenceMapPoints();

//set<MapPoint*> spRefMPs(vpRefMPs.begin(), vpRefMPs.end());
unique_lock<mutex> lock(mMutexCollision);

if(mCollisionPts.empty())
return;

int rows = static_cast<int>(mCollisionPts.size());
glPointSize(9*mPointSize);
glBegin(GL_POINTS);
glColor3f(0.0,0.0,1.0);

for(int i=0; i<rows; i++)
{
cv::Mat P_w=(cv::Mat_<float>(4,1) << mCollisionPts[i][0],
mCollisionPts[i][1],
mCollisionPts[i][2],
1);
cv::Mat P_s=T_sw_mat*P_w;
glVertex3f(P_s.at<float>(0,0),P_s.at<float>(1,0),P_s.at<float>(2,0));
}
glEnd();
}

void MapDrawer::DrawKeyFrames(const bool bDrawKF, const bool bDrawGraph)
{
Expand Down
2 changes: 2 additions & 0 deletions src/System.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ cv::Mat System::TrackRGBD(const cv::Mat &im, const cv::Mat &depthmap, const doub
mpOctomapBuilder->UpdateOctomap(depthmap, currPose);
vector<vector<float>> occupiedPoints = mpOctomapBuilder->getOccupiedPoints();
cout << "occupancy grid size = " << occupiedPoints.size() << endl;

mpTracker->UpdateCollision(occupiedPoints);
if(occupiedPoints.size()!=0)
octomapInitialize = true;
}
Expand Down
10 changes: 8 additions & 2 deletions src/Tracking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,14 @@ cv::Mat Tracking::GrabImageRGBD(const cv::Mat &imRGB,const cv::Mat &imD, const d
}

}

/*
// recover from the LOST state
if(mState==LOST){
recoverCounter++;
if(recoverCounter > 100){
recoverMode = true;
cout << "start recover mode" << endl;
//cout << "start recover mode" << endl;
}
}else if (mState==OK)
{
Expand Down Expand Up @@ -303,6 +303,8 @@ cv::Mat Tracking::GrabImageRGBD(const cv::Mat &imRGB,const cv::Mat &imD, const d
recoverMode = false;
//cout << "not in recover mode" << endl;
}
*/
return mCurrentFrame.mTcw.clone();
}

Expand Down Expand Up @@ -1957,6 +1959,10 @@ bool Tracking::checkWayPointRecover(){

}

void Tracking::UpdateCollision(const std::vector<std::vector<float>> &bCollision)
{
this->mpMapDrawer->SetCurrentCollision(bCollision);
}


} //namespace ORB_SLAM
1 change: 1 addition & 0 deletions src/Viewer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ void Viewer::Run()
mpMapDrawer->DrawMapPoints();

mpMapDrawer->DrawPath();
mpMapDrawer->DrawMapCollision();

pangolin::FinishFrame();

Expand Down

0 comments on commit 32e0643

Please sign in to comment.