MRPT  1.9.9
test.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
12 #include <mrpt/system/CTicTac.h>
14 #include <iostream>
15 #include <thread>
16 
17 using namespace mrpt::hwdrivers;
18 using namespace mrpt::system;
19 using namespace mrpt::obs;
20 using namespace mrpt::config;
21 using namespace std;
22 
23 /** Usage : ./test <conf file name>.ini
24  */
25 int main(int argc, char** argv)
26 {
27  try
28  {
29  string confFileName;
30  if (argc < 2)
31  confFileName = string("./conf.ini");
32  else
33  confFileName = string(argv[1]);
34 
36  string section("IK_1");
37  CConfigFile conf(confFileName);
38  ik.loadConfig(conf, section);
39  ik.initialize();
41  do
42  {
43  ik.doProcess();
44  ik.getObservation(obs);
45  for (size_t i = 0; i < obs.sensedData.size(); i++)
46  {
47  cout << obs.sensedData[i].sensedDistance << "\t";
48  }
49  cout << endl;
50  std::this_thread::sleep_for(10ms);
51  } while (!mrpt::system::os::kbhit());
52 
53  return 0;
54  }
55  catch (std::exception& e)
56  {
57  std::cerr << e.what();
58  return 1;
59  }
60 }
Declares a class derived from "CObservation" that encapsules a single range measurement, and associated parameters.
This class allows loading and storing values and vectors of different types from ".ini" files easily.
void getObservation(mrpt::obs::CObservationRange &outObservation)
This method tries to get a set of range measurements from the IR sensors.
Contains classes for various device interfaces.
STL namespace.
This namespace contains representation of robot actions and observations.
void loadConfig(const mrpt::config::CConfigFileBase &configSource, const std::string &section)
Loads the generic settings common to any sensor (See CGenericSensor), then call to "loadConfig_sensor...
GLsizei const GLchar ** string
Definition: glext.h:4101
: An interface for the phidget Interface kit board (1018).
bool kbhit() noexcept
An OS-independent version of kbhit, which returns true if a key has been pushed.
Definition: os.cpp:390
void initialize()
Initialize the sensor according to the parameters previously read in the configuration file...
TMeasurementList sensedData
All the measurements.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020