mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 09:30:25 +08:00
Tango: updated UI
This commit is contained in:
@@ -298,7 +298,11 @@ int RTABMapApp::openDatabase(const std::string & databasePath, bool databaseInMe
|
||||
optTexture_ = cv::Mat();
|
||||
cv::Mat cloudMat;
|
||||
std::vector<std::vector<std::vector<unsigned int> > > polygons;
|
||||
#if PCL_VERSION_COMPARE(>=, 1, 8, 0)
|
||||
std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > texCoords;
|
||||
#else
|
||||
std::vector<std::vector<Eigen::Vector2f> > texCoords;
|
||||
#endif
|
||||
cv::Mat textures;
|
||||
std::map<int, rtabmap::Transform> optPoses;
|
||||
if(!databaseSource.empty())
|
||||
@@ -1051,6 +1055,7 @@ int RTABMapApp::Render()
|
||||
pcl::fromPCLPointCloud2(optMesh_->cloud, *mesh.cloud);
|
||||
pcl::fromPCLPointCloud2(optMesh_->cloud, *mesh.normals);
|
||||
mesh.polygons = optMesh_->tex_polygons[0];
|
||||
mesh.pose.setIdentity();
|
||||
if(optMesh_->tex_coordinates.size())
|
||||
{
|
||||
mesh.texCoords = optMesh_->tex_coordinates[0];
|
||||
@@ -1568,7 +1573,7 @@ int RTABMapApp::Render()
|
||||
if(rtabmapEvents.size())
|
||||
{
|
||||
// send statistics to GUI
|
||||
LOGW("Posting PostRenderEvent! %fs", renderingTime_);
|
||||
LOGI("New data added to map, rendering time: %fs", renderingTime_);
|
||||
UEventsManager::post(new PostRenderEvent(rtabmapEvents.back()));
|
||||
rtabmapEvents.pop_back();
|
||||
|
||||
@@ -1740,6 +1745,10 @@ void RTABMapApp::setOrthoCropFactor(float value)
|
||||
{
|
||||
main_scene_.setOrthoCropFactor(value);
|
||||
}
|
||||
void RTABMapApp::setGridRotation(float value)
|
||||
{
|
||||
main_scene_.setGridRotation(value);
|
||||
}
|
||||
void RTABMapApp::setLighting(bool enabled)
|
||||
{
|
||||
main_scene_.setLighting(enabled);
|
||||
@@ -2764,7 +2773,11 @@ bool RTABMapApp::postExportation(bool visualize)
|
||||
{
|
||||
cv::Mat cloudMat;
|
||||
std::vector<std::vector<std::vector<unsigned int> > > polygons;
|
||||
#if PCL_VERSION_COMPARE(>=, 1, 8, 0)
|
||||
std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > texCoords;
|
||||
#else
|
||||
std::vector<std::vector<Eigen::Vector2f> > texCoords;
|
||||
#endif
|
||||
cv::Mat textures;
|
||||
std::map<int, rtabmap::Transform> optPoses;
|
||||
if(rtabmap_ && rtabmap_->getMemory())
|
||||
@@ -2801,7 +2814,11 @@ bool RTABMapApp::writeExportedMesh(const std::string & directory, const std::str
|
||||
pcl::TextureMesh::Ptr textureMesh(new pcl::TextureMesh);
|
||||
cv::Mat cloudMat;
|
||||
std::vector<std::vector<std::vector<unsigned int> > > polygons;
|
||||
#if PCL_VERSION_COMPARE(>=, 1, 8, 0)
|
||||
std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > texCoords;
|
||||
#else
|
||||
std::vector<std::vector<Eigen::Vector2f> > texCoords;
|
||||
#endif
|
||||
cv::Mat textures;
|
||||
std::map<int, rtabmap::Transform> optPoses;
|
||||
if(rtabmap_ && rtabmap_->getMemory())
|
||||
|
||||
@@ -121,6 +121,7 @@ class RTABMapApp : public UEventsHandler {
|
||||
void setPointSize(float value);
|
||||
void setFOV(float angle);
|
||||
void setOrthoCropFactor(float value);
|
||||
void setGridRotation(float value);
|
||||
void setLighting(bool enabled);
|
||||
void setBackfaceCulling(bool enabled);
|
||||
void setWireframe(bool enabled);
|
||||
|
||||
@@ -180,6 +180,12 @@ Java_com_introlab_rtabmap_RTABMapLib_setOrthoCropFactor(
|
||||
return app.setOrthoCropFactor(value);
|
||||
}
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_introlab_rtabmap_RTABMapLib_setGridRotation(
|
||||
JNIEnv*, jobject, float value)
|
||||
{
|
||||
return app.setGridRotation(value);
|
||||
}
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_introlab_rtabmap_RTABMapLib_setLighting(
|
||||
JNIEnv*, jobject, bool enabled)
|
||||
{
|
||||
|
||||
@@ -70,6 +70,7 @@ private:
|
||||
bool isVisible() const {return visible_;}
|
||||
bool hasMesh() const {return polygons_.size()!=0;}
|
||||
bool hasTexture() const {return textures_ != 0;}
|
||||
float getMinHeight() const {return minHeight_;}
|
||||
const pcl::PointXYZ & aabbMinModel() const {return aabbMinModel_;}
|
||||
const pcl::PointXYZ & aabbMaxModel() const {return aabbMaxModel_;}
|
||||
const pcl::PointXYZ & aabbMinWorld() const {return aabbMinWorld_;}
|
||||
@@ -126,6 +127,7 @@ private:
|
||||
bool visible_;
|
||||
bool hasNormals_;
|
||||
std::vector<unsigned int> organizedToDenseIndices_;
|
||||
float minHeight_; // odom frame
|
||||
|
||||
float gainR_;
|
||||
float gainG_;
|
||||
|
||||
@@ -16,12 +16,16 @@
|
||||
|
||||
#include <tango-gl/conversions.h>
|
||||
#include <tango-gl/gesture_camera.h>
|
||||
#include <tango-gl/util.h>
|
||||
|
||||
#include <rtabmap/utilite/ULogger.h>
|
||||
#include <rtabmap/utilite/UStl.h>
|
||||
#include <rtabmap/utilite/UTimer.h>
|
||||
#include <rtabmap/core/util3d_filtering.h>
|
||||
#include <rtabmap/core/util3d_transforms.h>
|
||||
#include <rtabmap/core/util3d_surface.h>
|
||||
#include <pcl/common/transforms.h>
|
||||
#include <pcl/common/common.h>
|
||||
|
||||
#include <glm/gtx/transform.hpp>
|
||||
|
||||
@@ -32,7 +36,7 @@
|
||||
// add an offset in z to our origin. We'll set this offset to 1.3 meters based
|
||||
// on the average height of a human standing with a Tango device. This allows us
|
||||
// to place a grid roughly on the ground for most users.
|
||||
const glm::vec3 kHeightOffset = glm::vec3(0.0f, 1.3f, 0.0f);
|
||||
const glm::vec3 kHeightOffset = glm::vec3(0.0f, -1.3f, 0.0f);
|
||||
|
||||
// Color of the motion tracking trajectory.
|
||||
const tango_gl::Color kTraceColor(0.66f, 0.66f, 0.66f);
|
||||
@@ -130,7 +134,7 @@ void Scene::InitGLContent()
|
||||
trace_->ClearVertexArray();
|
||||
trace_->SetColor(kTraceColor);
|
||||
grid_->SetColor(kGridColor);
|
||||
grid_->SetPosition(-kHeightOffset);
|
||||
grid_->SetPosition(kHeightOffset);
|
||||
box_->SetShader();
|
||||
box_->SetColor(1,0,0);
|
||||
|
||||
@@ -194,6 +198,10 @@ void Scene::clear()
|
||||
graph_ = 0;
|
||||
}
|
||||
pointClouds_.clear();
|
||||
if(grid_)
|
||||
{
|
||||
grid_->SetPosition(kHeightOffset);
|
||||
}
|
||||
}
|
||||
|
||||
//Should only be called in OpenGL thread!
|
||||
@@ -565,6 +573,15 @@ void Scene::setOrthoCropFactor(float value)
|
||||
{
|
||||
gesture_camera_->SetOrthoCropFactor(value);
|
||||
}
|
||||
void Scene::setGridRotation(float angleDeg)
|
||||
{
|
||||
float angleRad = angleDeg * DEGREE_2_RADIANS;
|
||||
if(grid_)
|
||||
{
|
||||
glm::quat rot = glm::rotate(glm::quat(1,0,0,0), angleRad, glm::vec3(0, 1, 0));
|
||||
grid_->SetRotation(rot);
|
||||
}
|
||||
}
|
||||
|
||||
rtabmap::Transform Scene::GetOpenGLCameraPose(float * fov) const
|
||||
{
|
||||
@@ -669,6 +686,58 @@ void Scene::addMesh(
|
||||
PointCloudDrawable * drawable = new PointCloudDrawable(mesh, createWireframe);
|
||||
drawable->setPose(pose);
|
||||
pointClouds_.insert(std::make_pair(id, drawable));
|
||||
|
||||
if(!mesh.pose.isNull() && mesh.cloud->size() && (!mesh.cloud->isOrganized() || mesh.indices->size()))
|
||||
{
|
||||
UTimer time;
|
||||
float height = 0.0f;
|
||||
Eigen::Affine3f affinePose = mesh.pose.toEigen3f();
|
||||
if(mesh.polygons.size())
|
||||
{
|
||||
for(unsigned int i=0; i<mesh.polygons.size(); ++i)
|
||||
{
|
||||
for(unsigned int j=0; j<mesh.polygons[i].vertices.size(); ++j)
|
||||
{
|
||||
pcl::PointXYZRGB pt = pcl::transformPoint(mesh.cloud->at(mesh.polygons[i].vertices[j]), affinePose);
|
||||
if(pt.z < height)
|
||||
{
|
||||
height = pt.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(mesh.cloud->isOrganized())
|
||||
{
|
||||
for(unsigned int i=0; i<mesh.indices->size(); ++i)
|
||||
{
|
||||
pcl::PointXYZRGB pt = pcl::transformPoint(mesh.cloud->at(mesh.indices->at(i)), affinePose);
|
||||
if(pt.z < height)
|
||||
{
|
||||
height = pt.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(unsigned int i=0; i<mesh.cloud->size(); ++i)
|
||||
{
|
||||
pcl::PointXYZRGB pt = pcl::transformPoint(mesh.cloud->at(i), affinePose);
|
||||
if(pt.z < height)
|
||||
{
|
||||
height = pt.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(grid_->GetPosition().y == kHeightOffset.y || grid_->GetPosition().y > height)
|
||||
{
|
||||
grid_->SetPosition(glm::vec3(0,height,0));
|
||||
}
|
||||
LOGD("compute min height %f s", time.ticks());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -129,6 +129,7 @@ class Scene {
|
||||
void setPointSize(float size) {pointSize_ = size;}
|
||||
void setFOV(float angle);
|
||||
void setOrthoCropFactor(float value);
|
||||
void setGridRotation(float angleDeg);
|
||||
void setLighting(bool enabled) {lighting_ = enabled;}
|
||||
void setBackfaceCulling(bool enabled) {backfaceCulling_ = enabled;}
|
||||
void setWireframe(bool enabled) {wireFrame_ = enabled;}
|
||||
|
||||
Reference in New Issue
Block a user