Skip to content

Commit

Permalink
reset added
Browse files Browse the repository at this point in the history
  • Loading branch information
sadanand1120 committed Oct 30, 2023
1 parent e54b078 commit 838f06f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/navigation/navigation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ void Navigation::SetNavGoal(const Vector2f& loc, float angle) {
plan_path_.clear();
}

void Navigation::ResetNavGoals() {
nav_state_ = NavigationState::kStopped;
nav_goal_loc_ = robot_loc_;
nav_goal_angle_ = robot_angle_;
local_target_.setZero();
plan_path_.clear();
}

void Navigation::SetOverride(const Vector2f& loc, float angle) {
nav_state_ = NavigationState::kOverride;
Expand Down
1 change: 1 addition & 0 deletions src/navigation/navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Navigation {
float* clearance,
Eigen::Vector2f* obstruction);
void SetNavGoal(const Eigen::Vector2f& loc, float angle);
void ResetNavGoals();
void SetOverride(const Eigen::Vector2f& loc, float angle);
void Resume();
bool PlanStillValid();
Expand Down
13 changes: 11 additions & 2 deletions src/navigation/navigation_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include "shared/util/helpers.h"
#include "shared/ros/ros_helpers.h"
#include "std_msgs/Bool.h"
#include "std_msgs/Empty.h"
#include "tf/transform_broadcaster.h"
#include "tf/transform_datatypes.h"
#include "visualization/visualization.h"
Expand Down Expand Up @@ -237,6 +238,10 @@ void GoToCallbackAMRL(const amrl_msgs::Localization2DMsg& msg) {
navigation_.Resume();
}

void ResetNavGoalsCallback(const std_msgs::Empty& msg) {
navigation_.ResetNavGoals();
}

bool PlanServiceCb(graphNavSrv::Request &req,
graphNavSrv::Response &res) {
const Vector2f start(req.start.x, req.start.y);
Expand Down Expand Up @@ -838,6 +843,8 @@ int main(int argc, char** argv) {
n.subscribe("/move_base_simple/goal", 1, &GoToCallback);
ros::Subscriber goto_amrl_sub =
n.subscribe("/move_base_simple/goal_amrl", 1, &GoToCallbackAMRL);
ros::Subscriber reset_nav_goals_sub =
n.subscribe("/reset_nav_goals", 1, &ResetNavGoalsCallback);
ros::Subscriber enabler_sub =
n.subscribe(CONFIG_enable_topic, 1, &EnablerCallback);
ros::Subscriber halt_sub =
Expand Down Expand Up @@ -870,8 +877,10 @@ int main(int argc, char** argv) {
// Publish Visualizations
PublishForwardPredictedPCL(navigation_.GetPredictedCloud());
DrawRobot();
DrawTarget();
DrawPathOptions();
if (navigation_.GetNavStatusUint8() != static_cast<uint8_t>(navigation::NavigationState::kStopped)) {
DrawTarget();
DrawPathOptions();
}
PublishVisualizationMarkers();
PublishPath();
local_viz_msg_.header.stamp = ros::Time::now();
Expand Down

0 comments on commit 838f06f

Please sign in to comment.