autoware_ai_planning
autoware_ai_planning copied to clipboard
what does the following fuction do?
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?
This is part of OpenPlanner. @hatem-darweesh would you mind taking a look?
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.
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.
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.
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.
Would one of you mind submitting a pull request?