Skip to content

Commit c296463

Browse files
committed
updates for handling 1st goal in the 1st loop + fixed pausing issue
1 parent 5e9ec41 commit c296463

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

nav2_rviz_plugins/src/nav2_panel.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,8 @@ bool Nav2Panel::isLoopValueValid(std::string & loop_value)
591591
for (char & c : loop_value) {
592592
if (isalpha(c) || isspace(c) || ispunct(c)) {
593593
waypoint_status_indicator_->setText(
594-
"<b> Note: </b> Set a valid value for the loop, check for alphabets and spaces");
594+
"<b> Note: </b> Set a valid value for the loop");
595+
std::cout << "Set a valid value for the loop, check for alphabets and spaces" << std::endl;
595596
navigation_mode_button_->setEnabled(false);
596597
return false;
597598
}
@@ -652,6 +653,7 @@ void Nav2Panel::handleGoalLoader()
652653
available_waypoints = YAML::LoadFile(file.toStdString());
653654
} catch (const std::exception & ex) {
654655
std::cout << ex.what() << ", please select a valid file" << std::endl;
656+
updateWpNavigationMarkers();
655657
return;
656658
}
657659

@@ -733,17 +735,18 @@ void Nav2Panel::handleGoalSaver()
733735
out << YAML::EndMap;
734736
}
735737

738+
// open dialog to save it in a file
736739
QString file = QFileDialog::getSaveFileName(
737740
this,
738741
tr("Open File"), "",
739742
tr("yaml(*.yaml);;All Files (*)"));
740743

741-
if (file.toStdString().empty()) {
742-
std::ofstream fout(file.toStdString());
744+
if (!file.toStdString().empty()) {
745+
std::ofstream fout(file.toStdString() + ".yaml");
743746
fout << out.c_str();
747+
std::cout << "Saving waypoints succeeded" << std::endl;
744748
} else {
745-
std::ofstream fout(file.toStdString());
746-
fout << out.c_str();
749+
std::cout << "Saving waypoints aborted" << std::endl;
747750
}
748751
}
749752

@@ -950,10 +953,11 @@ void Nav2Panel::onResumedWp()
950953
&Nav2Panel::onCancelButtonPressed,
951954
this));
952955
acummulated_poses_ = store_poses_;
953-
loop_no_ = std::to_string(stoi(loop_no_) - loop_count_);
956+
loop_no_ = std::to_string(
957+
stoi(nr_of_loops_->displayText().toStdString()) -
958+
loop_count_);
954959
waypoint_status_indicator_->setText(
955-
QString(std::string("<b> Note: </b> Last cancelled waypoint is stored. ").c_str()) +
956-
QString(std::string("Please press resume to continue the navigation.").c_str()));
960+
QString(std::string("<b> Note: </b> Navigation is paused.").c_str()));
957961
}
958962

959963
void
@@ -990,8 +994,7 @@ Nav2Panel::onNewGoal(double x, double y, double theta, QString frame)
990994
}
991995
} else {
992996
waypoint_status_indicator_->setText(
993-
QString(std::string("<b> Note: </b> Cannot set goal in pause state, ").c_str()) +
994-
QString(std::string("press resume to continue").c_str()));
997+
QString(std::string("<b> Note: </b> Cannot set goal in pause state").c_str()));
995998
}
996999
updateWpNavigationMarkers();
9971000
}
@@ -1089,6 +1092,9 @@ Nav2Panel::onAccumulatedWp()
10891092
acummulated_poses_.insert(acummulated_poses_.begin(), initial_pose);
10901093
updateWpNavigationMarkers();
10911094
initial_pose_stored_ = true;
1095+
if (loop_count_ == 0) {
1096+
goal_index_ = 1;
1097+
}
10921098
} else if (!store_initial_pose_ && initial_pose_stored_) {
10931099
acummulated_poses_.erase(
10941100
acummulated_poses_.begin(),

nav2_waypoint_follower/src/waypoint_follower.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ WaypointFollower::followWaypoints()
277277
failed_ids_.clear();
278278
return;
279279
}
280-
std::cout << "Starting a new loop, current loop count is: " << current_loop_no << std::endl;
280+
RCLCPP_INFO(
281+
get_logger(), "Starting a new loop, current loop count is %i",
282+
current_loop_no);
281283
goal_index = 0;
282284
current_loop_no++;
283285
}

0 commit comments

Comments
 (0)