Skip to content
This repository has been archived by the owner on Mar 10, 2023. It is now read-only.

what does the following fuction do? #43

Open
zoumaguanxin opened this issue Dec 10, 2020 · 6 comments
Open

what does the following fuction do? #43

zoumaguanxin opened this issue Dec 10, 2020 · 6 comments

Comments

@zoumaguanxin
Copy link

https://github.com/Autoware-AI/core_planning/blob/15f68b38a99809a2d0a58ee5bdcdc9d60a2f7045/op_local_planner/nodes/op_trajectory_generator/op_trajectory_generator_core.cpp#L163

In this fuction,

if(msg->lanes.size() > 0)
	{
		bool bOldGlobalPath = m_GlobalPaths.size() == msg->lanes.size();

		m_GlobalPaths.clear();

		for(unsigned int i = 0 ; i < msg->lanes.size(); i++)
		{
			PlannerHNS::ROSHelpers::ConvertFromAutowareLaneToLocalLane(msg->lanes.at(i), m_temp_path);

			PlannerHNS::PlanningHelpers::CalcAngleAndCost(m_temp_path);
			m_GlobalPaths.push_back(m_temp_path);

			if(bOldGlobalPath)
			{
				bOldGlobalPath = PlannerHNS::PlanningHelpers::CompareTrajectories(m_temp_path, m_GlobalPaths.at(i));
			}
		}

		if(!bOldGlobalPath)
		{
			bWayGlobalPath = true;
			std::cout << "Received New Global Path Generator ! " << std::endl;
		}
		else
		{
			m_GlobalPaths.clear();
		}
	}

The varibale bOldGlobalPath never be true, so that this function is equal to

if(msg->lanes.size() > 0)
	{
		bool bOldGlobalPath = m_GlobalPaths.size() == msg->lanes.size();
		m_GlobalPaths.clear();
		for(unsigned int i = 0 ; i < msg->lanes.size(); i++)
		{
			PlannerHNS::ROSHelpers::ConvertFromAutowareLaneToLocalLane(msg->lanes.at(i), m_temp_path);

			PlannerHNS::PlanningHelpers::CalcAngleAndCost(m_temp_path);
			m_GlobalPaths.push_back(m_temp_path);
		}
		bWayGlobalPath = true;
		std::cout << "Received New Global Path Generator ! " << std::endl;		
	}

Is it right?

@maximus5684
Copy link

This is part of OpenPlanner. @hatem-darweesh would you mind taking a look?

@hatem-darweesh
Copy link
Contributor

No that is not true. In next line.
bOldGlobalPath = PlannerHNS::PlanningHelpers::CompareTrajectories(m_temp_path, m_GlobalPaths.at(i));
it could be true or false depending on the similarity between the newly received global paths and the previously received ones.

@zoumaguanxin
Copy link
Author

No that is not true. In next line.
bOldGlobalPath = PlannerHNS::PlanningHelpers::CompareTrajectories(m_temp_path, m_GlobalPaths.at(i));
it could be true or false depending on the similarity between the newly received global paths and the previously received ones.

m_GlobalPaths is always cleared, and then the m_tem_path is pushed back into it. So CompareTrajectories(m_temp_path, m_GlobalPaths.at(i)) will return true.

@zoumaguanxin
Copy link
Author

bOldGlobalPath is true when the condition m_GlobalPaths.size() == msg->lanes.size() true. But, when bOldGlobalPath is true, the CompareTrajectories(m_temp_path, m_GlobalPaths.at(i)) doesn't work as your expectation, it always returns true. Then the m_GlobalPaths will be cleared. When next message arriving,bOldGlobalPath must be false.

@hatem-darweesh
Copy link
Contributor

Taking a second look, you are right.
one solution is:
use local variable for the global path import, than compare to the previous global path.
then if they match do nothing, if not copy the local global path to the m_GlobalPaths.
Thank you.

@JWhitleyWork
Copy link

Would one of you mind submitting a pull request?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants