MRPT  2.0.2
CObservationRotatingScan_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <gtest/gtest.h>
16 #include <mrpt/obs/CRawlog.h>
17 #include <mrpt/system/filesystem.h>
18 #include <test_mrpt_common.h>
19 
20 TEST(CObservationRotatingScan, fromKittiUndistorted)
21 {
22  using namespace std::string_literals;
23  const auto fil = mrpt::UNITTEST_BASEDIR + "/tests/kitti_00_000000.bin.gz"s;
24 
26  bool read_ok = pts->loadFromKittiVelodyneFile(fil);
27  EXPECT_TRUE(read_ok);
28 
29  // read_ok = pts->loadXYZI_from_text_file("0000000060.txt");
30  EXPECT_TRUE(read_ok);
31 
32  pts->saveToKittiVelodyneFile("/tmp/a.bin.gz");
33  pts->saveXYZI_to_text_file("/tmp/a.txt");
34 
36  // obsPcl.
37 
39  // rs.fromPointCloud()
40 }
41 
42 TEST(CObservationRotatingScan, fromVelodyne)
43 {
44  using namespace std::string_literals;
45  const auto fil = mrpt::system::getShareMRPTDir() +
46  "/datasets/test_velodyne_VLP16.rawlog"s;
47 
48  mrpt::obs::CRawlog rawlog;
49  bool load_ok = rawlog.loadFromRawLogFile(fil);
50  EXPECT_TRUE(load_ok) << "Could not load " << fil;
51 
52  auto oVelo = rawlog.asObservation<mrpt::obs::CObservationVelodyneScan>(0);
53  EXPECT_TRUE(oVelo.get() != nullptr);
54 
56  rs.fromVelodyne(*oVelo);
57 
58  EXPECT_TRUE(rs.azimuthSpan > 0) << "Rotation: CCW";
59  EXPECT_NEAR(std::abs(rs.azimuthSpan), 2 * M_PI, 0.1);
60  EXPECT_EQ(rs.columnCount, 28800);
61  EXPECT_EQ(rs.rowCount, 16);
62 
63  // std::cout << rs.getDescriptionAsTextValue();
64 }
65 
66 TEST(CObservationRotatingScan, from2DScan)
67 {
68  using namespace std::string_literals;
69  const auto fil =
70  mrpt::system::getShareMRPTDir() + "/datasets/localization_demo.rawlog"s;
71 
72  mrpt::obs::CRawlog rawlog;
73  bool load_ok = rawlog.loadFromRawLogFile(fil);
74  EXPECT_TRUE(load_ok) << "Could not load " << fil;
75 
76  auto oScan2D =
77  rawlog.getAsObservations(1)
78  ->getObservationByClass<mrpt::obs::CObservation2DRangeScan>();
79  EXPECT_TRUE(oScan2D.get() != nullptr);
80 
82  rs.fromScan2D(*oScan2D);
83 
84  EXPECT_TRUE(rs.azimuthSpan > 0) << "Rotation: CCW";
85  EXPECT_NEAR(std::abs(rs.azimuthSpan), M_PI, 1e-4);
86  EXPECT_EQ(rs.columnCount, 361);
87  EXPECT_EQ(rs.rowCount, 1);
88 
89  // std::cout << rs.getDescriptionAsTextValue();
90 }
A CObservation-derived class for RAW DATA (and optionally, point cloud) of scans from 3D Velodyne LID...
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
std::string getShareMRPTDir()
Attempts to find the directory [PREFIX/]share/mrpt/ and returns its absolute path, or empty string if not found.
Definition: filesystem.cpp:641
T::ConstPtr asObservation(size_t index) const
Get the i&#39;th observation as an observation of the given type.
Definition: CRawlog.h:208
An observation from any sensor that can be summarized as a pointcloud.
void fromVelodyne(const mrpt::obs::CObservationVelodyneScan &o)
bool loadFromRawLogFile(const std::string &fileName, bool non_obs_objects_are_legal=false)
Load the contents from a file containing one of these possibilities:
Definition: CRawlog.cpp:166
TEST(CObservationRotatingScan, fromKittiUndistorted)
This class stores a rawlog (robotic datasets) in one of two possible formats:
Definition: CRawlog.h:65
static Ptr Create(Args &&... args)
CSensoryFrame::Ptr getAsObservations(size_t index) const
Returns the i&#39;th element in the sequence, as being an action, where index=0 is the first object...
Definition: CRawlog.cpp:125
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
void fromScan2D(const mrpt::obs::CObservation2DRangeScan &o)
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
A CObservation-derived class for raw range data from a 2D or 3D rotating scanner. ...



Page generated by Doxygen 1.8.14 for MRPT 2.0.2 Git: 9b4fd2465 Mon May 4 16:59:08 2020 +0200 at lun may 4 17:26:07 CEST 2020