MRPT

1. https://www.mrpt.org/Building_and_Installing_Instructions#1_Prerequisites

P1. error C2371: “int32_t”: 重定义;不同的基类型  或“int8_t”

解决办法:因为两个.h文件所定义的int32_t和int8_t的类型不同。错误会提示哪两个.h文件冲突,打开pstdint.h文件,找到对应的定义,并修改为另一个.h文件的定义类型。

P2. Miscellaneous.h文件 error C2719: “p1”: 具有 __declspec(align('16')) 的形参将不被对齐 ,这个问题是编译时候包含了对PCL的支持

问题分析参考:https://stackoverflow.com/questions/28488986/formal-parameter-with-declspecalign16-wont-be-aligned/28489103

//Miscellaneous.h 修改为 
 struct Segment
  {
    Segment(const PointT& p0, const PointT& p1)
    {
		P0 = p0;
		P1 = p1;
	};

    PointT P0, P1;
  };

  /*! Square of the distance between two segments */
  float PBMAP_IMPEXP dist3D_Segment_to_Segment2(const Segment& S1, const Segment& S2);

//对应的 Miscellaneous.cpp 修改为
float PBMAP_IMPEXP dist3D_Segment_to_Segment2(const Segment& S1, const Segment& S2)
{}

//同时注释掉 PbMapMaker.h
typedef pcl::PointXYZRGBA PointT;

2. Visula Studio 2013 测试

1、先将D:AppsMRPTincludemrptmrpt-configmrpt目录下的config.h和version.h复制到D:AppsMRPTincludemrpt目录下。

2、打开VS2013,建立mrptTest项目:新建项目——C++——设置文件名mrptTest, WIN32控制台应用程序

 3、打开工程属性——VC++目录——包含目录 :添加目录D:AppsMRPTinclude和 D:AppsMRPTlibsXXXXinclude

第二个包含选项众多,我是将所有libs目录下所有的mrpt和otherlibs文件夹复制到D:AppsMRPTinclude,然后再添加该目录。需要用wxWidgets,则添加D:AppswxWidgets-3.0.4include

4、打开工程属性——VC++ 目录——库目录:在配置Debug中添加目录D:AppsMRPTlib 并链接库 libmrpt-base130.lib

三、编写代码 这里采用MRPT的例子,参考 https://raw.githubusercontent.com/MRPT/mrpt/master/doc/mrpt_example1/test.cpp

#include "stdafx.h"
#include <mrpt/poses/CPoint3D.h>
#include <mrpt/poses/CPose2D.h>
#include <mrpt/poses/CPose3D.h>
#include <mrpt/utils/CTicTac.h>

using namespace mrpt::utils;
using namespace mrpt::poses;
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
    try
    {
        // The landmark (global) position: 3D (x,y,z)
        CPoint3D L(0, 4, 2);

        // Robot pose: 2D (x,y,phi)
        CPose2D  R(2, 1, DEG2RAD(45.0f));

        // Camera pose relative to the robot: 6D (x,y,z,yaw,pitch,roll).
        CPose3D  C(0.5f, 0.5f, 1.5f, DEG2RAD(-90.0f), DEG2RAD(0), DEG2RAD(-90.0f));

        // TEST 1. Relative position L' of the landmark wrt the camera
        // --------------------------------------------------------------
        cout << "L: " << L << endl;
        cout << "R: " << R << endl;
        cout << "C: " << C << endl;
        cout << "R+C:" << (R + C) << endl;
        //cout << (R+C).getHomogeneousMatrix();

        CPoint3D L2;
        CTicTac tictac;
        tictac.Tic();
        size_t i, N = 10000;
        for (i = 0; i<N; i++)
            L2 = L - (R + C);
        cout << "Computation in: " << 1e6 * tictac.Tac() / ((double)N) << " us" << endl;

        cout << "L': " << L2 << endl;

        // TEST 2. Reconstruct the landmark position:
        // --------------------------------------------------------------
        CPoint3D L3 = R + C + L2;
        cout << "R(+)C(+)L' = " << L3 << endl;
        cout << "Should be equal to L = " << L << endl;

        // TEST 3. Distance from the camera to the landmark
        // --------------------------------------------------------------
        cout << "|(R(+)C)-L|= " << (R + C).distanceTo(L) << endl;
        cout << "|L-(R(+)C)|= " << (R + C).distanceTo(L) << endl;

        return 0;
    }
    catch (exception &e)
    {
        cerr << "EXCEPCTION: " << e.what() << endl;
        return -1;
    }
    catch (...)
    {
        cerr << "Untyped excepcion!!";
        return -1;
    }
}

输出如下结果则表示安装正常

原文地址:https://www.cnblogs.com/flyinggod/p/10294510.html