YARP
Yet Another Robot Platform
fakeNavigationDev.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <yarp/os/Network.h>
20 #include <yarp/os/RFModule.h>
21 #include <yarp/os/Time.h>
22 #include <yarp/os/Port.h>
23 #include <yarp/os/LogComponent.h>
24 #include <yarp/os/LogStream.h>
26 #include "fakeNavigationDev.h"
27 #include <math.h>
28 #include <cmath>
29 
30 using namespace yarp::dev;
31 using namespace yarp::dev::Nav2D;
32 
33 namespace {
34 YARP_LOG_COMPONENT(FAKENAVIGATION, "yarp.device.fakeNavigation")
35 }
36 
37 
39 {
40 #if 1
41 
42  yCDebug(FAKENAVIGATION) << "config configuration: \n" << config.toString().c_str();
43 
44  std::string context_name = "robotGoto";
45  std::string file_name = "robotGoto_cer.ini";
46 
47  if (config.check("context")) context_name = config.find("context").asString();
48  if (config.check("from")) file_name = config.find("from").asString();
49 
51  rf.setDefaultContext(context_name.c_str());
52  rf.setDefaultConfigFile(file_name.c_str());
53 
55  std::string configFile = rf.findFile("from");
56  if (configFile != "") p.fromConfigFile(configFile.c_str());
57  yCDebug(FAKENAVIGATION) << "robotGotoDev configuration: \n" << p.toString().c_str();
58 
59 #else
60  Property p;
61  p.fromString(config.toString());
62 #endif
63  navThread = new fakeNavigationThread(0.010, p);
64 
65  if (!navThread->start())
66  {
67  delete navThread;
68  return false;
69  }
70 
71  return true;
72 }
73 
75 {
76  navThread =NULL;
77 }
78 
79 //module cleanup
81 {
82  navThread->stop();
83  delete navThread;
84  navThread =NULL;
85 
86  return true;
87 }
88 
90 {
91  yCInfo(FAKENAVIGATION) << "gotoTargetByAbsoluteLocation not yet implemented";
92  return true;
93 }
94 
95 bool fakeNavigation::gotoTargetByRelativeLocation(double x, double y, double theta)
96 {
97  yCInfo(FAKENAVIGATION) << "gotoTargetByRelativeLocation not yet implemented";
98  return true;
99 }
100 
102 {
103  yCInfo(FAKENAVIGATION) << "gotoTargetByRelativeLocation not yet implemented";
104  return true;
105 }
106 
107 bool fakeNavigation::applyVelocityCommand(double x_vel, double y_vel, double theta_vel, double timeout)
108 {
109  yCInfo(FAKENAVIGATION) << "applyVelocityCommand not yet implemented";
110  return true;
111 }
112 
114 {
115  yCInfo(FAKENAVIGATION) << "stopNavigation not yet implemented";
116  return true;
117 }
118 
120 {
121  yCInfo(FAKENAVIGATION) << "suspendNavigation not yet implemented";
122  return true;
123 }
124 
126 {
127  yCInfo(FAKENAVIGATION) << "resumeNavigation not yet implemented";
128  return true;
129 }
130 
132 {
133  yCInfo(FAKENAVIGATION) << "getAllNavigationWaypoints not yet implemented";
134  return true;
135 }
136 
138 {
139  yCInfo(FAKENAVIGATION) << "getCurrentNavigationWaypoint not yet implemented";
140  return true;
141 }
142 
144 {
145  yCInfo(FAKENAVIGATION) << "getCurrentNavigationMap not yet implemented";
146  return true;
147 }
148 
150 {
151  yCInfo(FAKENAVIGATION) << "getNavigationStatus not yet implemented";
152  return true;
153 }
154 
156 {
157  yCInfo(FAKENAVIGATION) << "getAbsoluteLocationOfCurrentTarget not yet implemented";
158  return true;
159 }
160 
162 {
163  yCInfo(FAKENAVIGATION) << "recomputeCurrentNavigationPath not yet implemented";
164  return true;
165 }
166 
167 bool fakeNavigation::getRelativeLocationOfCurrentTarget(double& x, double& y, double& theta)
168 {
169  yCInfo(FAKENAVIGATION) << "getRelativeLocationOfCurrentTarget not yet implemented";
170  return true;
171 }
172 
173 fakeNavigationThread::fakeNavigationThread(double _period, yarp::os::Searchable& _cfg) : PeriodicThread(_period)
174 {
175 }
176 
178 {
179  return true;
180 }
181 
183 {
184 
185 }
186 
188 {
189 
190 }
LogStream.h
fakeNavigation::resumeNavigation
bool resumeNavigation() override
//Resumes a previously paused navigation task.
Definition: fakeNavigationDev.cpp:125
Network.h
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
fakeNavigationThread::threadRelease
virtual void threadRelease() override
Release method.
Definition: fakeNavigationDev.cpp:182
fakeNavigation::fakeNavigation
fakeNavigation()
Definition: fakeNavigationDev.cpp:74
Port.h
fakeNavigation::stopNavigation
bool stopNavigation() override
//Stops the current navigation task.
Definition: fakeNavigationDev.cpp:113
yarp::os::Searchable::toString
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
yarp::os::Property::fromString
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
Definition: Property.cpp:1046
fakeNavigation::getAbsoluteLocationOfCurrentTarget
bool getAbsoluteLocationOfCurrentTarget(yarp::dev::Nav2D::Map2DLocation &target) override
//Gets the last target set through a setNewAbsTarget() command.
Definition: fakeNavigationDev.cpp:155
YARP_LOG_COMPONENT
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:80
yarp::dev::Nav2D::TrajectoryTypeEnum
TrajectoryTypeEnum
Definition: INavigation2D.h:52
fakeNavigation::open
virtual bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: fakeNavigationDev.cpp:38
yarp::dev::Nav2D::NavigationStatusEnum
NavigationStatusEnum
Definition: INavigation2D.h:32
ControlBoardInterfaces.h
define control board standard interfaces
yarp::dev
An interface for the device drivers.
Definition: audioBufferSizeData.cpp:17
fakeNavigationThread::run
virtual void run() override
Loop function.
Definition: fakeNavigationDev.cpp:187
yarp::os::ResourceFinder::findFile
std::string findFile(const std::string &name)
Find the full path to a file.
Definition: ResourceFinder.cpp:847
fakeNavigationThread
Definition: fakeNavigationDev.h:31
yarp::os::ResourceFinder::setDefaultContext
bool setDefaultContext(const std::string &contextName)
Sets the context for the current ResourceFinder object.
Definition: ResourceFinder.h:91
fakeNavigationThread::threadInit
virtual bool threadInit() override
Initialization method.
Definition: fakeNavigationDev.cpp:177
fakeNavigation::recomputeCurrentNavigationPath
bool recomputeCurrentNavigationPath() override
Forces the navigation system to recompute the path from the current robot position to the current goa...
Definition: fakeNavigationDev.cpp:161
yarp::os::Property::toString
std::string toString() const override
Return a standard text representation of the content of the object.
Definition: Property.cpp:1052
yarp::dev::Nav2D::MapGrid2D
Definition: MapGrid2D.h:32
fakeNavigation::gotoTargetByAbsoluteLocation
bool gotoTargetByAbsoluteLocation(yarp::dev::Nav2D::Map2DLocation loc) override
Sets a new navigation target, expressed in the absolute (map) coordinate frame.
Definition: fakeNavigationDev.cpp:89
fakeNavigation::getCurrentNavigationMap
bool getCurrentNavigationMap(yarp::dev::Nav2D::NavigationMapTypeEnum map_type, yarp::dev::Nav2D::MapGrid2D &map) override
Returns the current navigation map processed by the navigation algorithm.
Definition: fakeNavigationDev.cpp:143
yarp::os::Value::asString
virtual std::string asString() const
Get string value.
Definition: Value.cpp:237
yarp::os::Searchable::check
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
yarp::os::Searchable::find
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
RFModule.h
yarp::dev::Nav2D::Map2DPath
Definition: Map2DPath.h:27
yarp::dev::Nav2D
Definition: ILocalization2D.h:21
LogComponent.h
fakeNavigation::suspendNavigation
bool suspendNavigation(double time) override
//Pauses the current navigation task.
Definition: fakeNavigationDev.cpp:119
fakeNavigation::getNavigationStatus
bool getNavigationStatus(yarp::dev::Nav2D::NavigationStatusEnum &status) override
//Gets the status of the current navigation task.
Definition: fakeNavigationDev.cpp:149
fakeNavigation::close
virtual bool close() override
Close the DeviceDriver.
Definition: fakeNavigationDev.cpp:80
fakeNavigationThread::fakeNavigationThread
fakeNavigationThread(double _period, yarp::os::Searchable &_cfg)
Definition: fakeNavigationDev.cpp:173
fakeNavigation::gotoTargetByRelativeLocation
bool gotoTargetByRelativeLocation(double x, double y, double theta) override
//Sets a new relative target, expressed in local (robot) coordinate frame.
Definition: fakeNavigationDev.cpp:95
yarp::dev::Nav2D::Map2DLocation
Definition: Map2DLocation.h:30
fakeNavigation::getAllNavigationWaypoints
bool getAllNavigationWaypoints(yarp::dev::Nav2D::TrajectoryTypeEnum trajectory_type, yarp::dev::Nav2D::Map2DPath &waypoints) override
Returns the list of waypoints generated by the navigation algorithm.
Definition: fakeNavigationDev.cpp:131
fakeNavigation::getCurrentNavigationWaypoint
bool getCurrentNavigationWaypoint(yarp::dev::Nav2D::Map2DLocation &curr_waypoint) override
Returns the current waypoint pursued by the navigation algorithm.
Definition: fakeNavigationDev.cpp:137
yarp::os::Property::fromConfigFile
bool fromConfigFile(const std::string &fname, bool wipe=true)
Interprets a file as a list of properties.
Definition: Property.cpp:1081
yCInfo
#define yCInfo(component,...)
Definition: LogComponent.h:135
yarp::dev::Nav2D::NavigationMapTypeEnum
NavigationMapTypeEnum
Definition: INavigation2D.h:46
yCDebug
#define yCDebug(component,...)
Definition: LogComponent.h:112
Time.h
yarp::os::ResourceFinder::setDefaultConfigFile
bool setDefaultConfigFile(const std::string &fname)
Provide a default value for the configuration file (can be overridden from command line with the –fro...
Definition: ResourceFinder.h:134
fakeNavigationDev.h
fakeNavigation::getRelativeLocationOfCurrentTarget
bool getRelativeLocationOfCurrentTarget(double &x, double &y, double &theta) override
//Gets the last target set through a setNewRelTarget command, expressed in absolute coordinates.
Definition: fakeNavigationDev.cpp:167
fakeNavigation::applyVelocityCommand
virtual bool applyVelocityCommand(double x_vel, double y_vel, double theta_vel, double timeout=0.1) override
Apply a velocity command.
Definition: fakeNavigationDev.cpp:107
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37
yarp::os::ResourceFinder
Helper class for finding config files and other external resources.
Definition: ResourceFinder.h:33