YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
map2DStorage_test.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
7#include <yarp/dev/IMap2D.h>
10#include <yarp/os/Network.h>
11#include <yarp/os/LogStream.h>
12#include <yarp/dev/PolyDriver.h>
16
17#include <catch2/catch_amalgamated.hpp>
18#include <harness.h>
19
20using namespace yarp::dev;
21using namespace yarp::dev::Nav2D;
22using namespace yarp::sig;
23using namespace yarp::os;
24
25TEST_CASE("dev::Map2DStorageTest", "[yarp::dev]")
26{
27 YARP_REQUIRE_PLUGIN("map2DStorage", "device");
28
29 Network::setLocalMode(true);
30
31 SECTION("Checking map2DStorage device without loading files")
32 {
34 IMap2D* imap = nullptr;
35
37 {
39 pmapstorage_cfg.put("device", "map2DStorage");
43 }
44
45 //execute tests
50
51 //"Close all polydrivers and check"
52 {
54 }
55 }
56
57 SECTION("Checking map2DStorage device loading files (1/3)")
58 {
60 IMap2D* imap = nullptr;
61
63 // This will fail because map2DStorage cannot find a
64 //`maps_collection.ini` file in `erraticContext`.
65 {
67 pmapstorage_cfg.put("device", "map2DStorage");
68 pmapstorage_cfg.put("mapCollectionContext", "erraticContext");
70 }
71 }
72
73 SECTION("Checking map2DStorage device loading files (2/3)")
74 {
76 IMap2D* imap = nullptr;
77
78 //open the poly loading a previously saved collection
79 {
81 pmapstorage_cfg.put("device", "map2DStorage");
82 pmapstorage_cfg.put("mapCollectionContext", "mapGrid2DTest");
85
86 bool b;
87 std::vector<Nav2D::Map2DArea> veca;
88 std::vector<Nav2D::Map2DLocation> vecl;
89 std::vector<Nav2D::Map2DObject> veco;
90 std::vector<Nav2D::Map2DPath> vecp;
91 b = imap->getAllAreas(veca); CHECK(b); CHECK(veca.size()==3);
92 b = imap->getAllLocations(vecl); CHECK(b); CHECK(vecl.size()==3);
93 b = imap->getAllObjects(veco); CHECK(b); CHECK(veco.size()==3);
94 b = imap->getAllPaths(vecp); CHECK(b); CHECK(vecp.size()==3);
95 //Cleanup of vectors which contain elements allocated inside a plugin.
96 //beware! Forgetting this might cause segfault
97 veca.clear();
98 vecl.clear();
99 veco.clear();
100 vecp.clear();
101
102 //"Close all polydrivers and check"
104 }
105 }
106
107 SECTION("Checking map2DStorage device loading files (3/3)")
108 {
110 IMap2D* imap = nullptr;
111
112 //open a poly, creates a collection from scratch, close the poly
113 {
115 pmapstorage_cfg.put("device", "map2DStorage");
120 }
121
122 //open the poly loading a previously saved collection
123 {
125 pmapstorage_cfg.put("device", "map2DStorage");
126 pmapstorage_cfg.put("mapCollectionContext", "exampleContext");
129
130 //execute tests
133
134 //"Close all polydrivers and check"
136 }
137
138 //remove the collection
140 }
141
142 Network::setLocalMode(false);
143}
contains the definition of a Map2DArea type
contains the definition of a Map2DLocation type
IMap2D Interface.
Definition IMap2D.h:31
A container for a device driver.
Definition PolyDriver.h:23
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A class for storing options and configuration information.
Definition Property.h:33
TEST_CASE("dev::Map2DStorageTest", "[yarp::dev]")
void exec_iMap2D_test_3(IMap2D *imap)
Definition IMap2DTest.h:331
void exec_iMap2D_test_1(IMap2D *imap)
Definition IMap2DTest.h:35
void exec_params_test(yarp::dev::PolyDriver *pdrv)
void remove_test_collection()
Definition IMap2DTest.h:587
void exec_iMap2D_test_4(IMap2D *imap)
Definition IMap2DTest.h:462
void exec_iMap2D_test_2(IMap2D *imap)
Definition IMap2DTest.h:108
void create_test_collection(IMap2D *imap)
Definition IMap2DTest.h:576
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.
Definition OSTestMsg.cpp:13