Main MRPT website > C++ reference for MRPT 1.9.9
test.cpp
Go to the documentation of this file.
1 /**-----------------------------------------------
2  * @Copyright (C) 2017 All rights reserved.
3  * @filename: test.cpp
4  * @author: aliben.develop@gmail.com
5  * @created_date: 2017-12-04 15:59:55
6  * @last_modified_date: NO_LAST_MODIFIED_DATE
7  * @description: TODO
8  *-----------------------------------------------*/
9 
10 /* +------------------------------------------------------------------------+
11  | Mobile Robot Programming Toolkit (MRPT) |
12  | http://www.mrpt.org/ |
13  | |
14  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
15  | See: http://www.mrpt.org/Authors - All rights reserved. |
16  | Released under BSD License. See details in http://www.mrpt.org/License |
17  +------------------------------------------------------------------------+
18  */
19 
20 /*
21  This example was contributed by Adrien Barral - Robopec (France)
22 */
23 
24 #include <mrpt/gui.h>
25 #include <mrpt/opengl/CPlanarLaserScan.h> // [mrpt-maps]
27 #include <iostream>
28 
29 using namespace mrpt;
30 using namespace mrpt::utils;
31 using namespace mrpt::obs;
32 using namespace mrpt::opengl;
33 using namespace mrpt::hwdrivers;
34 using namespace mrpt::gui;
35 using namespace std;
36 
37 int main(int argc, char* argv[])
38 {
39  /** A process for testing Lidar with MRPT
40  * 1. New a Lidar class with <IP> <Port>
41  * 2. Turn on the Lidar just created
42  * 3. Get Lidar data into outObs
43  */
44  if (argc < 3)
45  {
46  cout << "Usage : " << argv[0] << " <IP> <port> " << endl;
47  return 0;
48  }
49 
50  CSICKTim561Eth laser(string(argv[1]), atoi(argv[2]));
51  laser.turnOn();
52 
53  bool isOutObs, hardwareError;
55  laser.doProcessSimple(isOutObs, outObs, hardwareError);
56 
57  CDisplayWindow3D win3D("Scan", 200, 200);
58 
59  COpenGLScene::Ptr ptr_scene = win3D.get3DSceneAndLock();
60 
62  mrpt::make_aligned_shared<opengl::CPlanarLaserScan>();
63  obj->clear();
64  obj->setColor(0, 0, 1);
65  obj->setName("scan_TIM561");
66  obj->setScan(outObs);
67  ptr_scene->insert(obj);
68 
69  win3D.unlockAccess3DScene();
70  win3D.forceRepaint();
71 
72  while (win3D.isOpen())
73  {
74  laser.doProcessSimple(isOutObs, outObs, hardwareError);
75 
76  ptr_scene = win3D.get3DSceneAndLock();
78  std::dynamic_pointer_cast<opengl::CPlanarLaserScan>(
79  ptr_scene->getByName("scan_TIM561"));
80  obj->clear();
81  obj->setScan(outObs);
82  win3D.unlockAccess3DScene();
83  win3D.forceRepaint();
84  std::this_thread::sleep_for(20ms);
85  }
86  win3D.waitForKey();
87  return 0;
88 }
CSICKTim561Eth_2050101.h
mrpt::obs::CObservation2DRangeScan
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
Definition: CObservation2DRangeScan.h:56
obj
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
mrpt::hwdrivers
Contains classes for various device interfaces.
Definition: C2DRangeFinderAbstract.h:22
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::obs
This namespace contains representation of robot actions and observations.
Definition: CParticleFilter.h:17
main
int main()
Definition: vision_stereo_rectify/test.cpp:78
mrpt::hwdrivers::CSICKTim561Eth
Definition: CSICKTim561Eth_2050101.h:20
mrpt::opengl::CPlanarLaserScan::Ptr
std::shared_ptr< CPlanarLaserScan > Ptr
Definition: CPlanarLaserScan.h:59
mrpt::gui
Classes for creating GUI windows for 2D and 3D visualization.
Definition: about_box.h:16
mrpt::utils
Definition: utils/CConfigFile.h:5
gui.h
mrpt::opengl::COpenGLScene::Ptr
std::shared_ptr< COpenGLScene > Ptr
Definition: COpenGLScene.h:61
CPlanarLaserScan.h
mrpt::opengl
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
mrpt::gui::CDisplayWindow3D
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.
Definition: CDisplayWindow3D.h:117



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST