Skip to content

Commit

Permalink
WIP: new mrpt-viz library
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Jan 4, 2025
1 parent 2270811 commit 137c837
Show file tree
Hide file tree
Showing 247 changed files with 18,665 additions and 901 deletions.
8 changes: 4 additions & 4 deletions libs/apps/src/CGridMapAlignerApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
#include <mrpt/math/ops_containers.h>
#include <mrpt/math/wrap2pi.h>
#include <mrpt/obs/CSensoryFrame.h>
#include <mrpt/opengl/CGridPlaneXY.h>
#include <mrpt/opengl/CSetOfLines.h>
#include <mrpt/opengl/Scene.h>
#include <mrpt/poses/CPoint2D.h>
#include <mrpt/poses/CPose3DPDFGaussian.h>
#include <mrpt/poses/CPosePDFParticles.h>
Expand All @@ -34,6 +31,9 @@
#include <mrpt/system/datetime.h>
#include <mrpt/system/filesystem.h>
#include <mrpt/system/os.h>
#include <mrpt/viz/CGridPlaneXY.h>
#include <mrpt/viz/CSetOfLines.h>
#include <mrpt/viz/Scene.h>

using namespace mrpt::apps;

Expand Down Expand Up @@ -188,7 +188,7 @@ void CGridMapAlignerApp::run()
using namespace mrpt::slam;
using namespace mrpt::maps;
using namespace mrpt::obs;
using namespace mrpt::opengl;
using namespace mrpt::viz;
using namespace mrpt::tfest;
using namespace mrpt::math;
using namespace mrpt::serialization;
Expand Down
20 changes: 10 additions & 10 deletions libs/apps/src/ICP_SLAM_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
#include <mrpt/io/vector_loadsave.h>
#include <mrpt/maps/COccupancyGridMap2D.h>
#include <mrpt/obs/CObservationOdometry.h>
#include <mrpt/opengl/CGridPlaneXY.h>
#include <mrpt/opengl/CPlanarLaserScan.h> // from lib [mrpt-maps]
#include <mrpt/opengl/Scene.h>
#include <mrpt/opengl/stock_objects.h>
#include <mrpt/serialization/CArchive.h>
#include <mrpt/slam/CMetricMapBuilderICP.h>
#include <mrpt/system/CRateTimer.h>
#include <mrpt/system/filesystem.h>
#include <mrpt/system/memory.h>
#include <mrpt/system/os.h>
#include <mrpt/system/thread_name.h>
#include <mrpt/viz/CGridPlaneXY.h>
#include <mrpt/viz/CPlanarLaserScan.h> // from lib [mrpt-maps]
#include <mrpt/viz/Scene.h>
#include <mrpt/viz/stock_objects.h>

using namespace mrpt::apps;

