来自 金沙澳门官网网址 2019-12-25 08:29 的文章
当前位置: 金沙澳门官网网址 > 金沙澳门官网网址 > 正文

Pangolin学习

0.1. 资料

泡沫机器人

github example

opengl中录制机的职位,观察的自由化

gluLookAt函数

图片 1

0.2. 应用表达

行使这些gluLookAt矩阵坐标观望矩阵可以很便捷地把拥有世界坐标调换为观看比赛坐标LookAt矩阵

find_package(Pangolin REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})

target_link_libraries(pangolin_test ${Pangolin_LIBRARIES})

Github 下有个example有风度翩翩对事例,轻巧的参阅着写,复杂的估算须要查opengl.

0.3. HelloPangolin

#include <iostream>
#include <pangolin/pangolin.h>

int main(int argc, char **argv)
{
    //创建一个窗口
    pangolin::CreateWindowAndBind("Main",640,480);
    //启动深度测试
    glEnable(GL_DEPTH_TEST);

    // Define Projection and initial ModelView matrix
    pangolin::OpenGlRenderState s_cam(
            pangolin::ProjectionMatrix(640,480,420,420,320,240,0.2,100),
            //对应的是gluLookAt,摄像机位置,参考点位置,up vector(上向量)
            pangolin::ModelViewLookAt(0,-10,0.1,0,0,0,pangolin::AxisNegY)
    );

    // Create Interactive View in window
    pangolin::Handler3D handler(s_cam);
    //setBounds 跟opengl的viewport 有关
    //看SimpleDisplay中边界的设置就知道
    pangolin::View &d_cam = pangolin::CreateDisplay().SetBounds(0.0,1.0,0.0,1.0,-640.0f/480.0f)
                            .SetHandler(&handler);

    while(!pangolin::ShouldQuit())
    {
        // Clear screen and activate view to render into
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        d_cam.Activate(s_cam);

        // Render OpenGL Cube
//        pangolin::glDrawColouredCube();
        //坐标轴的创建
        pangolin::glDrawAxis(3);

        //点的创建
        glPointSize(10.0f);
        glBegin(GL_POINTS);
        glColor3f(1.0,1.0,1.0);
        glVertex3f(0.0f,0.0f,0.0f);
        glVertex3f(1,0,0);
        glVertex3f(0,2,0);
        glEnd();

        //把下面的点都做一次旋转变换
        glPushMatrix();
        //col major
        std::vector<GLfloat > Twc = {1,0,0,0, 0,1,0,0 , 0,0,1,0 ,0,0,5,1};
        glMultMatrixf(Twc.data());

        //直线的创建
        const float w = 2;
        const float h = w*0.75;
        const float z = w*0.6;
        glLineWidth(2);
        glColor3f(1.0,0,0);
        glBegin(GL_LINES);

        glVertex3f(0,0,0);
        glVertex3f(w,h,z);
        glVertex3f(0,0,0);
        glVertex3f(w,-h,z);
        glVertex3f(0,0,0);
        glVertex3f(-w,-h,z);
        glVertex3f(0,0,0);
        glVertex3f(-w,h,z);
        glVertex3f(w,h,z);
        glVertex3f(-w,h,z);
        glVertex3f(-w,h,z);
        glVertex3f(-w,-h,z);
        glVertex3f(-w,-h,z);
        glVertex3f(w,-h,z);
        glVertex3f(w,-h,z);
        glVertex3f(w,h,z);
        glEnd();

        glPopMatrix();

        // Swap frames and Process Events
        pangolin::FinishFrame();
    }

    return 0;

}

0.4. Plot data with ros

参照SimplePlot, !pangolin::ShouldQuit()换成ros::ok(),就可以

参照SimpleDisplay, 能够做出选取配置

本文由金沙澳门官网网址发布于金沙澳门官网网址,转载请注明出处:Pangolin学习

关键词: