提交 84bf555b 编写于 作者: S siyangy 提交者: Jiangtao Hu

Common: Use FillHeader function

上级 9fead654
...@@ -29,6 +29,7 @@ cc_library( ...@@ -29,6 +29,7 @@ cc_library(
":perception_obstacle_hdmapinput", ":perception_obstacle_hdmapinput",
"//modules/common", "//modules/common",
"//modules/common:log", "//modules/common:log",
"//modules/common/adapters:adapter_manager",
"//modules/perception/common:perception_common", "//modules/perception/common:perception_common",
"//modules/perception/lib/base", "//modules/perception/lib/base",
"//modules/perception/lib/config_manager", "//modules/perception/lib/config_manager",
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "tf/transform_listener.h" #include "tf/transform_listener.h"
#include "tf_conversions/tf_eigen.h" #include "tf_conversions/tf_eigen.h"
#include "modules/common/adapters/adapter_manager.h"
#include "modules/common/log.h" #include "modules/common/log.h"
#include "modules/perception/common/perception_gflags.h" #include "modules/perception/common/perception_gflags.h"
#include "modules/perception/lib/base/timer.h" #include "modules/perception/lib/base/timer.h"
...@@ -40,6 +41,7 @@ ...@@ -40,6 +41,7 @@
namespace apollo { namespace apollo {
namespace perception { namespace perception {
using apollo::common::adapter::AdapterManager;
using pcl_util::Point; using pcl_util::Point;
using pcl_util::PointD; using pcl_util::PointD;
using pcl_util::PointCloud; using pcl_util::PointCloud;
...@@ -76,9 +78,6 @@ bool LidarProcess::Process(const sensor_msgs::PointCloud2& message) { ...@@ -76,9 +78,6 @@ bool LidarProcess::Process(const sensor_msgs::PointCloud2& message) {
objects_.clear(); objects_.clear();
const double kTimeStamp = message.header.stamp.toSec(); const double kTimeStamp = message.header.stamp.toSec();
timestamp_ = kTimeStamp; timestamp_ = kTimeStamp;
seq_num_++;
ADEBUG << "process the " << seq_num_ << " frame. timestamp: " << timestamp_;
PERF_BLOCK_START(); PERF_BLOCK_START();
/// get velodyne2world transfrom /// get velodyne2world transfrom
...@@ -188,7 +187,7 @@ bool LidarProcess::Process(double timestamp, PointCloudPtr point_cloud, ...@@ -188,7 +187,7 @@ bool LidarProcess::Process(double timestamp, PointCloudPtr point_cloud,
PERF_BLOCK_END("lidar_tracker"); PERF_BLOCK_END("lidar_tracker");
ADEBUG << "lidar process succ, there are " << objects_.size() ADEBUG << "lidar process succ, there are " << objects_.size()
<< " tracked objects."; << " tracked objects.";
return true; return true;
} }
...@@ -353,22 +352,14 @@ bool LidarProcess::GetVelodyneTrans(const double query_time, Matrix4d* trans) { ...@@ -353,22 +352,14 @@ bool LidarProcess::GetVelodyneTrans(const double query_time, Matrix4d* trans) {
*trans = affine_3d.matrix(); *trans = affine_3d.matrix();
ADEBUG << "get " << FLAGS_lidar_tf2_frame_id << " to " ADEBUG << "get " << FLAGS_lidar_tf2_frame_id << " to "
<< FLAGS_lidar_tf2_child_frame_id << " trans: " << *trans; << FLAGS_lidar_tf2_child_frame_id << " trans: " << *trans;
return true; return true;
} }
bool LidarProcess::GeneratePbMsg(PerceptionObstacles* obstacles) { bool LidarProcess::GeneratePbMsg(PerceptionObstacles* obstacles) {
// double publish_time = ros::Time::now().toSec(); AdapterManager::FillPerceptionObstaclesHeader(FLAGS_obstacle_module_name,
double publish_time = timestamp_; obstacles);
try {
publish_time = ros::Time::now().toSec();
} catch (ros::Exception& ex) {
AERROR << "Exception: " << ex.what();
}
apollo::common::Header* header = obstacles->mutable_header(); apollo::common::Header* header = obstacles->mutable_header();
header->set_timestamp_sec(publish_time);
header->set_module_name(FLAGS_obstacle_module_name);
header->set_sequence_num(seq_num_);
header->set_lidar_timestamp(timestamp_ * 1e9); // in ns header->set_lidar_timestamp(timestamp_ * 1e9); // in ns
header->set_camera_timestamp(0); header->set_camera_timestamp(0);
header->set_radar_timestamp(0); header->set_radar_timestamp(0);
......
...@@ -71,7 +71,6 @@ class LidarProcess { ...@@ -71,7 +71,6 @@ class LidarProcess {
bool GetVelodyneTrans(const double query_time, Eigen::Matrix4d* trans); bool GetVelodyneTrans(const double query_time, Eigen::Matrix4d* trans);
bool inited_ = false; bool inited_ = false;
size_t seq_num_ = 0;
double timestamp_; double timestamp_;
apollo::common::ErrorCode error_code_ = apollo::common::OK; apollo::common::ErrorCode error_code_ = apollo::common::OK;
std::vector<ObjectPtr> objects_; std::vector<ObjectPtr> objects_;
......
...@@ -18,8 +18,9 @@ ...@@ -18,8 +18,9 @@
#include <vector> #include <vector>
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "modules/common/log.h" #include "modules/common/adapters/adapter_manager.h"
#include "modules/common/configs/config_gflags.h" #include "modules/common/configs/config_gflags.h"
#include "modules/common/log.h"
#include "modules/perception/common/perception_gflags.h" #include "modules/perception/common/perception_gflags.h"
#include "modules/perception/lib/pcl_util/pcl_types.h" #include "modules/perception/lib/pcl_util/pcl_types.h"
#include "modules/perception/obstacle/lidar/dummy/dummy_algorithms.h" #include "modules/perception/obstacle/lidar/dummy/dummy_algorithms.h"
...@@ -36,7 +37,19 @@ using Eigen::Matrix4d; ...@@ -36,7 +37,19 @@ using Eigen::Matrix4d;
class LidarProcessTest : public testing::Test { class LidarProcessTest : public testing::Test {
protected: protected:
LidarProcessTest() {} LidarProcessTest() {
apollo::common::adapter::AdapterManagerConfig config;
config.set_is_ros(false);
{
auto *sub_config = config.add_config();
sub_config->set_mode(
apollo::common::adapter::AdapterConfig::PUBLISH_ONLY);
sub_config->set_type(
apollo::common::adapter::AdapterConfig::PERCEPTION_OBSTACLES);
}
apollo::common::adapter::AdapterManager::Init(config);
}
virtual ~LidarProcessTest() {} virtual ~LidarProcessTest() {}
LidarProcess lidar_process_; LidarProcess lidar_process_;
......
...@@ -53,9 +53,10 @@ cc_library( ...@@ -53,9 +53,10 @@ cc_library(
"result_generator.h", "result_generator.h",
], ],
deps = [ deps = [
"//modules/common/adapters:adapter_manager",
"//modules/common/time",
"//modules/routing/proto:routing_proto", "//modules/routing/proto:routing_proto",
"//modules/routing/graph", "//modules/routing/graph",
"//modules/common/time",
], ],
) )
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*****************************************************************************/ *****************************************************************************/
#include "modules/routing/core/result_generator.h"
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
...@@ -21,18 +22,19 @@ ...@@ -21,18 +22,19 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "modules/routing/core/result_generator.h" #include "modules/common/adapters/adapter_manager.h"
#include "modules/common/log.h" #include "modules/common/log.h"
#include "modules/common/time/time.h" #include "modules/common/time/time.h"
#include "modules/routing/common/routing_gflags.h" #include "modules/routing/common/routing_gflags.h"
#include "modules/routing/graph/range_utils.h"
#include "modules/routing/graph/node_with_range.h" #include "modules/routing/graph/node_with_range.h"
#include "modules/routing/graph/range_utils.h"
namespace apollo { namespace apollo {
namespace routing { namespace routing {
using apollo::common::adapter::AdapterManager;
namespace { namespace {
bool IsCloseEnough(double value_1, double value_2) { bool IsCloseEnough(double value_1, double value_2) {
...@@ -43,7 +45,7 @@ bool IsCloseEnough(double value_1, double value_2) { ...@@ -43,7 +45,7 @@ bool IsCloseEnough(double value_1, double value_2) {
} }
std::string GetRoadId( std::string GetRoadId(
const std::vector<std::vector<NodeWithRange> >& node_vecs) { const std::vector<std::vector<NodeWithRange>>& node_vecs) {
std::unordered_set<std::string> road_id_set; std::unordered_set<std::string> road_id_set;
std::string road_id = ""; std::string road_id = "";
for (const auto& node_vec : node_vecs) { for (const auto& node_vec : node_vecs) {
...@@ -68,8 +70,7 @@ void NodeVecToSet(const std::vector<NodeWithRange>& vec, ...@@ -68,8 +70,7 @@ void NodeVecToSet(const std::vector<NodeWithRange>& vec,
} }
} }
NodeWithRange BuildNodeRange(const TopoNode* node, NodeWithRange BuildNodeRange(const TopoNode* node, double start_s,
double start_s,
double end_s) { double end_s) {
NodeSRange range(start_s, end_s); NodeSRange range(start_s, end_s);
NodeWithRange node_with_range(range, node); NodeWithRange node_with_range(range, node);
...@@ -82,17 +83,17 @@ const NodeWithRange& GetLargestRange( ...@@ -82,17 +83,17 @@ const NodeWithRange& GetLargestRange(
size_t result_idx = 0; size_t result_idx = 0;
double result_range_length = 0.0; double result_range_length = 0.0;
for (size_t i = 1; i < node_vec.size(); ++i) { for (size_t i = 1; i < node_vec.size(); ++i) {
if (node_vec[i].Length() > result_range_length) { if (node_vec[i].Length() > result_range_length) {
result_range_length = node_vec[i].Length(); result_range_length = node_vec[i].Length();
result_idx = i; result_idx = i;
} }
} }
return node_vec[result_idx]; return node_vec[result_idx];
} }
void GetNodesOfWaysBasedOnVirtual( void GetNodesOfWaysBasedOnVirtual(
const std::vector<NodeWithRange>& nodes, const std::vector<NodeWithRange>& nodes,
std::vector<std::vector<NodeWithRange> >* const nodes_of_ways) { std::vector<std::vector<NodeWithRange>>* const nodes_of_ways) {
AINFO << "Cut routing ways based on is_virtual."; AINFO << "Cut routing ways based on is_virtual.";
assert(!nodes.empty()); assert(!nodes.empty());
nodes_of_ways->clear(); nodes_of_ways->clear();
...@@ -116,7 +117,7 @@ void GetNodesOfWaysBasedOnVirtual( ...@@ -116,7 +117,7 @@ void GetNodesOfWaysBasedOnVirtual(
void GetNodesOfWays( void GetNodesOfWays(
const std::vector<NodeWithRange>& nodes, const std::vector<NodeWithRange>& nodes,
std::vector<std::vector<NodeWithRange> >* const nodes_of_ways) { std::vector<std::vector<NodeWithRange>>* const nodes_of_ways) {
AINFO << "Cut routing ways based on road id."; AINFO << "Cut routing ways based on road id.";
assert(!nodes.empty()); assert(!nodes.empty());
nodes_of_ways->clear(); nodes_of_ways->clear();
...@@ -136,20 +137,20 @@ void GetNodesOfWays( ...@@ -136,20 +137,20 @@ void GetNodesOfWays(
bool ExtractBasicPassages( bool ExtractBasicPassages(
const std::vector<NodeWithRange>& nodes, const std::vector<NodeWithRange>& nodes,
std::vector<std::vector<NodeWithRange> >* const nodes_of_passages, std::vector<std::vector<NodeWithRange>>* const nodes_of_passages,
std::vector<RoutingResponse::LaneChangeInfo::Type>* const std::vector<RoutingResponse::LaneChangeInfo::Type>* const
lane_change_types) { lane_change_types) {
assert(!nodes.empty()); assert(!nodes.empty());
nodes_of_passages->clear(); nodes_of_passages->clear();
lane_change_types->clear(); lane_change_types->clear();
std::vector<NodeWithRange> nodes_of_passage; std::vector<NodeWithRange> nodes_of_passage;
nodes_of_passage.push_back(nodes.at(0)); nodes_of_passage.push_back(nodes.at(0));
for (size_t i = 1; i < nodes.size(); ++i) { for (size_t i = 1; i < nodes.size(); ++i) {
auto edge = nodes.at(i - 1).GetTopoNode() auto edge =
->GetOutEdgeTo(nodes.at(i).GetTopoNode()); nodes.at(i - 1).GetTopoNode()->GetOutEdgeTo(nodes.at(i).GetTopoNode());
if (edge == nullptr) { if (edge == nullptr) {
AERROR << "Get null pointer to edge from " AERROR << "Get null pointer to edge from " << nodes.at(i - 1).LaneId()
<< nodes.at(i - 1).LaneId() << " to " << nodes.at(i).LaneId(); << " to " << nodes.at(i).LaneId();
return false; return false;
} }
if (edge->Type() == TET_LEFT || edge->Type() == TET_RIGHT) { if (edge->Type() == TET_LEFT || edge->Type() == TET_RIGHT) {
...@@ -212,9 +213,9 @@ void ExtendBackward(bool enable_use_road_id, ...@@ -212,9 +213,9 @@ void ExtendBackward(bool enable_use_road_id,
if (IsCloseEnough(nodes_of_prev_passage.front().StartS(), 0.0)) { if (IsCloseEnough(nodes_of_prev_passage.front().StartS(), 0.0)) {
front_node.SetStartS(0.0); front_node.SetStartS(0.0);
} else { } else {
double temp_s = nodes_of_prev_passage.front().StartS() double temp_s = nodes_of_prev_passage.front().StartS() /
/ nodes_of_prev_passage.front().FullLength() nodes_of_prev_passage.front().FullLength() *
* front_node.FullLength(); front_node.FullLength();
front_node.SetStartS(temp_s); front_node.SetStartS(temp_s);
} }
} else { } else {
...@@ -234,8 +235,8 @@ void ExtendBackward(bool enable_use_road_id, ...@@ -234,8 +235,8 @@ void ExtendBackward(bool enable_use_road_id,
} }
// if pred node has been inserted // if pred node has been inserted
if (enable_use_road_id && if (enable_use_road_id &&
node_set_of_curr_passage.find(pred_node) node_set_of_curr_passage.find(pred_node) !=
!= node_set_of_curr_passage.end()) { node_set_of_curr_passage.end()) {
continue; continue;
} }
// if pred node is reachable from prev passage // if pred node is reachable from prev passage
...@@ -244,14 +245,12 @@ void ExtendBackward(bool enable_use_road_id, ...@@ -244,14 +245,12 @@ void ExtendBackward(bool enable_use_road_id,
if (range_manager.Find(pred_node)) { if (range_manager.Find(pred_node)) {
double black_s_end = range_manager.RangeEnd(pred_node); double black_s_end = range_manager.RangeEnd(pred_node);
if (!IsCloseEnough(black_s_end, pred_node->Length())) { if (!IsCloseEnough(black_s_end, pred_node->Length())) {
pred_set.push_back(BuildNodeRange(pred_node, pred_set.push_back(
black_s_end, BuildNodeRange(pred_node, black_s_end, pred_node->Length()));
pred_node->Length()));
} }
} else { } else {
pred_set.push_back(BuildNodeRange(pred_node, pred_set.push_back(
0.0, BuildNodeRange(pred_node, 0.0, pred_node->Length()));
pred_node->Length()));
} }
} }
} }
...@@ -281,7 +280,8 @@ void ExtendForward(bool enable_use_road_id, ...@@ -281,7 +280,8 @@ void ExtendForward(bool enable_use_road_id,
back_node.SetEndS(back_node.FullLength()); back_node.SetEndS(back_node.FullLength());
} else { } else {
double temp_s = nodes_of_next_passage.back().EndS() / double temp_s = nodes_of_next_passage.back().EndS() /
nodes_of_next_passage.back().FullLength() * back_node.FullLength(); nodes_of_next_passage.back().FullLength() *
back_node.FullLength();
back_node.SetEndS(std::min(temp_s, back_node.FullLength())); back_node.SetEndS(std::min(temp_s, back_node.FullLength()));
} }
} else { } else {
...@@ -293,16 +293,16 @@ void ExtendForward(bool enable_use_road_id, ...@@ -293,16 +293,16 @@ void ExtendForward(bool enable_use_road_id,
while (allowed_to_explore) { while (allowed_to_explore) {
std::vector<NodeWithRange> succ_set; std::vector<NodeWithRange> succ_set;
for (const auto& edge : for (const auto& edge :
nodes_of_curr_passage->back().GetTopoNode()->OutToSucEdge()) { nodes_of_curr_passage->back().GetTopoNode()->OutToSucEdge()) {
const auto& succ_node = edge->ToNode(); const auto& succ_node = edge->ToNode();
// if succ node is not in the same road // if succ node is not in the same road
if (enable_use_road_id && if (enable_use_road_id &&
succ_node->RoadId() != nodes_of_curr_passage->back().RoadId()) { succ_node->RoadId() != nodes_of_curr_passage->back().RoadId()) {
continue; continue;
} }
// if succ node has been inserted // if succ node has been inserted
if (node_set_of_curr_passage.find(succ_node) if (node_set_of_curr_passage.find(succ_node) !=
!= node_set_of_curr_passage.end()) { node_set_of_curr_passage.end()) {
continue; continue;
} }
// if next passage is reachable from succ node // if next passage is reachable from succ node
...@@ -316,12 +316,12 @@ void ExtendForward(bool enable_use_road_id, ...@@ -316,12 +316,12 @@ void ExtendForward(bool enable_use_road_id,
} else { } else {
if (IsCloseEnough(reachable_node->EndS(), if (IsCloseEnough(reachable_node->EndS(),
reachable_node->FullLength())) { reachable_node->FullLength())) {
succ_set.push_back(BuildNodeRange(succ_node, succ_set.push_back(
0.0, BuildNodeRange(succ_node, 0.0, succ_node->Length()));
succ_node->Length()));
} else { } else {
double push_end_s = reachable_node->EndS() / double push_end_s = reachable_node->EndS() /
reachable_node->FullLength() * succ_node->Length(); reachable_node->FullLength() *
succ_node->Length();
succ_set.push_back(BuildNodeRange(succ_node, 0.0, push_end_s)); succ_set.push_back(BuildNodeRange(succ_node, 0.0, push_end_s));
} }
} }
...@@ -339,36 +339,27 @@ void ExtendForward(bool enable_use_road_id, ...@@ -339,36 +339,27 @@ void ExtendForward(bool enable_use_road_id,
} }
void ExtendPassages( void ExtendPassages(
bool enable_use_road_id, bool enable_use_road_id, const TopoRangeManager& range_manager,
const TopoRangeManager& range_manager, std::vector<std::vector<NodeWithRange>>* const nodes_of_passages) {
std::vector<std::vector<NodeWithRange> >* const nodes_of_passages) {
int passage_num = nodes_of_passages->size(); int passage_num = nodes_of_passages->size();
for (int i = 0; i < passage_num; ++i) { for (int i = 0; i < passage_num; ++i) {
if (i < passage_num - 1) { if (i < passage_num - 1) {
ExtendForward(enable_use_road_id, ExtendForward(enable_use_road_id, nodes_of_passages->at(i + 1),
nodes_of_passages->at(i + 1), range_manager, &(nodes_of_passages->at(i)));
range_manager,
&(nodes_of_passages->at(i)));
} }
if (i > 0) { if (i > 0) {
ExtendBackward(enable_use_road_id, ExtendBackward(enable_use_road_id, nodes_of_passages->at(i - 1),
nodes_of_passages->at(i - 1), range_manager, &(nodes_of_passages->at(i)));
range_manager,
&(nodes_of_passages->at(i)));
} }
} }
for (int i = passage_num - 1; i >= 0; --i) { for (int i = passage_num - 1; i >= 0; --i) {
if (i < passage_num - 1) { if (i < passage_num - 1) {
ExtendForward(enable_use_road_id, ExtendForward(enable_use_road_id, nodes_of_passages->at(i + 1),
nodes_of_passages->at(i + 1), range_manager, &(nodes_of_passages->at(i)));
range_manager,
&(nodes_of_passages->at(i)));
} }
if (i > 0) { if (i > 0) {
ExtendBackward(enable_use_road_id, ExtendBackward(enable_use_road_id, nodes_of_passages->at(i - 1),
nodes_of_passages->at(i - 1), range_manager, &(nodes_of_passages->at(i)));
range_manager,
&(nodes_of_passages->at(i)));
} }
} }
} }
...@@ -386,8 +377,8 @@ void LaneNodesToPassageRegion(const std::vector<NodeWithRange>& nodes, ...@@ -386,8 +377,8 @@ void LaneNodesToPassageRegion(const std::vector<NodeWithRange>& nodes,
double CalculateDistance(const std::vector<NodeWithRange>& nodes) { double CalculateDistance(const std::vector<NodeWithRange>& nodes) {
double distance = nodes.at(0).EndS() - nodes.at(0).StartS(); double distance = nodes.at(0).EndS() - nodes.at(0).StartS();
for (size_t i = 1; i < nodes.size(); ++i) { for (size_t i = 1; i < nodes.size(); ++i) {
auto edge = nodes.at(i - 1).GetTopoNode() auto edge =
->GetOutEdgeTo(nodes.at(i).GetTopoNode()); nodes.at(i - 1).GetTopoNode()->GetOutEdgeTo(nodes.at(i).GetTopoNode());
if (edge->Type() != TET_FORWARD) { if (edge->Type() != TET_FORWARD) {
continue; continue;
} }
...@@ -396,11 +387,10 @@ double CalculateDistance(const std::vector<NodeWithRange>& nodes) { ...@@ -396,11 +387,10 @@ double CalculateDistance(const std::vector<NodeWithRange>& nodes) {
return distance; return distance;
} }
void PrintDebugInfo( void PrintDebugInfo(const std::vector<std::vector<std::vector<NodeWithRange>>>&
const std::vector<std::vector<std::vector<NodeWithRange> > >& nodes_of_passages_of_ways,
nodes_of_passages_of_ways, const std::vector<std::string>& road_id_of_ways,
const std::vector<std::string>& road_id_of_ways, const std::vector<bool>& is_virtual_of_ways) {
const std::vector<bool>& is_virtual_of_ways) {
for (size_t i = 0; i < nodes_of_passages_of_ways.size(); ++i) { for (size_t i = 0; i < nodes_of_passages_of_ways.size(); ++i) {
if (is_virtual_of_ways[i]) { if (is_virtual_of_ways[i]) {
AINFO << "----------Way " << i << " juntion----------"; AINFO << "----------Way " << i << " juntion----------";
...@@ -412,7 +402,7 @@ void PrintDebugInfo( ...@@ -412,7 +402,7 @@ void PrintDebugInfo(
AINFO << "\tPassage " << j; AINFO << "\tPassage " << j;
for (const auto& node : nodes_of_passages_of_ways[i][j]) { for (const auto& node : nodes_of_passages_of_ways[i][j]) {
AINFO << "\t\t" << node.LaneId() << " (" << node.StartS() << ", " AINFO << "\t\t" << node.LaneId() << " (" << node.StartS() << ", "
<< node.EndS() << ")"; << node.EndS() << ")";
} }
} }
} }
...@@ -420,22 +410,14 @@ void PrintDebugInfo( ...@@ -420,22 +410,14 @@ void PrintDebugInfo(
} // namespace } // namespace
ResultGenerator::ResultGenerator() : _sequence_num(0) { }
bool ResultGenerator::GeneratePassageRegion( bool ResultGenerator::GeneratePassageRegion(
const std::string& map_version, const std::string& map_version, const RoutingRequest& request,
const RoutingRequest& request,
const std::vector<NodeWithRange>& nodes, const std::vector<NodeWithRange>& nodes,
const TopoRangeManager& range_manager, const TopoRangeManager& range_manager, RoutingResponse* const result) {
RoutingResponse* const result) { AdapterManager::FillRoutingResponseHeader(FLAGS_node_name, result);
result->mutable_header()->set_timestamp_sec(
::apollo::common::time::Clock::NowInSecond());
result->mutable_header()->set_module_name(FLAGS_node_name);
result->mutable_header()->set_sequence_num(++_sequence_num);
if (!GeneratePassageRegion(nodes, range_manager, result)) { if (!GeneratePassageRegion(nodes, range_manager, result)) {
return false; return false;
} }
result->set_map_version(map_version); result->set_map_version(map_version);
...@@ -446,30 +428,28 @@ bool ResultGenerator::GeneratePassageRegion( ...@@ -446,30 +428,28 @@ bool ResultGenerator::GeneratePassageRegion(
bool ResultGenerator::GeneratePassageRegion( bool ResultGenerator::GeneratePassageRegion(
const std::vector<NodeWithRange>& nodes, const std::vector<NodeWithRange>& nodes,
const TopoRangeManager& range_manager, const TopoRangeManager& range_manager, RoutingResponse* const result) {
RoutingResponse* const result) { std::vector<std::vector<NodeWithRange>> nodes_of_ways;
std::vector<std::vector<NodeWithRange> > nodes_of_ways;
if (FLAGS_use_road_id) { if (FLAGS_use_road_id) {
GetNodesOfWays(nodes, &nodes_of_ways); GetNodesOfWays(nodes, &nodes_of_ways);
} else { } else {
GetNodesOfWaysBasedOnVirtual(nodes, &nodes_of_ways); GetNodesOfWaysBasedOnVirtual(nodes, &nodes_of_ways);
} }
std::vector<std::vector<std::vector<NodeWithRange> > > std::vector<std::vector<std::vector<NodeWithRange>>>
nodes_of_passages_of_ways; nodes_of_passages_of_ways;
std::vector<std::vector<RoutingResponse::LaneChangeInfo::Type> > std::vector<std::vector<RoutingResponse::LaneChangeInfo::Type>>
lane_change_types_of_ways; lane_change_types_of_ways;
std::vector<std::string> road_id_of_ways; std::vector<std::string> road_id_of_ways;
std::vector<bool> is_virtual_of_ways; std::vector<bool> is_virtual_of_ways;
for (size_t i = 0; i < nodes_of_ways.size(); ++i) { for (size_t i = 0; i < nodes_of_ways.size(); ++i) {
std::vector<std::vector<NodeWithRange> > nodes_of_passages; std::vector<std::vector<NodeWithRange>> nodes_of_passages;
std::vector<RoutingResponse::LaneChangeInfo::Type> lane_change_types; std::vector<RoutingResponse::LaneChangeInfo::Type> lane_change_types;
if (nodes_of_ways[i].empty()) { if (nodes_of_ways[i].empty()) {
return false; return false;
} }
if (!nodes_of_ways[i][0].IsVirtual()) { if (!nodes_of_ways[i][0].IsVirtual()) {
is_virtual_of_ways.push_back(false); is_virtual_of_ways.push_back(false);
if (!ExtractBasicPassages(nodes_of_ways[i], if (!ExtractBasicPassages(nodes_of_ways[i], &nodes_of_passages,
&nodes_of_passages,
&lane_change_types)) { &lane_change_types)) {
return false; return false;
} }
...@@ -489,8 +469,7 @@ bool ResultGenerator::GeneratePassageRegion( ...@@ -489,8 +469,7 @@ bool ResultGenerator::GeneratePassageRegion(
} }
} }
PrintDebugInfo(nodes_of_passages_of_ways, PrintDebugInfo(nodes_of_passages_of_ways, road_id_of_ways,
road_id_of_ways,
is_virtual_of_ways); is_virtual_of_ways);
for (size_t i = 0; i < nodes_of_passages_of_ways.size(); ++i) { for (size_t i = 0; i < nodes_of_passages_of_ways.size(); ++i) {
...@@ -543,4 +522,3 @@ bool ResultGenerator::GeneratePassageRegion( ...@@ -543,4 +522,3 @@ bool ResultGenerator::GeneratePassageRegion(
} // namespace routing } // namespace routing
} // namespace apollo } // namespace apollo
...@@ -30,7 +30,7 @@ namespace routing { ...@@ -30,7 +30,7 @@ namespace routing {
class ResultGenerator { class ResultGenerator {
public: public:
ResultGenerator(); ResultGenerator() = default;
~ResultGenerator() = default; ~ResultGenerator() = default;
bool GeneratePassageRegion(const std::string& map_version, bool GeneratePassageRegion(const std::string& map_version,
...@@ -43,9 +43,6 @@ class ResultGenerator { ...@@ -43,9 +43,6 @@ class ResultGenerator {
bool GeneratePassageRegion(const std::vector<NodeWithRange>& nodes, bool GeneratePassageRegion(const std::vector<NodeWithRange>& nodes,
const TopoRangeManager& range_manager, const TopoRangeManager& range_manager,
RoutingResponse* const result); RoutingResponse* const result);
private:
int _sequence_num;
}; };
} // namespace routing } // namespace routing
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册