YARP
Yet Another Robot Platform
Navigation2D_nwc_yarp_iNav2DCtrl.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
8#include <yarp/os/Log.h>
10#include <yarp/os/LogStream.h>
11#include <mutex>
12#include <cmath>
13
16using namespace yarp::dev;
17using namespace yarp::dev::Nav2D;
18using namespace yarp::os;
19using namespace yarp::sig;
20
21namespace {
22YARP_LOG_COMPONENT(NAVIGATION2D_NWC_YARP, "yarp.device.navigation2D_nwc_yarp")
23}
24
25//------------------------------------------------------------------------------------------------------------------------------
26
28{
29 std::lock_guard <std::mutex> lg(m_mutex);
31 if (!ret.ret)
32 {
33 yCError(NAVIGATION2D_NWC_YARP, "Unable to get_navigation_status_RPC");
34 return false;
35 }
37 return true;
38}
39
41{
42 std::lock_guard <std::mutex> lg(m_mutex);
44}
45
47{
48 std::lock_guard <std::mutex> lg(m_mutex);
49 return m_nav_RPC.suspend_navigation_RPC(time_s);
50}
51
53{
54 std::lock_guard <std::mutex> lg(m_mutex);
56}
57
59{
60 std::lock_guard <std::mutex> lg(m_mutex);
62}
63
65{
66 std::lock_guard <std::mutex> lg(m_mutex);
67 auto ret = m_nav_RPC.get_all_navigation_waypoints_RPC(trajectory_type);
68 if (!ret.ret)
69 {
70 yCError(NAVIGATION2D_NWC_YARP, "Unable to get_current_nav_waypoint_RPC");
71 return false;
72 }
73 waypoints = ret.waypoints;
74 return true;
75}
76
78{
79 std::lock_guard <std::mutex> lg(m_mutex);
81 if (!ret.ret)
82 {
83 yCError(NAVIGATION2D_NWC_YARP, "Unable to get_current_nav_waypoint_RPC");
84 return false;
85 }
86 curr_waypoint = ret.waypoint;
87 return true;
88}
89
91{
92 std::lock_guard <std::mutex> lg(m_mutex);
94 if (!ret.ret)
95 {
96 yCError(NAVIGATION2D_NWC_YARP, "Unable to get_current_nav_waypoint_RPC");
97 return false;
98 }
99 map = ret.mapgrid;
100 return true;
101}
bool ret
virtual bool suspend_navigation_RPC(const double time_s)
virtual bool recompute_current_navigation_path_RPC()
virtual return_get_current_nav_map get_current_navigation_map_RPC(const yarp::dev::Nav2D::NavigationMapTypeEnum map_type)
virtual return_get_navigation_status get_navigation_status_RPC()
virtual return_get_current_nav_waypoint get_current_nav_waypoint_RPC()
virtual bool stop_navigation_RPC()
virtual return_get_all_nav_waypoints get_all_navigation_waypoints_RPC(const yarp::dev::Nav2D::TrajectoryTypeEnum trajectory_type)
virtual bool resume_navigation_RPC()
INavigation2DMsgs m_nav_RPC
bool recomputeCurrentNavigationPath() override
Forces the navigation system to recompute the path from the current robot position to the current goa...
bool stopNavigation() override
Terminates the current navigation task.
bool getNavigationStatus(yarp::dev::Nav2D::NavigationStatusEnum &status) override
Gets the current status of the navigation task.
bool getCurrentNavigationWaypoint(yarp::dev::Nav2D::Map2DLocation &curr_waypoint) override
Returns the current waypoint pursued by the navigation algorithm.
bool resumeNavigation() override
Resume a previously suspended navigation task.
bool suspendNavigation(const double time_s) override
Ask to the robot to suspend the current navigation task for a defined amount of time.
bool getCurrentNavigationMap(yarp::dev::Nav2D::NavigationMapTypeEnum map_type, yarp::dev::Nav2D::MapGrid2D &map) override
Returns the current navigation map processed by the navigation algorithm.
bool getAllNavigationWaypoints(yarp::dev::Nav2D::TrajectoryTypeEnum trajectory_type, yarp::dev::Nav2D::Map2DPath &waypoints) override
Returns the list of waypoints generated by the navigation algorithm.
#define yCError(component,...)
Definition: LogComponent.h:213
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:76
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.