21#define CHECK_POINTER(xxx) {if (xxx==nullptr) {yCError(NAVIGATION2DSERVER, "Invalid interface"); return false;}}
25 m_iNav_target = iNav_target;
26 m_iNav_ctrl = iNav_ctrl;
27 m_iNav_vel = iNav_vel;
33 std::lock_guard <std::mutex> lg(m_mutex);
34 {
if (m_iNav_ctrl ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return false; }}
38 yCError(NAVIGATION2DSERVER,
"Unable to stopNavigation");
41 m_current_goal_name.
clear();
47 std::lock_guard <std::mutex> lg(m_mutex);
48 {
if (m_iNav_ctrl ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return false; }}
52 yCError(NAVIGATION2DSERVER,
"Unable to resumeNavigation");
60 std::lock_guard <std::mutex> lg(m_mutex);
61 {
if (m_iNav_ctrl ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return false; }}
65 yCError(NAVIGATION2DSERVER,
"Unable to suspendNavigation");
73 std::lock_guard <std::mutex> lg(m_mutex);
74 {
if (m_iNav_ctrl ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return false; }}
78 yCError(NAVIGATION2DSERVER,
"Unable to recomputeCurrentNavigationPath");
86 std::lock_guard <std::mutex> lg(m_mutex);
90 {
if (m_iNav_ctrl ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return ret; }}
95 yCError(NAVIGATION2DSERVER,
"Unable to getNavigationStatus");
108 std::lock_guard <std::mutex> lg(m_mutex);
112 {
if (m_iNav_ctrl ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return ret; }}
117 yCError(NAVIGATION2DSERVER,
"Unable to getCurrentNavigationWaypoint");
130 std::lock_guard <std::mutex> lg(m_mutex);
134 {
if (m_iNav_ctrl ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return ret; }}
139 yCError(NAVIGATION2DSERVER,
"Unable to getAllNavigationWaypoints");
145 ret.waypoints = path;
152 std::lock_guard <std::mutex> lg(m_mutex);
156 {
if (m_iNav_ctrl ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return ret; }}
161 yCError(NAVIGATION2DSERVER,
"Unable to getRelativeLocationOfCurrentTarget");
167 ret.mapgrid = themap;
177 std::lock_guard <std::mutex> lg(m_mutex);
178 {
if (m_iNav_target ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return false; }}
182 yCError(NAVIGATION2DSERVER,
"Unable to gotoTargetByAbsoluteLocation");
185 m_current_goal_name.
clear();
191 std::lock_guard <std::mutex> lg(m_mutex);
192 {
if (m_iNav_target ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return false; }}
196 yCError(NAVIGATION2DSERVER,
"Unable to gotoTargetByRelativeLocation");
199 m_current_goal_name.
clear();
205 std::lock_guard <std::mutex> lg(m_mutex);
206 {
if (m_iNav_target ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return false; }}
210 yCError(NAVIGATION2DSERVER,
"Unable to gotoTargetByRelativeLocation");
213 m_current_goal_name.
clear();
219 std::lock_guard <std::mutex> lg(m_mutex);
220 {
if (m_iNav_target ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return false; }}
224 yCError(NAVIGATION2DSERVER,
"Unable to gotoTargetByAbsoluteLocation");
234 std::lock_guard <std::mutex> lg(m_mutex);
238 {
if (m_iNav_target ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return ret; }}
243 yCError(NAVIGATION2DSERVER,
"Unable to getAbsoluteLocationOfCurrentTarget");
256 std::lock_guard <std::mutex> lg(m_mutex);
260 {
if (m_iNav_target ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return ret; }}
265 yCError(NAVIGATION2DSERVER,
"Unable to getRelativeLocationOfCurrentTarget");
281 std::lock_guard <std::mutex> lg(m_mutex);
282 {
if (m_iNav_vel ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return false; }}
286 yCError(NAVIGATION2DSERVER,
"Unable to applyVelocityCommand");
294 std::lock_guard <std::mutex> lg(m_mutex);
298 {
if (m_iNav_vel ==
nullptr) {
yCError(NAVIGATION2DSERVER,
"Invalid interface");
return ret; }}
303 yCError(NAVIGATION2DSERVER,
"Unable to getLastVelocityCommand");
319 std::lock_guard <std::mutex> lg(m_mutex);
329 yCError(NAVIGATION2DSERVER,
"Unable to getNameOfCurrentTarget");
340 m_current_goal_name = name;
346 if (m_current_goal_name ==
"")
350 name = m_current_goal_name;
356 m_current_goal_name =
"";
return_get_current_nav_waypoint get_current_nav_waypoint_RPC() override
return_get_all_nav_waypoints get_all_navigation_waypoints_RPC(yarp::dev::Nav2D::TrajectoryTypeEnum trajectory_type) override
bool goto_target_by_relative_location2_RPC(double x, double y, double theta) override
return_get_abs_loc_of_curr_target get_absolute_location_of_current_target_RPC() override
bool suspend_navigation_RPC(double time_s) override
return_get_name_of_current_target get_name_of_current_target_RPC() override
void setInterfaces(yarp::dev::Nav2D::INavigation2DTargetActions *iNav_target, yarp::dev::Nav2D::INavigation2DControlActions *iNav_ctrl, yarp::dev::Nav2D::INavigation2DVelocityActions *iNav_vel)
return_get_current_nav_map get_current_navigation_map_RPC(yarp::dev::Nav2D::NavigationMapTypeEnum map_type) override
return_get_rel_loc_of_curr_target get_relative_location_of_current_target_RPC() override
bool apply_velocity_command_RPC(double x_vel, double y_vel, double theta_vel, double timeout) override
return_get_last_velocity_command get_last_velocity_command_RPC() override
bool goto_target_by_absolute_location_RPC(const yarp::dev::Nav2D::Map2DLocation &loc) override
bool goto_target_by_absolute_location_and_set_name_RPC(const yarp::dev::Nav2D::Map2DLocation &loc, const std::string &name) override
return_get_navigation_status get_navigation_status_RPC() override
bool recompute_current_navigation_path_RPC() override
bool resume_navigation_RPC() override
bool goto_target_by_relative_location1_RPC(double x, double y) override
bool stop_navigation_RPC() override
bool set_current_goal_name(const std::string &name)
bool get_current_goal_name(std::string &name)
virtual bool recomputeCurrentNavigationPath()=0
Forces the navigation system to recompute the path from the current robot position to the current goa...
virtual bool getAllNavigationWaypoints(yarp::dev::Nav2D::TrajectoryTypeEnum trajectory_type, yarp::dev::Nav2D::Map2DPath &waypoints)=0
Returns the list of waypoints generated by the navigation algorithm.
virtual bool getCurrentNavigationWaypoint(yarp::dev::Nav2D::Map2DLocation &curr_waypoint)=0
Returns the current waypoint pursued by the navigation algorithm.
virtual bool resumeNavigation()=0
Resume a previously suspended navigation task.
virtual bool getNavigationStatus(NavigationStatusEnum &status)=0
Gets the current status of the navigation task.
virtual bool stopNavigation()=0
Terminates the current navigation task.
virtual bool suspendNavigation(const double time_s=std::numeric_limits< double >::infinity())=0
Ask to the robot to suspend the current navigation task for a defined amount of time.
virtual bool getCurrentNavigationMap(yarp::dev::Nav2D::NavigationMapTypeEnum map_type, yarp::dev::Nav2D::MapGrid2D &map)=0
Returns the current navigation map processed by the navigation algorithm.
virtual bool gotoTargetByRelativeLocation(double x, double y)=0
Ask the robot to reach a position defined in the robot reference frame.
virtual bool gotoTargetByAbsoluteLocation(yarp::dev::Nav2D::Map2DLocation loc)=0
Ask the robot to reach a position defined in the world reference frame.
virtual bool getAbsoluteLocationOfCurrentTarget(yarp::dev::Nav2D::Map2DLocation &loc)=0
Gets the last navigation target in the world reference frame.
virtual bool getRelativeLocationOfCurrentTarget(double &x, double &y, double &theta)=0
Gets the last navigation target in the robot reference frame.
virtual bool applyVelocityCommand(double x_vel, double y_vel, double theta_vel, double timeout=0.1)=0
Apply a velocity command.
virtual bool getLastVelocityCommand(double &x_vel, double &y_vel, double &theta_vel)=0
Returns the last applied velocity command.
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.