38 bool Navigation2DClient::set_current_goal_name(
const std::string& name)
40 m_current_goal_name = name;
44 bool Navigation2DClient::get_current_goal_name(std::string& name)
46 if (m_current_goal_name ==
"")
50 name = m_current_goal_name;
54 bool Navigation2DClient::reset_current_goal_name()
56 m_current_goal_name =
"";
65 m_navigation_server_name.clear();
66 m_map_locations_server_name.clear();
67 m_localization_server_name.clear();
70 m_navigation_server_name = config.
find(
"navigation_server").
asString();
71 m_map_locations_server_name = config.
find(
"map_locations_server").
asString();
72 m_localization_server_name = config.
find(
"localization_server").
asString();
74 if (m_local_name ==
"")
76 yCError(NAVIGATION2DCLIENT,
"open() error you have to provide a valid 'local' param");
80 if (m_navigation_server_name ==
"")
82 yCError(NAVIGATION2DCLIENT,
"open() error you have to provide a valid 'navigation_server' param");
86 if (m_map_locations_server_name ==
"")
88 yCError(NAVIGATION2DCLIENT,
"open() error you have to provide valid 'map_locations_server' param");
92 if (m_localization_server_name ==
"")
94 yCError(NAVIGATION2DCLIENT,
"open() error you have to provide valid 'localization_server' param");
98 if (config.
check(
"period"))
105 yCWarning(NAVIGATION2DCLIENT,
"Using default period of %d ms" , m_period);
116 remote_streaming_name,
117 local_streaming_name;
119 local_rpc_1 = m_local_name +
"/navigation/rpc";
120 local_rpc_2 = m_local_name +
"/locations/rpc";
121 local_rpc_3 = m_local_name +
"/localization/rpc";
122 local_rpc_4 = m_local_name +
"/user_commands/rpc";
123 remote_rpc_1 = m_navigation_server_name +
"/rpc";
124 remote_rpc_2 = m_map_locations_server_name +
"/rpc";
125 remote_rpc_3 = m_localization_server_name +
"/rpc";
126 remote_streaming_name = m_localization_server_name +
"/stream:o";
127 local_streaming_name = m_local_name +
"/stream:i";
129 if (!m_rpc_port_navigation_server.open(local_rpc_1))
131 yCError(NAVIGATION2DCLIENT,
"open() error could not open rpc port %s, check network", local_rpc_1.c_str());
135 if (!m_rpc_port_map_locations_server.open(local_rpc_2))
137 yCError(NAVIGATION2DCLIENT,
"open() error could not open rpc port %s, check network", local_rpc_2.c_str());
141 if (!m_rpc_port_localization_server.open(local_rpc_3))
143 yCError(NAVIGATION2DCLIENT,
"open() error could not open rpc port %s, check network", local_rpc_3.c_str());
149 ok = Network::connect(local_rpc_1, remote_rpc_1);
152 yCError(NAVIGATION2DCLIENT,
"open() error could not connect to %s", remote_rpc_1.c_str());
156 ok = Network::connect(local_rpc_2, remote_rpc_2);
159 yCError(NAVIGATION2DCLIENT,
"open() error could not connect to %s", remote_rpc_2.c_str());
163 ok = Network::connect(local_rpc_3, remote_rpc_3);
166 yCError(NAVIGATION2DCLIENT,
"open() error could not connect to %s", remote_rpc_3.c_str());
170 if (!m_rpc_port_user_commands.open(local_rpc_4.c_str()))
172 yCError(NAVIGATION2DCLIENT,
"Failed to open port %s", local_rpc_4.c_str());
175 m_rpc_port_user_commands.setReader(*
this);
182 m_rpc_port_navigation_server.close();
183 m_rpc_port_map_locations_server.close();
184 m_rpc_port_localization_server.close();
185 m_rpc_port_user_commands.close();
193 yCError(NAVIGATION2DCLIENT) <<
"General error in parse_respond_string";
200 reply.
addString(
"Available commands are:");
204 reply.
addString(
"store_location <location_name> <map_id> <x> <y> <y>");
205 reply.
addString(
"store_current_location <location_name>");
206 reply.
addString(
"delete_location <location_name>");
210 reply.
addString(
"get_navigation_status");
217 reply.
addString(
"initLoc <map_name> <x> <y> <angle in degrees>");
219 else if (command.
get(0).
asString() ==
"store_current_location")
224 reply.
addString(
"store_current_location done");
228 reply.
addString(
"store_current_location failed");
237 if (command.
size() == 5)
246 bool ret = this->gotoTargetByAbsoluteLocation(loc);
249 reply.
addString(
"gotoTargetByAbsoluteLocation() executed successfully");
253 reply.
addString(
"gotoTargetByAbsoluteLocation() returned an error");
263 if (command.
size() == 4)
266 ret = this->gotoTargetByRelativeLocation(x, y,
t);
270 ret = this->gotoTargetByRelativeLocation(x, y);
275 reply.
addString(
"gotoTargetByRelativeLocation() executed successfully");
279 reply.
addString(
"gotoTargetByRelativeLocation() returned an error");
282 else if (command.
get(0).
asString() ==
"get_location_list")
284 std::vector<std::string> locations;
285 bool ret = getLocationsList(locations);
288 for (
size_t i=0; i < locations.size(); i++)
295 reply.
addString(
"get_location_list failed");
298 else if (command.
get(0).
asString() ==
"get_navigation_status")
301 bool ret = this->getNavigationStatus(ss);
309 reply.
addString(
"getNavigationStatus() failed");
316 bool ret1 = this->getCurrentPosition(curr_loc);
319 std::string s = std::string(
"Current Location is: ") + curr_loc.
toString();
324 reply.
addString(
"getCurrentPosition(curr_loc) failed");
330 bool ret2 = this->getCurrentPosition(curr_loc, cov);
333 std::string s = std::string(
"Current Location with covariance is: ") + curr_loc.
toString() +
"\n" + cov.
toString();
338 reply.
addString(
"getCurrentPosition(curr_loc, covariance) failed");
346 if (command.
size() == 5)
352 ret = this->setInitialPose(init_loc);
354 else if (command.
size() == 6)
361 if (b && b->
size()==9)
364 for (
size_t i = 0; i < 3; i++) {
for (
size_t j = 0; j < 3; j++) { cov[i][j] = b->
get(i * 3 + j).
asFloat64(); } }
365 ret = this->setInitialPose(init_loc, cov);
372 std::string s = std::string(
"Localization initialized to: ") + init_loc.
toString();
377 reply.
addString(
"setInitialPose() failed");
380 else if (command.
get(0).
asString() ==
"store_location")
382 if (command.
size() != 6)
384 reply.
addString(
"store_location failed (invalid params)");
400 reply.
addString(
"store_location failed");
404 else if (command.
get(0).
asString() ==
"delete_location")
413 reply.
addString(
"delete_location failed");
416 else if (command.
get(0).
asString() ==
"clear_all_locations")
418 std::vector<std::string> locations;
419 bool ret = getLocationsList(locations);
422 for (
size_t i = 0; i < locations.size(); i++)
424 bool ret = this->deleteLocation(locations[i]);
427 reply.
addString(
"clear_all_locations failed");
430 reply.
addString(
"clear_all_locations done");
434 reply.
addString(
"clear_all_locations failed");
439 bool ret = this->gotoTargetByLocationName(command.
get(1).
asString());
450 else if (command.
get(0).
asString() ==
"get_last_target")
452 std::string last_target;
453 bool b = this->getNameOfCurrentTarget(last_target);
460 yCError(NAVIGATION2DCLIENT) <<
"get_last_target failed: goto <location_name> target not found.";
466 this->stopNavigation();
471 this->stopLocalizationService();
472 reply.
addString(
"Stopping localization service.");
477 if (command.
size() > 1)
479 this->suspendNavigation(time);
482 else if (command.
get(0).
asString() ==
"resume_nav")
484 this->resumeNavigation();
489 this->startLocalizationService();
490 reply.
addString(
"Starting localization service.");
494 yCError(NAVIGATION2DCLIENT) <<
"Unknown command";
504 bool ok = command.
read(connection);
505 if (!ok)
return false;
510 parse_respond_string(command, reply);
514 yCError(NAVIGATION2DCLIENT) <<
"Invalid command type";
519 if (returnToSender !=
nullptr)
521 reply.
write(*returnToSender);
533 bool ret = m_rpc_port_navigation_server.write(b, resp);
538 yCError(NAVIGATION2DCLIENT) <<
"getNavigationStatus() received error from navigation server";
549 yCError(NAVIGATION2DCLIENT) <<
"getNavigationStatus() error on writing on rpc port";
567 bool ret = m_rpc_port_navigation_server.write(b, resp);
572 yCError(NAVIGATION2DCLIENT) <<
"gotoTargetByAbsoluteLocation() received error from navigation server";
578 yCError(NAVIGATION2DCLIENT) <<
"gotoTargetByAbsoluteLocation() error on writing on rpc port";
582 reset_current_goal_name();
586 bool Navigation2DClient::locations_are_similar(
Map2DLocation loc1,
Map2DLocation loc2,
double linear_tolerance,
double angular_tolerance)
588 if (linear_tolerance < 0)
return false;
589 if (angular_tolerance < 0)
return false;
590 yCAssert(NAVIGATION2DCLIENT, linear_tolerance >= 0);
591 yCAssert(NAVIGATION2DCLIENT, angular_tolerance >= 0);
597 if (sqrt(pow((loc1.
x - loc2.
x),2) + pow((loc1.
y - loc2.
y),2)) > linear_tolerance)
602 if (angular_tolerance != std::numeric_limits<double>::infinity())
611 double diff = loc2.
theta - loc1.
theta + 180.0;
612 diff = fmod(diff, 360.0) - 180.0;
613 diff = (diff < -180.0) ? (diff + 360.0) : (diff);
614 if (fabs(diff) > angular_tolerance)
617 double angle1 = normalize_angle(loc1.
theta);
618 double angle2 = normalize_angle(loc2.
theta);
619 double diff = angle1 - angle2;
620 diff += (diff > 180) ? -360 : (diff < -180) ? 360 : 0;
621 if (fabs(diff) > angular_tolerance)
633 if (getCurrentPosition(curr_loc) ==
false)
635 yCError(NAVIGATION2DCLIENT) <<
"checkInsideArea() unable to get robot position";
639 return locations_are_similar(loc, curr_loc, linear_tolerance, angular_tolerance);
648 if (this->getLocation(location_name, loc) ==
false)
650 yCError(NAVIGATION2DCLIENT) <<
"Location" << location_name <<
"not found";
654 if (getCurrentPosition(curr_loc) ==
false)
656 yCError(NAVIGATION2DCLIENT) <<
"checkInsideArea() unable to get robot position";
660 return locations_are_similar(loc, curr_loc, linear_tolerance, angular_tolerance);
666 if (getCurrentPosition(curr_loc) ==
false)
668 yCError(NAVIGATION2DCLIENT) <<
"checkInsideArea() unable to get robot position";
685 if (this->getArea(area_name, area) ==
false)
687 yCError(NAVIGATION2DCLIENT) <<
"Area" << area_name <<
"not found";
691 if (getCurrentPosition(curr_loc) ==
false)
693 yCError(NAVIGATION2DCLIENT) <<
"checkInsideArea() unable to get robot position";
712 bool found = this->getLocation(location_name, loc);
717 found = this->getArea(location_name, area);
727 yCError(NAVIGATION2DCLIENT) <<
"Location not found";
732 this->gotoTargetByAbsoluteLocation(loc);
733 set_current_goal_name(location_name);
748 bool ret = m_rpc_port_navigation_server.write(b, resp);
753 yCError(NAVIGATION2DCLIENT) <<
"gotoTargetByRelativeLocation() received error from navigation server";
759 yCError(NAVIGATION2DCLIENT) <<
"gotoTargetByRelativeLocation() error on writing on rpc port";
763 reset_current_goal_name();
778 bool ret = m_rpc_port_navigation_server.write(b, resp);
783 yCError(NAVIGATION2DCLIENT) <<
"gotoTargetByRelativeLocation() received error from navigation server";
789 yCError(NAVIGATION2DCLIENT) <<
"gotoTargetByRelativeLocation() error on writing on rpc port";
793 reset_current_goal_name();
805 bool ret = m_rpc_port_navigation_server.write(b, resp);
810 yCError(NAVIGATION2DCLIENT) <<
"recomputeCurrentNavigationPath() received error from navigation server";
816 yCError(NAVIGATION2DCLIENT) <<
"recomputeCurrentNavigationPath() error on writing on rpc port";
834 bool ret = m_rpc_port_localization_server.write(b, resp);
839 yCError(NAVIGATION2DCLIENT) <<
"setInitialPose() received error from localization server";
845 yCError(NAVIGATION2DCLIENT) <<
"setInitialPose() error on writing on rpc port";
853 if (cov.
rows() != 3 || cov.
cols() != 3)
855 yCError(NAVIGATION2DCLIENT) <<
"Covariance matrix is expected to have size (3,3)";
868 for (
int i = 0; i < 3; i++) {
for (
int j = 0; j < 3; j++) { mc.
addFloat64(cov[i][j]); } }
870 bool ret = m_rpc_port_localization_server.write(b, resp);
875 yCError(NAVIGATION2DCLIENT) <<
"setInitialPose() received error from localization server";
881 yCError(NAVIGATION2DCLIENT) <<
"setInitialPose() error on writing on rpc port";
895 bool ret = m_rpc_port_localization_server.write(b, resp);
900 yCError(NAVIGATION2DCLIENT) <<
"getCurrentPosition() received error from localization server";
905 if (cov.
rows() != 3 || cov.
cols() != 3)
907 yCDebug(NAVIGATION2DCLIENT) <<
"Performance warning: covariance matrix is not (3,3), resizing...";
915 if (mc ==
nullptr)
return false;
916 for (
size_t i = 0; i < 3; i++) {
for (
size_t j = 0; j < 3; j++) { cov[i][j] = mc->
get(i * 3 + j).
asFloat64(); } }
922 yCError(NAVIGATION2DCLIENT) <<
"getCurrentPosition() error on writing on rpc port";
936 bool ret = m_rpc_port_localization_server.write(b, resp);
941 yCError(NAVIGATION2DCLIENT) <<
"getEstimatedOdometry() received error from localization server";
960 yCError(NAVIGATION2DCLIENT) <<
"getEstimatedOdometry() error on writing on rpc port";
974 bool ret = m_rpc_port_localization_server.write(b, resp);
979 yCError(NAVIGATION2DCLIENT) <<
"getCurrentPosition() received error from localization server";
993 yCError(NAVIGATION2DCLIENT) <<
"getCurrentPosition() error on writing on rpc port";
1008 bool ret = m_rpc_port_navigation_server.write(b, resp);
1013 yCError(NAVIGATION2DCLIENT) <<
"suspendNavigation() received error from navigation server";
1019 yCError(NAVIGATION2DCLIENT) <<
"suspendNavigation() error on writing on rpc port";
1033 bool ret = m_rpc_port_navigation_server.write(b, resp);
1038 yCError(NAVIGATION2DCLIENT) <<
"getAbsoluteLocationOfCurrentTarget() received error from navigation server";
1052 yCError(NAVIGATION2DCLIENT) <<
"getAbsoluteLocationOfCurrentTarget() error on writing on rpc port";
1061 if (get_current_goal_name(s))
1068 yCError(NAVIGATION2DCLIENT) <<
"No name for the current target, or no target set";
1080 bool ret = m_rpc_port_navigation_server.write(b, resp);
1085 yCError(NAVIGATION2DCLIENT) <<
"getRelativeLocationOfCurrentTarget() received error from navigation server";
1098 yCError(NAVIGATION2DCLIENT) <<
"getRelativeLocationOfCurrentTarget() error on writing on rpc port";
1114 bool ret_nav = m_rpc_port_localization_server.write(b_nav, resp_nav);
1119 yCError(NAVIGATION2DCLIENT) <<
"storeCurrentPosition() received error from localization server";
1132 yCError(NAVIGATION2DCLIENT) <<
"storeCurrentPosition() error on writing on rpc port";
1145 bool ret_loc = m_rpc_port_map_locations_server.write(b_loc, resp_loc);
1150 yCError(NAVIGATION2DCLIENT) <<
"storeCurrentPosition() received error from locations server";
1156 yCError(NAVIGATION2DCLIENT) <<
"storeCurrentPosition() error on writing on rpc port";
1176 bool ret = m_rpc_port_map_locations_server.write(b, resp);
1181 yCError(NAVIGATION2DCLIENT) <<
"storeLocation() received error from locations server";
1187 yCError(NAVIGATION2DCLIENT) <<
"storeLocation() error on writing on rpc port";
1202 bool ret = m_rpc_port_map_locations_server.write(b, resp);
1207 yCError(NAVIGATION2DCLIENT) <<
"getLocationsList() received error from locations server";
1216 for (
size_t i = 0; i < list->
size(); i++)
1224 yCError(NAVIGATION2DCLIENT) <<
"getLocationsList() error while reading from locations server";
1231 yCError(NAVIGATION2DCLIENT) <<
"getLocationsList() error on writing on rpc port";
1247 bool ret = m_rpc_port_map_locations_server.write(b, resp);
1252 yCError(NAVIGATION2DCLIENT) <<
"getLocation() received error from locations server";
1265 yCError(NAVIGATION2DCLIENT) <<
"getLocation() error on writing on rpc port";
1283 bool ret = m_rpc_port_map_locations_server.write(b_loc, resp_loc);
1288 yCError(NAVIGATION2DCLIENT) <<
"getArea() received error from locations server";
1294 if (Property::copyPortable(b, area) ==
false)
1296 yCError(NAVIGATION2DCLIENT) <<
"getArea() received error from locations server";
1303 yCError(NAVIGATION2DCLIENT) <<
"getArea() error on writing on rpc port";
1320 bool ret = m_rpc_port_map_locations_server.write(b, resp);
1325 yCError(NAVIGATION2DCLIENT) <<
"deleteLocation() received error from locations server";
1331 yCError(NAVIGATION2DCLIENT) <<
"deleteLocation() error on writing on rpc port";
1346 bool ret = m_rpc_port_map_locations_server.write(b, resp);
1351 yCError(NAVIGATION2DCLIENT) <<
"clearAllLocations() received error from locations server";
1357 yCError(NAVIGATION2DCLIENT) <<
"clearAllLocations() error on writing on rpc port";
1371 bool ret = m_rpc_port_navigation_server.write(b, resp);
1376 yCError(NAVIGATION2DCLIENT) <<
"stopNavigation() received error from navigation server";
1382 yCError(NAVIGATION2DCLIENT) <<
"stopNavigation() error on writing on rpc port";
1396 bool ret = m_rpc_port_navigation_server.write(b, resp);
1401 yCError(NAVIGATION2DCLIENT) <<
"resumeNavigation() received error from navigation server";
1407 yCError(NAVIGATION2DCLIENT) <<
"resumeNavigation() error on writing on rpc port";
1422 bool ret = m_rpc_port_navigation_server.write(b, resp);
1427 yCError(NAVIGATION2DCLIENT) <<
"getNavigationWaypoints() received error from navigation server";
1434 if (waypoints_bottle == 0) {
yCError(NAVIGATION2DCLIENT) <<
"getNavigationWaypoints parsing error";
return false; }
1435 for (
size_t i = 0; i < waypoints_bottle->
size(); i++)
1438 if (the_waypoint == 0) {
yCError(NAVIGATION2DCLIENT) <<
"getNavigationWaypoints parsing error";
return false; }
1457 yCError(NAVIGATION2DCLIENT) <<
"getCurrentPosition() error on writing on rpc port";
1471 bool ret = m_rpc_port_navigation_server.write(b, resp);
1476 yCError(NAVIGATION2DCLIENT) <<
"getCurrentNavigationWaypoint() received error from navigation server";
1479 else if (resp.
size() == 5)
1490 curr_waypoint.
map_id =
"invalid";
1491 curr_waypoint.
x = std::nan(
"");
1492 curr_waypoint.
y = std::nan(
"");
1493 curr_waypoint.
theta = std::nan(
"");
1499 yCError(NAVIGATION2DCLIENT) <<
"getCurrentPosition() error on writing on rpc port";
1514 bool ret = m_rpc_port_navigation_server.write(b, resp);
1519 yCError(NAVIGATION2DCLIENT) <<
"getCurrentNavigationMap() received error from server";
1525 if (Property::copyPortable(b, map))
1531 yCError(NAVIGATION2DCLIENT) <<
"getCurrentNavigationMap() failed copyPortable()";
1538 yCError(NAVIGATION2DCLIENT) <<
"getCurrentNavigationMap() error on writing on rpc port";
1552 bool ret = m_rpc_port_localization_server.write(b, resp);
1557 yCError(NAVIGATION2DCLIENT) <<
"getLocalizationStatus() received error from localization server";
1568 yCError(NAVIGATION2DCLIENT) <<
"getLocalizationStatus() error on writing on rpc port";
1586 bool ret = m_rpc_port_navigation_server.write(b, resp);
1591 yCError(NAVIGATION2DCLIENT) <<
"applyVelocityCommand() received error from navigation server";
1597 yCError(NAVIGATION2DCLIENT) <<
"applyVelocityCommand() error on writing on rpc port";
1601 reset_current_goal_name();
1613 bool ret = m_rpc_port_localization_server.write(b, resp);
1618 yCError(NAVIGATION2DCLIENT) <<
"getEstimatedPoses() received error from localization server";
1625 for (
int i = 0; i < nposes; i++)
1639 yCError(NAVIGATION2DCLIENT) <<
"getEstimatedPoses() parsing error";
1642 poses.push_back(loc);
1649 yCError(NAVIGATION2DCLIENT) <<
"getEstimatedPoses() error on writing on rpc port";
1656 double Navigation2DClient::normalize_angle(
double angle)
1658 angle = std::remainder(angle, 360);
1660 if (angle > 180 && angle < 360)
1662 angle = angle - 360;
1665 if (angle<-180 && angle>-360)
1667 angle = angle + 360;
1680 bool ret = m_rpc_port_localization_server.write(b, resp);
1685 yCError(NAVIGATION2DCLIENT) <<
"startLocalizationService() received error from navigation server";
1691 yCError(NAVIGATION2DCLIENT) <<
"startLocalizationService() error on writing on rpc port";
1705 bool ret = m_rpc_port_localization_server.write(b, resp);
1710 yCError(NAVIGATION2DCLIENT) <<
"stopLocalizationService() received error from navigation server";
1716 yCError(NAVIGATION2DCLIENT) <<
"stopLocalizationService() error on writing on rpc port";
constexpr yarp::conf::vocab32_t VOCAB_OK
constexpr yarp::conf::vocab32_t VOCAB_ERR
constexpr yarp::conf::vocab32_t VOCAB_NAV_DELETE_X
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_LOCALIZER_POSES
constexpr yarp::conf::vocab32_t VOCAB_NAV_VELOCITY_CMD
constexpr yarp::conf::vocab32_t VOCAB_INAVIGATION
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_LIST_X
constexpr yarp::conf::vocab32_t VOCAB_NAV_AREA
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_ABS_TARGET
constexpr yarp::conf::vocab32_t VOCAB_NAV_RECOMPUTE_PATH
constexpr yarp::conf::vocab32_t VOCAB_NAV_STORE_X
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_REL_TARGET
constexpr yarp::conf::vocab32_t VOCAB_NAV_LOCALIZATION_STOP
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_X
constexpr yarp::conf::vocab32_t VOCAB_NAV_SET_INITIAL_POSCOV
constexpr yarp::conf::vocab32_t VOCAB_NAV_CLEAR_X
constexpr yarp::conf::vocab32_t VOCAB_NAV_LOCATION
constexpr yarp::conf::vocab32_t VOCAB_NAV_GOTOREL
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_CURRENT_POS
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_LOCALIZER_STATUS
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_ESTIMATED_ODOM
constexpr yarp::conf::vocab32_t VOCAB_NAV_SET_INITIAL_POS
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_CURRENT_POSCOV
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_NAVIGATION_STATUS
constexpr yarp::conf::vocab32_t VOCAB_NAV_GOTOABS
constexpr yarp::conf::vocab32_t VOCAB_NAV_LOCALIZATION_START
constexpr yarp::conf::vocab32_t VOCAB_NAV_RESUME
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_CURRENT_WAYPOINT
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_NAVIGATION_WAYPOINTS
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_NAV_MAP
constexpr yarp::conf::vocab32_t VOCAB_NAV_STOP
constexpr yarp::conf::vocab32_t VOCAB_NAV_SUSPEND
bool getLocation(std::string location_name, yarp::dev::Nav2D::Map2DLocation &loc) override
Retrieves a location previously stored by the user.
bool storeCurrentPosition(std::string location_name) override
Store the current location of the robot.
bool getCurrentPosition(yarp::dev::Nav2D::Map2DLocation &loc) override
Gets the current position of the robot w.r.t world reference frame.
bool gotoTargetByRelativeLocation(double x, double y, double theta) override
Ask the robot to reach a position defined in the robot reference frame.
bool getNavigationStatus(yarp::dev::Nav2D::NavigationStatusEnum &status) override
Gets the current status of the navigation task.
bool parse_respond_string(const yarp::os::Bottle &command, yarp::os::Bottle &reply)
bool getEstimatedOdometry(yarp::dev::OdometryData &odom) override
Gets the estimated odometry the robot, including its velocity expressed in the world and in the local...
bool getLocalizationStatus(yarp::dev::Nav2D::LocalizationStatusEnum &status) override
Gets the current status of the localization task.
bool getEstimatedPoses(std::vector< yarp::dev::Nav2D::Map2DLocation > &poses) override
Gets a set of pose estimates computed by the localization algorithm.
bool storeLocation(std::string location_name, yarp::dev::Nav2D::Map2DLocation loc) override
Store a location specified by the user in the world reference frame.
bool getAllNavigationWaypoints(yarp::dev::Nav2D::TrajectoryTypeEnum trajectory_type, yarp::dev::Nav2D::Map2DPath &waypoints) override
Returns the list of waypoints generated by the navigation algorithm.
bool getAbsoluteLocationOfCurrentTarget(yarp::dev::Nav2D::Map2DLocation &loc) override
Gets the last navigation target in the world reference frame.
virtual bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual bool checkInsideArea(yarp::dev::Nav2D::Map2DArea area) override
Check if the robot is currently inside the specified area.
bool applyVelocityCommand(double x_vel, double y_vel, double theta_vel, double timeout=0.1) override
Apply a velocity command.
bool getNameOfCurrentTarget(std::string &location_name) override
Gets the name of the current target, if available (set by gotoTargetByLocationName)
bool deleteLocation(std::string location_name) override
Delete a location.
bool getRelativeLocationOfCurrentTarget(double &x, double &y, double &theta) override
Gets the last navigation target in the robot reference frame.
virtual bool checkNearToLocation(yarp::dev::Nav2D::Map2DLocation loc, double linear_tolerance, double angular_tolerance=std::numeric_limits< double >::infinity()) override
Check if the robot is currently near to the specified area.
bool recomputeCurrentNavigationPath() override
Forces the navigation system to recompute the path from the current robot position to the current goa...
bool getArea(std::string area_name, yarp::dev::Nav2D::Map2DArea &area) override
Retrieves an area previously stored by the user.
bool stopNavigation() override
Terminates the current 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 stopLocalizationService() override
Stops the localization service.
bool setInitialPose(const yarp::dev::Nav2D::Map2DLocation &loc) override
Sets the initial pose for the localization algorithm which estimates the current position of the robo...
bool clearAllLocations() override
Delete all stored locations.
bool gotoTargetByAbsoluteLocation(yarp::dev::Nav2D::Map2DLocation loc) override
Ask the robot to reach a position defined in the world reference frame.
bool close() override
Close the DeviceDriver.
bool gotoTargetByLocationName(std::string location_name) override
Ask the robot to reach a previously stored location/area.
bool startLocalizationService() override
Starts the localization service.
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 getCurrentNavigationWaypoint(yarp::dev::Nav2D::Map2DLocation &curr_waypoint) override
Returns the current waypoint pursued by the navigation algorithm.
bool getLocationsList(std::vector< std::string > &locations) override
Get a list of all stored locations.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool resumeNavigation() override
Resume a previously suspended navigation task.
bool getRandomLocation(yarp::dev::Nav2D::Map2DLocation &loc)
get a random Map2DLocation inside the Map2DArea @loc the computed Map2DLocation
bool checkLocationInsideArea(yarp::dev::Nav2D::Map2DLocation loc)
Check if a Map2DLocation is inside a Map2DArea.
void push_back(yarp::dev::Nav2D::Map2DLocation loc)
Inserts a new location into the path @loc the location to be inserted.
void clear()
Remove all elements from the path.
double base_vel_x
velocity of the robot [m/s] expressed in the robot reference frame
double odom_vel_y
velocity of the robot [m/s] expressed in the world reference frame
double base_vel_theta
angular velocity of the robot [deg/s] expressed in the robot reference frame
double odom_vel_theta
angular velocity of the robot [deg/s] expressed in the world reference frame
double base_vel_y
velocity of the robot [m/s] expressed in the robot reference frame
double odom_x
position of the robot [m], expressed in the world reference frame
double odom_y
position of the robot [m], expressed in the world reference frame
double odom_theta
orientation the robot [deg], expressed in the world reference frame
double odom_vel_x
velocity of the robot [m/s] expressed in the world reference frame
A simple collection of objects that can be described and transmitted in a portable way.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
size_type size() const
Gets the number of elements in the bottle.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number in the bottle, at the end of the list.
void addVocab(int x)
Places a vocabulary item in the bottle, at the end of the list.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void clear()
Empties the bottle of any objects it contains.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
An interface for reading from a network connection.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
An interface for writing to a network connection.
A base class for nested structures that can be searched.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
A single value (typically within a Bottle).
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual bool isString() const
Checks if value is a string.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual bool isList() const
Checks if value is a list.
virtual Bottle * asList() const
Get list value.
virtual std::int32_t asVocab() const
Get vocabulary identifier as an integer.
virtual std::string asString() const
Get string value.
void resize(size_t r, size_t c)
Resize the matrix, if matrix is not empty preserve old content.
size_t cols() const
Return number of columns.
size_t rows() const
Return number of rows.
std::string toString(int precision=-1, int width=-1, const char *endRowStr="\n") const
Print matrix to a string.
#define yCError(component,...)
#define yCAssert(component, x)
#define yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
std::string statusToString(NavigationStatusEnum status)
An interface for the device drivers.
NetInt32 encode(const std::string &str)
Convert a string into a vocabulary identifier.
An interface to the operating system, including Port based communication.
std::string toString() const
Returns text representation of the location.