# How to detect is a planned path has changed through topics

**URL:** <https://get-help.theconstruct.ai/t/how-to-detect-is-a-planned-path-has-changed-through-topics/22933>\
**Category:** General Support\
**Created:** [March 8, 2023, 6:12pm UTC](https://get-help.theconstruct.ai/t/how-to-detect-is-a-planned-path-has-changed-through-topics/22933 "2023-03-08T18:12:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lfernandez](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/l/bb73d2/32.png) [@lfernandez](https://get-help.theconstruct.ai/u/lfernandez)\
**Post date:** [March 8, 2023, 6:12pm UTC](https://get-help.theconstruct.ai/t/how-to-detect-is-a-planned-path-has-changed-through-topics/22933/1 "2023-03-08T18:12:27Z")

</div>

Hi everyone,  
I would like to know if is there a way to detect if a precomputed planned path has changed due to, for example, an obstacle, through topics information. I’ve by using the /plan topic but it receives new poses continuously, even if the plan hasn’t changed.  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![girishkumar.kannan](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/girishkumar.kannan/32/6994_2.png) [@girishkumar.kannan](https://get-help.theconstruct.ai/u/girishkumar.kannan)\
**Post date:** [March 9, 2023, 5:46am UTC](https://get-help.theconstruct.ai/t/how-to-detect-is-a-planned-path-has-changed-through-topics/22933/2 "2023-03-09T05:46:15Z")

</div>

Hi @lfernandez ,

From my experience so far, I can say a few things:

1. The global plan may not change frequently.
2. The local plan is designed to change frequently and be more “path-adaptable”.

What I understand from your question: You want to detect if the initially computed path has changed recently or had multiple changes.

If you are using ROS 1: use the `/move_base/<your_global_path_planner>/global_plan` topic.  
If you are using ROS 2: use the `/received_global_plan` topic. `/plan` is subjected to change as the robot moves.

To give you **one** solution:  
Once the goal position is communicated to the action server, you can read the very first path plan from the above mentioned topics.  
To check if the path has changed, you can do it by two ways:  
Simple way:  
Just compare the initial path plan to current path plan.  
Complex way:  
Use an external program logic to compare the initial path plan with current path plan.  
You can use mathematical shape comparison logic or any pattern matching logic and check for match percentage.

I hope this helps.

Regards,  
Girish

---

<div class="post-metadata">

**Author:** ![lfernandez](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/l/bb73d2/32.png) [@lfernandez](https://get-help.theconstruct.ai/u/lfernandez)\
**Post date:** [March 9, 2023, 11:52am UTC](https://get-help.theconstruct.ai/t/how-to-detect-is-a-planned-path-has-changed-through-topics/22933/3 "2023-03-09T11:52:12Z")

</div>

Thanks @girishkumar.kannan  
I’ve checked it and I think that `/received_global_plan` decreases the number of poses with each message from the same path. Is it possible?  
Thanks again

---

<div class="post-metadata">

**Author:** ![girishkumar.kannan](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/girishkumar.kannan/32/6994_2.png) [@girishkumar.kannan](https://get-help.theconstruct.ai/u/girishkumar.kannan)\
**Post date:** [March 9, 2023, 12:39pm UTC](https://get-help.theconstruct.ai/t/how-to-detect-is-a-planned-path-has-changed-through-topics/22933/4 "2023-03-09T12:39:59Z")

</div>

Hi @lfernandez ,

I actually did not know that `/received_global_plan` decreases the number of poses with each message.  
If I am right, I guess, `/plan` = `/received_global_plan` + `/transformed_global_plan`.

So what you can do is use the `/plan` instead, but make sure you get the first plan correctly and store it for later use, since you have mentioned that even `/plan` keeps changing.

I have not done such an implementation before, so I just shared an idea that I had.

Perhaps, someone from TheConstruct Team can give you a better idea/suggestion.

Regards,  
Girish

---

<div class="post-metadata">

**Author:** ![lfernandez](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/l/bb73d2/32.png) [@lfernandez](https://get-help.theconstruct.ai/u/lfernandez)\
**Post date:** [March 9, 2023, 1:10pm UTC](https://get-help.theconstruct.ai/t/how-to-detect-is-a-planned-path-has-changed-through-topics/22933/5 "2023-03-09T13:10:34Z")

</div>

Thanks @girishkumar.kannan. I don’t know how to do it due to all the poses arrays returns by the topics seem to change even when the planned path doesn’t.  
Thanks again!

---

<div class="post-metadata">

**Author:** ![rzegers](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rzegers/32/7010_2.png) [@rzegers](https://get-help.theconstruct.ai/u/rzegers)\
**Post date:** [March 10, 2023, 8:40am UTC](https://get-help.theconstruct.ai/t/how-to-detect-is-a-planned-path-has-changed-through-topics/22933/6 "2023-03-10T08:40:27Z")

</div>

Hello @lfernandez,

If you are using the move\_base node, there is the “planner\_frequency” parameter that defines how frequently the global plan is calculated in Hz (default: 0.0). If that value is 5 you will get a new plan 5 times a second, normally I set it to 1 or 0.5 because the global plan is a computationally expensive operation.

From the documentation here: [http://wiki.ros.org/move\_base#Parameters](http://wiki.ros.org/move_base#Parameters)  
If the frequency is set to 0.0, the global planner will only run when a new goal is received or the local planner reports that its path is blocked.

> all the poses arrays returns by the topics seem to change even when the planned path doesn’t.

Notice that a Path is a set of points contained in a nav\_msgs/Path message.  
This list of individual points will very likely change each time the global path is calculated (at the frequency set as explained above) **even if the plan doesn’t seem to change as visualized in Rviz**.

To solve the problem of changing points in a seemingly not changing path (as visualized in Rviz) I would try first with tolerances for the waypoints or some kind of statistical method.

From with my limited knowledge I haven’t come across a ready made package that does that out of the box. So now you, @lfernandez, as ROS engineer have to come up with a solution to solve that problem. We can only provide ideas here but the solution has to be build by you.

Hope these hints help,

Cheers,

Roberto

---

<div class="post-metadata">

**Author:** ![lfernandez](https://get-help.theconstruct.ai/letter_avatar_proxy/v4/letter/l/bb73d2/32.png) [@lfernandez](https://get-help.theconstruct.ai/u/lfernandez)\
**Post date:** [March 12, 2023, 7:04pm UTC](https://get-help.theconstruct.ai/t/how-to-detect-is-a-planned-path-has-changed-through-topics/22933/7 "2023-03-12T19:04:21Z")

</div>

Thanks @rzegers  
Yes, I was only asking for ideas. Thanks agains for your help!

---

<div class="post-metadata">

**Author:** ![system](https://get-help.theconstruct.ai/uploads/default/original/2X/9/9d3ce8305cc0d0d9b6e07d15767a6f245c526f1b.jpeg) [@system](https://get-help.theconstruct.ai/u/system)\
**Post date:** [March 22, 2023, 7:04pm UTC](https://get-help.theconstruct.ai/t/how-to-detect-is-a-planned-path-has-changed-through-topics/22933/8 "2023-03-22T19:04:33Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
