Skip to content

Commit

Permalink
update decision
Browse files Browse the repository at this point in the history
  • Loading branch information
66Lau committed Nov 11, 2023
1 parent af461d8 commit 29fe731
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sentry_decision/src/random_deci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ void callback(const nav_msgs::Odometry& odom)
// std::cout << imu.orientation.x << std::endl;
// std::cout << imu.orientation.y << std::endl;

double distance = abs(odom.pose.pose.position.x-Goal.pose.position.x)+abs(odom.pose.pose.position.y-Goal.pose.position.y);
distance = abs(odom.pose.pose.position.x-Goal.pose.position.x)+abs(odom.pose.pose.position.y-Goal.pose.position.y);
publish_flag = distance < trigger_distance;

if (distance < trigger_distance){
if (publish_flag ){
Goal.header.frame_id = "map";
Goal.pose.position.x = generateRandomNumber(min_x_range, max_x_range);
Goal.pose.position.y = generateRandomNumber(min_y_range, max_y_range);
Expand Down Expand Up @@ -80,7 +81,8 @@ int main (int argc, char** argv){

while(ros::ok()){
ros::spinOnce();
goal_pub.publish(Goal);
if (publish_flag ){
goal_pub.publish(Goal);}
r.sleep();}

}
Expand Down
3 changes: 3 additions & 0 deletions sentry_decision/src/random_deci.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ float min_y_range = -1.5;

float trigger_distance = 0.8;

double distance;
bool publish_flag = true;

#endif

0 comments on commit 29fe731

Please sign in to comment.