Expand Down Expand Up @@ -75,7 +75,7 @@ void ICP_SLAM_App_Base::run()
using namespace mrpt::slam;
using namespace mrpt::obs;
using namespace mrpt::maps;
using namespace mrpt::opengl;
using namespace mrpt::viz;
using namespace mrpt::gui;
using namespace mrpt::io;
using namespace mrpt::gui;
Expand Down Expand Up @@ -279,7 +279,7 @@ void ICP_SLAM_App_Base::run()
// Save a 3D scene view of the mapping process:
if ((LOG_FREQUENCY > 0 && 0 == (step % LOG_FREQUENCY)) || (SAVE_3D_SCENE || win3D))
{
auto scene = mrpt::opengl::Scene::Create();
auto scene = mrpt::viz::Scene::Create();

Viewport::Ptr view = scene->getViewport("main");
ASSERT_(view);
Expand All @@ -290,7 +290,7 @@ void ICP_SLAM_App_Base::run()
view_map->setTransparent(false);

{
mrpt::opengl::CCamera& cam = view_map->getCamera();
mrpt::viz::CCamera& cam = view_map->getCamera();
cam.setAzimuthDegrees(-90);
cam.setElevationDegrees(90);
cam.setPointingAt(robotPose);
Expand All @@ -299,8 +299,8 @@ void ICP_SLAM_App_Base::run()
}

// The ground:
mrpt::opengl::CGridPlaneXY::Ptr groundPlane =
mrpt::opengl::CGridPlaneXY::Create(-200, 200, -200, 200, 0, 5);
mrpt::viz::CGridPlaneXY::Ptr groundPlane =
mrpt::viz::CGridPlaneXY::Create(-200, 200, -200, 200, 0, 5);
groundPlane->setColor(0.4f, 0.4f, 0.4f);
view->insert(groundPlane);
view_map->insert(CRenderizable::Ptr(groundPlane)); // A copy
Expand All @@ -310,7 +310,7 @@ void ICP_SLAM_App_Base::run()
{
scene->enableFollowCamera(true);

mrpt::opengl::CCamera& cam = view_map->getCamera();
mrpt::viz::CCamera& cam = view_map->getCamera();
cam.setAzimuthDegrees(-45);
cam.setElevationDegrees(45);
cam.setPointingAt(robotPose);
Expand Down
19 changes: 9 additions & 10 deletions libs/apps/src/KFSLAMApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
#include <mrpt/io/vector_loadsave.h>
#include <mrpt/math/ops_containers.h>
#include <mrpt/obs/CRawlog.h>
#include <mrpt/opengl/CGridPlaneXY.h>
#include <mrpt/opengl/CSetOfLines.h>
#include <mrpt/opengl/stock_objects.h>
#include <mrpt/slam/CRangeBearingKFSLAM.h>
#include <mrpt/slam/CRangeBearingKFSLAM2D.h>
#include <mrpt/system/filesystem.h>
#include <mrpt/system/os.h>
#include <mrpt/system/string_utils.h>
#include <mrpt/viz/CGridPlaneXY.h>
#include <mrpt/viz/CSetOfLines.h>
#include <mrpt/viz/stock_objects.h>

#include <fstream>

Expand Down Expand Up @@ -84,7 +84,7 @@ void KFSLAMApp::run()
using namespace mrpt;
using namespace mrpt::slam;
using namespace mrpt::maps;
using namespace mrpt::opengl;
using namespace mrpt::viz;
using namespace mrpt::system;
using namespace mrpt::math;
using namespace mrpt::poses;
Expand Down Expand Up @@ -587,8 +587,8 @@ void KFSLAMApp::Run_KF_SLAM()
if (++path_decim > 10)
{
path_decim = 0;
mrpt::opengl::CSetOfObjects::Ptr xyz =
mrpt::opengl::stock_objects::CornerXYZSimple(0.3f, 2.0f);
mrpt::viz::CSetOfObjects::Ptr xyz =
mrpt::viz::stock_objects::CornerXYZSimple(0.3f, 2.0f);
xyz->setPose(CPose3D(it));
scene3D->insert(xyz);
}
Expand All @@ -597,8 +597,7 @@ void KFSLAMApp::Run_KF_SLAM()

// finally a big corner for the latest robot pose:
{
mrpt::opengl::CSetOfObjects::Ptr xyz =
mrpt::opengl::stock_objects::CornerXYZSimple(1.0, 2.5);
mrpt::viz::CSetOfObjects::Ptr xyz = mrpt::viz::stock_objects::CornerXYZSimple(1.0, 2.5);
xyz->setPose(robotPoseMean3D);
scene3D->insert(xyz);
}
Expand Down Expand Up @@ -652,7 +651,7 @@ void KFSLAMApp::Run_KF_SLAM()
{
const typename ekfslam_t::TDataAssocInfo& da = mapping.getLastDataAssociation();

mrpt::opengl::CSetOfLines::Ptr lins = mrpt::opengl::CSetOfLines::Create();
mrpt::viz::CSetOfLines::Ptr lins = mrpt::viz::CSetOfLines::Create();
lins->setLineWidth(1.2f);
lins->setColor(1, 1, 1);
for (auto it = da.results.associations.begin(); it != da.results.associations.end(); ++it)
Expand Down Expand Up @@ -683,7 +682,7 @@ void KFSLAMApp::Run_KF_SLAM()

if (win3d)
{
mrpt::opengl::Scene::Ptr& scn = win3d->get3DSceneAndLock();
mrpt::viz::Scene::Ptr& scn = win3d->get3DSceneAndLock();
scn = scene3D;

// Update text messages:
Expand Down
18 changes: 9 additions & 9 deletions libs/apps/src/MonteCarloLocalization_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
#include <mrpt/obs/CActionRobotMovement3D.h>
#include <mrpt/obs/CObservationOdometry.h>
#include <mrpt/obs/CRawlog.h>
#include <mrpt/opengl/CDisk.h>
#include <mrpt/opengl/CEllipsoid2D.h>
#include <mrpt/opengl/CEllipsoid3D.h>
#include <mrpt/opengl/CGridPlaneXY.h>
#include <mrpt/opengl/CPointCloud.h>
#include <mrpt/opengl/stock_objects.h>
#include <mrpt/poses/CPose2D.h>
#include <mrpt/poses/CPose2DInterpolator.h>
#include <mrpt/random.h>
Expand All @@ -46,6 +40,12 @@
#include <mrpt/system/CTicTac.h>
#include <mrpt/system/filesystem.h>
#include <mrpt/system/os.h>
#include <mrpt/viz/CDisk.h>
#include <mrpt/viz/CEllipsoid2D.h>
#include <mrpt/viz/CEllipsoid3D.h>
#include <mrpt/viz/CGridPlaneXY.h>
#include <mrpt/viz/CPointCloud.h>
#include <mrpt/viz/stock_objects.h>

#include <Eigen/Dense>

Expand Down Expand Up @@ -90,7 +90,7 @@ void MonteCarloLocalization_Base::initialize(int argc, const char** argv)
using namespace mrpt;
using namespace mrpt::slam;
using namespace mrpt::maps;
using namespace mrpt::opengl;
using namespace mrpt::viz;
using namespace mrpt::gui;
using namespace mrpt::math;
using namespace mrpt::system;
Expand Down Expand Up @@ -409,8 +409,8 @@ void MonteCarloLocalization_Base::do_pf_localization()
mrpt::math::TBoundingBoxf bbox({-50, -50, 0}, {50, 50, 0});
if (auto pts = metricMap->getAsSimplePointsMap(); pts) bbox = pts->boundingBox();

scene.insert(mrpt::opengl::CGridPlaneXY::Create(
bbox.min.x, bbox.max.x, bbox.min.y, bbox.max.y, 0, 5));
scene.insert(
mrpt::viz::CGridPlaneXY::Create(bbox.min.x, bbox.max.x, bbox.min.y, bbox.max.y, 0, 5));

if (win3D)
win3D->setCameraZoom(2 * std::max(bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y));
Expand Down
20 changes: 10 additions & 10 deletions libs/apps/src/RBPF_SLAM_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
#include <mrpt/obs/CActionRobotMovement3D.h>
#include <mrpt/obs/CObservationGasSensors.h>
#include <mrpt/obs/CRawlog.h>
#include <mrpt/opengl/CEllipsoid2D.h>
#include <mrpt/opengl/CEllipsoid3D.h>
#include <mrpt/opengl/CGridPlaneXY.h>
#include <mrpt/opengl/CSetOfLines.h>
#include <mrpt/opengl/stock_objects.h>
#include <mrpt/poses/CPosePDFGaussian.h>
#include <mrpt/random.h>
#include <mrpt/system/filesystem.h> // ASSERT_FILE_EXISTS_()
#include <mrpt/system/memory.h> // getMemoryUsage()
#include <mrpt/viz/CEllipsoid2D.h>
#include <mrpt/viz/CEllipsoid3D.h>
#include <mrpt/viz/CGridPlaneXY.h>
#include <mrpt/viz/CSetOfLines.h>
#include <mrpt/viz/stock_objects.h>

using namespace mrpt::apps;

Expand Down Expand Up @@ -76,7 +76,7 @@ void RBPF_SLAM_App_Base::run()
using namespace mrpt::slam;
using namespace mrpt::obs;
using namespace mrpt::maps;
using namespace mrpt::opengl;
using namespace mrpt::viz;
using namespace mrpt::gui;
using namespace mrpt::io;
using namespace mrpt::gui;
Expand Down Expand Up @@ -396,15 +396,15 @@ void RBPF_SLAM_App_Base::run()
scene = std::make_shared<Scene>();

// The ground:
mrpt::opengl::CGridPlaneXY::Ptr groundPlane =
mrpt::opengl::CGridPlaneXY::Create(-200, 200, -200, 200, 0, 5);
mrpt::viz::CGridPlaneXY::Ptr groundPlane =
mrpt::viz::CGridPlaneXY::Create(-200, 200, -200, 200, 0, 5);
groundPlane->setColor(0.4f, 0.4f, 0.4f);
scene->insert(groundPlane);

// The camera pointing to the current robot pose:
if (CAMERA_3DSCENE_FOLLOWS_ROBOT)
{
mrpt::opengl::CCamera::Ptr objCam = mrpt::opengl::CCamera::Create();
mrpt::viz::CCamera::Ptr objCam = mrpt::viz::CCamera::Create();
CPose3D robotPose;
curPDF.getMean(robotPose);

Expand All @@ -419,7 +419,7 @@ void RBPF_SLAM_App_Base::run()

// Draw the robot particles:
size_t M = mapBuilder->mapPDF.particlesCount();
mrpt::opengl::CSetOfLines::Ptr objLines = mrpt::opengl::CSetOfLines::Create();
mrpt::viz::CSetOfLines::Ptr objLines = mrpt::viz::CSetOfLines::Create();
objLines->setColor(0, 1, 1);
for (size_t i = 0; i < M; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion libs/graphs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define_mrpt_lib(
# Lib name
graphs
# Dependencies
mrpt-opengl
mrpt-viz
)


Expand Down
8 changes: 4 additions & 4 deletions libs/graphs/include/mrpt/graphs/CMRVisualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class CMRVisualizer :

~CMRVisualizer() override;
void drawNodePoints(
mrpt::opengl::CSetOfObjects::Ptr& object,
mrpt::viz::CSetOfObjects::Ptr& object,
const mrpt::containers::yaml* viz_params = nullptr) const override;
void drawEdges(
mrpt::opengl::CSetOfObjects::Ptr& object,
mrpt::viz::CSetOfObjects::Ptr& object,
const mrpt::containers::yaml* viz_params = nullptr) const override;

private:
Expand All @@ -70,10 +70,10 @@ class CMRVisualizer<CPOSE, MAPS_IMPLEMENTATION, TMRSlamNodeAnnotations, EDGE_ANN

~CMRVisualizer();
void drawNodePoints(
mrpt::opengl::CSetOfObjects::Ptr& object,
mrpt::viz::CSetOfObjects::Ptr& object,
const mrpt::containers::yaml* viz_params = nullptr) const;
void drawEdges(
mrpt::opengl::CSetOfObjects::Ptr& object,
mrpt::viz::CSetOfObjects::Ptr& object,
const mrpt::containers::yaml* viz_params = nullptr) const;

private:
Expand Down
15 changes: 6 additions & 9 deletions libs/graphs/include/mrpt/graphs/CMRVisualizer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ CMRVisualizer<CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS, EDGE_ANNOTATIONS>::~

template <class CPOSE, class MAPS_IMPLEMENTATION, class NODE_ANNOTATIONS, class EDGE_ANNOTATIONS>
void CMRVisualizer<CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS, EDGE_ANNOTATIONS>::drawNodePoints(
mrpt::opengl::CSetOfObjects::Ptr& object,
const mrpt::containers::yaml* viz_params /*=NULL*/) const
mrpt::viz::CSetOfObjects::Ptr& object, const mrpt::containers::yaml* viz_params /*=NULL*/) const
{
}

template <class CPOSE, class MAPS_IMPLEMENTATION, class NODE_ANNOTATIONS, class EDGE_ANNOTATIONS>
void CMRVisualizer<CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS, EDGE_ANNOTATIONS>::drawEdges(
mrpt::opengl::CSetOfObjects::Ptr& object,
const mrpt::containers::yaml* viz_params /*=NULL*/) const
mrpt::viz::CSetOfObjects::Ptr& object, const mrpt::containers::yaml* viz_params /*=NULL*/) const
{
}

Expand All @@ -68,10 +66,10 @@ CMRVisualizer<CPOSE, MAPS_IMPLEMENTATION, TMRSlamNodeAnnotations, EDGE_ANNOTATIO
template <class CPOSE, class MAPS_IMPLEMENTATION, class EDGE_ANNOTATIONS>
void CMRVisualizer<CPOSE, MAPS_IMPLEMENTATION, TMRSlamNodeAnnotations, EDGE_ANNOTATIONS>::
drawNodePoints(
mrpt::opengl::CSetOfObjects::Ptr& object,
mrpt::viz::CSetOfObjects::Ptr& object,
const mrpt::containers::yaml* viz_params /*=NULL*/) const
{
using namespace mrpt::opengl;
using namespace mrpt::viz;
using namespace mrpt::graphs;
using namespace mrpt::img;
using namespace std;
Expand Down Expand Up @@ -143,10 +141,9 @@ void CMRVisualizer<CPOSE, MAPS_IMPLEMENTATION, TMRSlamNodeAnnotations, EDGE_ANNO

template <class CPOSE, class MAPS_IMPLEMENTATION, class EDGE_ANNOTATIONS>
void CMRVisualizer<CPOSE, MAPS_IMPLEMENTATION, TMRSlamNodeAnnotations, EDGE_ANNOTATIONS>::drawEdges(
mrpt::opengl::CSetOfObjects::Ptr& object,
const mrpt::containers::yaml* viz_params /*=NULL*/) const
mrpt::viz::CSetOfObjects::Ptr& object, const mrpt::containers::yaml* viz_params /*=NULL*/) const
{
using namespace mrpt::opengl;
using namespace mrpt::viz;
using namespace mrpt::img;

ASSERTMSG_(viz_params, "Pointer to viz_params was not provided.");
Expand Down
4 changes: 2 additions & 2 deletions libs/graphs/include/mrpt/graphs/CNetworkOfPoses.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
#include <mrpt/io/CFileGZInputStream.h>
#include <mrpt/io/CFileGZOutputStream.h>
#include <mrpt/math/utils.h>
#include <mrpt/opengl/CSetOfObjects.h>
#include <mrpt/poses/poses_frwds.h>
#include <mrpt/serialization/CSerializable.h>
#include <mrpt/serialization/stl_serialization.h>
#include <mrpt/system/os.h>
#include <mrpt/viz/CSetOfObjects.h>

#include <iostream>
#include <iterator>
Expand Down Expand Up @@ -294,7 +294,7 @@ class CNetworkOfPoses : public mrpt::graphs::CDirectedGraph<CPOSE, EDGE_ANNOTATI
* class instance.
*/
inline void getAs3DObject(
mrpt::opengl::CSetOfObjects::Ptr object, const mrpt::containers::yaml& viz_params) const
mrpt::viz::CSetOfObjects::Ptr object, const mrpt::containers::yaml& viz_params) const
{
using visualizer_t = mrpt::graphs::detail::CVisualizer<
CPOSE, MAPS_IMPLEMENTATION, NODE_ANNOTATIONS, EDGE_ANNOTATIONS>;
Expand Down
Loading

0 comments on commit 137c837

Please sign in to comment.