num_els.c

 
bool ParseProtoMsg::DecodeLaneInfoListMessage( msg::perception::lane::LaneInfoCameraList& proto_in, ad_msg::LaneInfoCameraList* data_out) { if (nullptr == data_out) { return false; } // 清空输出结构 data_out->Clear(); // 1. 解析消息头 if (proto_in.has_msg_head()) { auto& proto_head = proto_in.msg_head(); if (proto_head.has_seq()) { data_out->msg_head.seq = proto_head.seq(); } if (proto_head.has_timestamp()) { data_out->msg_head.timestamp = proto_head.timestamp(); } } // 2. 解析基础字段 if (proto_in.has_quality()) { data_out->quality = static_cast<Int8_t>(proto_in.quality()); } if (proto_in.has_forward_len()) { data_out->forward_len = proto_in.forward_len(); } if (proto_in.has_left_width()) { data_out->left_width = proto_in.left_width(); } if (proto_in.has_right_width()) { data_out->right_width = proto_in.right_width(); } // 3. 解析边界线 (boundary_lines) const int boundary_count = std::min( proto_in.boundary_lines_size(), ad_msg::LaneInfoCameraList::MAX_LANE_BOUNDARY_LINE_NUM); data_out->boundary_lines_els_num = boundary_count; for (int i = 0; i < boundary_count; ++i) { const auto& proto_line = proto_in.boundary_lines(i); auto& cpp_line = data_out->boundary_lines[i]; // 解析边界线基础字段 if (proto_line.has_id()) cpp_line.id = proto_line.id(); // 使用switch-case处理类型字段 if (proto_line.has_type()) { switch (proto_line.type()) { case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_INVALID: cpp_line.type = 0; // 对应C++中的INVALID break; case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_UNKNOWN: cpp_line.type = 1; break; case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_DASHED: cpp_line.type = 2; break; case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_SOLID: cpp_line.type = 3; break; case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_DOUBLE_LANE_MARK: cpp_line.type = 4; break; case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_BOTTS_DOTS: cpp_line.type = 5; break; case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_ROAD_EDGE: cpp_line.type = 6; break; case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_DASHED_SOLID: cpp_line.type = 7; break; case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_SOLID_DASHED: cpp_line.type = 8; break; case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_DOUBLE_YELLOW: cpp_line.type = 9; break; case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_FISHBONE: cpp_line.type = 10; break; default: // 处理未定义类型 cpp_line.type = 0; // 默认为INVALID break; } } // 解析曲线点 const int point_count = std::min( proto_line.curve_size(), ad_msg::LaneBoundaryLineCamera::MAX_CURVE_POINT_NUM); cpp_line.curve_els_num = point_count; for (int j = 0; j < point_count; ++j) { const auto& proto_point = proto_line.curve(j); auto& cpp_point = cpp_line.curve[j]; cpp_point.fake = proto_point.fake() ? 1 : 0; if (proto_point.has_x()) cpp_point.x = proto_point.x(); if (proto_point.has_y()) cpp_point.y = proto_point.y(); } } // 4. 解析中心线 (center_lines) const int center_count = std::min( proto_in.center_lines_size(), ad_msg::LaneInfoCameraList::MAX_LANE_CENTER_LINE_NUM); data_out->center_lines_els_num = center_count; for (int i = 0; i < center_count; ++i) { const auto& proto_line = proto_in.center_lines(i); auto& cpp_line = data_out->center_lines[i]; // 解析中心线基础字段 if (proto_line.has_quality()) cpp_line.quality = static_cast<Int8_t>(proto_line.quality()); if (proto_line.has_age()) cpp_line.age = proto_line.age(); if (proto_line.has_forward_len()) cpp_line.forward_len = proto_line.forward_len(); if (proto_line.has_id()) cpp_line.id = proto_line.id(); if (proto_line.has_left_boundary_index()) { cpp_line.left_boundary_index = proto_line.left_boundary_index(); } if (proto_line.has_right_boundary_index()) { cpp_line.right_boundary_index = proto_line.right_boundary_index(); } // 解析中心曲线点 const int point_count = std::min( proto_line.curve_size(), ad_msg::LaneCenterLineCamera::MAX_CURVE_POINT_NUM); cpp_line.curve_els_num = point_count; for (int j = 0; j < point_count; ++j) { const auto& proto_point = proto_line.curve(j); auto& cpp_point = cpp_line.curve[j]; if (proto_point.has_x()) cpp_point.x = proto_point.x(); if (proto_point.has_y()) cpp_point.y = proto_point.y(); if (proto_point.has_left_width()) cpp_point.left_width = proto_point.left_width(); if (proto_point.has_right_width()) cpp_point.right_width = proto_point.right_width(); } } return true; } 以上代码出现以下错误,请修改/home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc: In member function ‘bool phoenix::msg::ParseProtoMsg::DecodeLaneInfoListMessage(phoenix::msg::perception::lane::LaneInfoCameraList&, phoenix::ad_msg::LaneInfoCameraList*)’: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:502:26: error: ‘struct phoenix::ad_msg::MsgHead’ has no member named ‘seq’ 502 | data_out->msg_head.seq = proto_head.seq(); | ^~~ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:526:61: error: no matching function for call to ‘min(int, phoenix::ad_msg::LaneInfoCameraList::<unnamed enum>)’ 526 | ad_msg::LaneInfoCameraList::MAX_LANE_BOUNDARY_LINE_NUM); | ^ In file included from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/string:40, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:8, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: ‘template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)’ 198 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:198:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:526:61: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘phoenix::ad_msg::LaneInfoCameraList::<unnamed enum>’) 526 | ad_msg::LaneInfoCameraList::MAX_LANE_BOUNDARY_LINE_NUM); | ^ In file included from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/string:40, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:8, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: ‘template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 246 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:246:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:526:61: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘phoenix::ad_msg::LaneInfoCameraList::<unnamed enum>’) 526 | ad_msg::LaneInfoCameraList::MAX_LANE_BOUNDARY_LINE_NUM); | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/local/include/google/protobuf/stubs/common.h:38, from /usr/local/include/google/protobuf/io/coded_stream.h:141, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:23, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: ‘template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)’ 3450 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3450:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:526:61: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 526 | ad_msg::LaneInfoCameraList::MAX_LANE_BOUNDARY_LINE_NUM); | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/local/include/google/protobuf/stubs/common.h:38, from /usr/local/include/google/protobuf/io/coded_stream.h:141, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:23, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: ‘template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)’ 3456 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3456:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:526:61: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 526 | ad_msg::LaneInfoCameraList::MAX_LANE_BOUNDARY_LINE_NUM); | ^ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:539:61: error: ‘LaneMarkType_LANE_MARK_TYPE_INVALID’ is not a member of ‘phoenix::msg::perception::lane::LaneBoundaryLineCamera’ 539 | case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_INVALID: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:542:61: error: ‘LaneMarkType_LANE_MARK_TYPE_UNKNOWN’ is not a member of ‘phoenix::msg::perception::lane::LaneBoundaryLineCamera’ 542 | case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_UNKNOWN: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:545:61: error: ‘LaneMarkType_LANE_MARK_TYPE_DASHED’ is not a member of ‘phoenix::msg::perception::lane::LaneBoundaryLineCamera’ 545 | case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_DASHED: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:548:61: error: ‘LaneMarkType_LANE_MARK_TYPE_SOLID’ is not a member of ‘phoenix::msg::perception::lane::LaneBoundaryLineCamera’ 548 | case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_SOLID: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:551:61: error: ‘LaneMarkType_LANE_MARK_TYPE_DOUBLE_LANE_MARK’ is not a member of ‘phoenix::msg::perception::lane::LaneBoundaryLineCamera’ 551 | case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_DOUBLE_LANE_MARK: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:554:61: error: ‘LaneMarkType_LANE_MARK_TYPE_BOTTS_DOTS’ is not a member of ‘phoenix::msg::perception::lane::LaneBoundaryLineCamera’ 554 | case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_BOTTS_DOTS: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:557:61: error: ‘LaneMarkType_LANE_MARK_TYPE_ROAD_EDGE’ is not a member of ‘phoenix::msg::perception::lane::LaneBoundaryLineCamera’ 557 | case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_ROAD_EDGE: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:560:61: error: ‘LaneMarkType_LANE_MARK_TYPE_DASHED_SOLID’ is not a member of ‘phoenix::msg::perception::lane::LaneBoundaryLineCamera’ 560 | case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_DASHED_SOLID: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:563:61: error: ‘LaneMarkType_LANE_MARK_TYPE_SOLID_DASHED’ is not a member of ‘phoenix::msg::perception::lane::LaneBoundaryLineCamera’ 563 | case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_SOLID_DASHED: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:566:61: error: ‘LaneMarkType_LANE_MARK_TYPE_DOUBLE_YELLOW’ is not a member of ‘phoenix::msg::perception::lane::LaneBoundaryLineCamera’ 566 | case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_DOUBLE_YELLOW: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:569:61: error: ‘LaneMarkType_LANE_MARK_TYPE_FISHBONE’ is not a member of ‘phoenix::msg::perception::lane::LaneBoundaryLineCamera’ 569 | case msg::perception::lane::LaneBoundaryLineCamera::LaneMarkType_LANE_MARK_TYPE_FISHBONE: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:581:60: error: no matching function for call to ‘min(int, phoenix::ad_msg::LaneBoundaryLineCamera::<unnamed enum>)’ 581 | ad_msg::LaneBoundaryLineCamera::MAX_CURVE_POINT_NUM); | ^ In file included from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/string:40, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:8, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: ‘template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)’ 198 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:198:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:581:60: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘phoenix::ad_msg::LaneBoundaryLineCamera::<unnamed enum>’) 581 | ad_msg::LaneBoundaryLineCamera::MAX_CURVE_POINT_NUM); | ^ In file included from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/string:40, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:8, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: ‘template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 246 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:246:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:581:60: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘phoenix::ad_msg::LaneBoundaryLineCamera::<unnamed enum>’) 581 | ad_msg::LaneBoundaryLineCamera::MAX_CURVE_POINT_NUM); | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/local/include/google/protobuf/stubs/common.h:38, from /usr/local/include/google/protobuf/io/coded_stream.h:141, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:23, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: ‘template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)’ 3450 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3450:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:581:60: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 581 | ad_msg::LaneBoundaryLineCamera::MAX_CURVE_POINT_NUM); | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/local/include/google/protobuf/stubs/common.h:38, from /usr/local/include/google/protobuf/io/coded_stream.h:141, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:23, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: ‘template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)’ 3456 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3456:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:581:60: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 581 | ad_msg::LaneBoundaryLineCamera::MAX_CURVE_POINT_NUM); | ^ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:598:59: error: no matching function for call to ‘min(int, phoenix::ad_msg::LaneInfoCameraList::<unnamed enum>)’ 598 | ad_msg::LaneInfoCameraList::MAX_LANE_CENTER_LINE_NUM); | ^ In file included from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/string:40, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:8, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: ‘template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)’ 198 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:198:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:598:59: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘phoenix::ad_msg::LaneInfoCameraList::<unnamed enum>’) 598 | ad_msg::LaneInfoCameraList::MAX_LANE_CENTER_LINE_NUM); | ^ In file included from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/string:40, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:8, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: ‘template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 246 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:246:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:598:59: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘phoenix::ad_msg::LaneInfoCameraList::<unnamed enum>’) 598 | ad_msg::LaneInfoCameraList::MAX_LANE_CENTER_LINE_NUM); | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/local/include/google/protobuf/stubs/common.h:38, from /usr/local/include/google/protobuf/io/coded_stream.h:141, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:23, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: ‘template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)’ 3450 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3450:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:598:59: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 598 | ad_msg::LaneInfoCameraList::MAX_LANE_CENTER_LINE_NUM); | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/local/include/google/protobuf/stubs/common.h:38, from /usr/local/include/google/protobuf/io/coded_stream.h:141, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:23, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: ‘template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)’ 3456 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3456:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:598:59: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 598 | ad_msg::LaneInfoCameraList::MAX_LANE_CENTER_LINE_NUM); | ^ /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:621:58: error: no matching function for call to ‘min(int, phoenix::ad_msg::LaneCenterLineCamera::<unnamed enum>)’ 621 | ad_msg::LaneCenterLineCamera::MAX_CURVE_POINT_NUM); | ^ In file included from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/string:40, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:8, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: ‘template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)’ 198 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:198:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:621:58: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘phoenix::ad_msg::LaneCenterLineCamera::<unnamed enum>’) 621 | ad_msg::LaneCenterLineCamera::MAX_CURVE_POINT_NUM); | ^ In file included from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/string:40, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:8, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: ‘template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 246 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algobase.h:246:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:621:58: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘phoenix::ad_msg::LaneCenterLineCamera::<unnamed enum>’) 621 | ad_msg::LaneCenterLineCamera::MAX_CURVE_POINT_NUM); | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/local/include/google/protobuf/stubs/common.h:38, from /usr/local/include/google/protobuf/io/coded_stream.h:141, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:23, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: ‘template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)’ 3450 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3450:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:621:58: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 621 | ad_msg::LaneCenterLineCamera::MAX_CURVE_POINT_NUM); | ^ In file included from /usr/include/c++/9/algorithm:62, from /usr/local/include/google/protobuf/stubs/common.h:38, from /usr/local/include/google/protobuf/io/coded_stream.h:141, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/gnss.pb.h:23, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.h:7, from /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:2: /usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: ‘template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)’ 3456 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/9/bits/stl_algo.h:3456:5: note: template argument deduction/substitution failed: /home/cobo/shared_dirs/shared/MPA_Planning/src/msg_series_c/parse_proto_msg.cc:621:58: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 621 | ad_msg::LaneCenterLineCamera::MAX_CURVE_POINT_NUM); | ^ make[2]: *** [CMakeFiles/planning.dir/build.make:1597: CMakeFiles/planning.dir/src/msg_series_c/parse_proto_msg.cc.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/planning.dir/all] Error 2
10-28
#define CATCH_CONFIG_MAIN #ifdef CATCH_CONFIG_MAIN #include "LSP/catch2/catch.hpp" #include <time.h> #include "ad_msg.h" #include "util.h" #include "parse_proto_msg.h" #include "utils/log.h" #include "utils/gps_tools.h" #include "CruPlanningAlg.h" #include <thread> // #include "Klog.h" ////////Log header files // #include "ara/log/log_com.h" // #include "LSP/EnhancedAssertion.h" #include "map_msg_apollo.pb.h" using std::chrono::high_resolution_clock; using std::chrono::milliseconds; uint32_t g_TrajCalculateTime; // 全局控制变量 std::atomic<bool> running{true}; std::once_flag init_flag; // 确保初始化只执行一次 namespace mpa { namespace cru_planning_algorithm { TEST_CASE("CruPlanning01", "[CruPlanning]") { LOG_INFO(5) << " CruPlanning01--------------------"; CruiseTrajPlanning planner; // 确保初始化只执行一次 std::call_once(init_flag, [&] { planner.cruiseTrajPlanningInit("../conf/Cru_Planning_Parameter.yaml"); std::cout << "Cruise planning initialized once\n"; }); // 创建三个不同周期的线程 std::thread t1([&planner] { while(running) { planner.updateUserClockUs(); std::this_thread::sleep_for(std::chrono::milliseconds(10)); } }); std::thread t2([&planner] { while(running) { planner.checkModuleStatus(); std::this_thread::sleep_for(std::chrono::milliseconds(50)); } }); std::thread t3([&planner] { while(running) { // 先执行所有接收函数(模拟数据接收) std::string file_name = "../conf/map_1030.txt"; // std::string file_name = "./conf/DGMMap_mult_lane_1101.txt"; phoenix::msg::map::MapMsg map_msg; bool read_map = phoenix::framework::GetProtoFromASCIIFile(file_name, map_msg.mutable_hdmap()); if(read_map) { LOG_INFO(5) << "Read map ok"; std::cout << "The map is: \n" << map_msg.hdmap().DebugString() << std::endl; } else { LOG_INFO(5) << "Read map fail"; } Int32_t map_msg_serialize_size = map_msg.ByteSize(); std::shared_ptr<Char_t> map_data_array(new Char_t[map_msg_serialize_size], std::default_delete<Char_t[]>()); if (!map_msg.SerializeToArray(map_data_array.get(), map_msg_serialize_size)) { LOG_ERR << "Failed to serialize Map message."; } planner.recvMapMessage(map_data_array.get(), map_msg_serialize_size); phoenix::ad_msg::Chassis chassis_; chassis_.driving_mode = phoenix::ad_msg::VEH_DRIVING_MODE_ROBOTIC; chassis_.eps_status = phoenix::ad_msg::VEH_EPS_STATUS_ROBOTIC; chassis_.steering_wheel_angle_valid = 1; chassis_.steering_wheel_angle = 0; chassis_.v_valid = 1; chassis_.v = 30.0F/3.6F; chassis_.yaw_rate_valid = 1; chassis_.yaw_rate= 0; chassis_.gear = phoenix::ad_msg::VEH_GEAR_D; // Update message head chassis_.msg_head.valid = true; chassis_.msg_head.UpdateSequenceNum(); chassis_.msg_head.timestamp = phoenix::common::GetClockNowMs(); phoenix::msg::control::Chassis chassis_proto; phoenix::msg::ParseProtoMsg pase_proto; pase_proto.EncodeChassisMessage(chassis_,&chassis_proto); Int32_t chassis_proto_serialize_size = chassis_proto.ByteSize(); std::shared_ptr<Char_t> chassis_data_array(new Char_t[chassis_proto_serialize_size], std::default_delete<Char_t[]>()); if (!chassis_proto.SerializeToArray(chassis_data_array.get(), chassis_proto_serialize_size)) { LOG_ERR << "Failed to serialize chassis message."; } planner.recvChassisMessage(chassis_data_array.get(), chassis_proto_serialize_size); phoenix::ad_msg::Gnss gnss_; gnss_.msg_head.valid = true; gnss_.x_utm = 255877.829200091; gnss_.y_utm = 3371818.6588779385; // gnss_.x_utm = 255873.40718475843; // gnss_.y_utm = 3371819.0246172794; gnss_.z_utm = 0.0; gnss_.heading_utm = 0.0; gnss_.gnss_status = 3 ; gnss_.utm_status = 3 ; phoenix::msg::localization::Gnss gnss_proto; pase_proto.EncodeGnssMessage(gnss_,&gnss_proto); Int32_t gnss_proto_serialize_size = gnss_proto.ByteSize(); std::shared_ptr<Char_t> gnss_data_array(new Char_t[gnss_proto_serialize_size], std::default_delete<Char_t[]>()); if (!gnss_proto.SerializeToArray(gnss_data_array.get(), gnss_proto_serialize_size)) { LOG_ERR << "Failed to serialize gnss message."; } planner.recvGnssMessage(gnss_data_array.get(), gnss_proto_serialize_size); planner.recvImuMessage(nullptr, 0); phoenix::ad_msg::ObstacleList obstacle_list_; obstacle_list_.obstacles_els_num = 1; Float32_t obj_v = -10.0F / 3.6F; for (Int32_t i = 0; i < obstacle_list_.obstacles_els_num; ++i) { phoenix::ad_msg::Obstacle &obj = obstacle_list_.obstacles[i]; obj.id = 0; obj.x = 60.0F; //-0.5F * obj_v; obj.y = 0.0F; //-3.6F; obj.obb.x = obj.x + 1.0F; obj.obb.y = obj.y; obj.obb.heading = phoenix::common::com_deg2rad(0.0F); obj.obb.half_length = 2.0F; obj.obb.half_width = 1.0F; obj.type = phoenix::ad_msg::OBJ_TYPE_PASSENGER_VEHICLE; obj.dynamic = false; obj.confidence = 90; obj.perception_type = phoenix::ad_msg::OBJ_PRCP_TYPE_FUSED; obj.v = obj_v; obj.v_x = obj_v; obj.v_y = 0.0F; } // Update message head obstacle_list_.msg_head.valid = true; obstacle_list_.msg_head.UpdateSequenceNum(); obstacle_list_.msg_head.timestamp = phoenix::common::GetClockNowMs(); phoenix::msg::perception::ObstacleList obstacle_list_proto; pase_proto.EncodeObstacleListMessage(obstacle_list_,&obstacle_list_proto); Int32_t obstacle_list_proto_serialize_size = obstacle_list_proto.ByteSize(); std::shared_ptr<Char_t> obstacle_list_data_array(new Char_t[obstacle_list_proto_serialize_size], std::default_delete<Char_t[]>()); if (!obstacle_list_proto.SerializeToArray(obstacle_list_data_array.get(), obstacle_list_proto_serialize_size)) { LOG_ERR << "Failed to serialize obstacle list message."; } planner.recvPerceptionMessage(obstacle_list_data_array.get(), obstacle_list_proto_serialize_size); planner.recvLaneInfoCameraListMessage(nullptr, 0); phoenix::ad_msg::ParkingSystemStatus parking_system_status_; parking_system_status_.current_mode = phoenix::ad_msg::ParkingMode::CRUISE_MODE; phoenix::msg::parking::ParkingSystemStatus parking_system_status_proto; pase_proto.EncodeParkSystemStatusMessage(parking_system_status_,&parking_system_status_proto); Int32_t parking_system_status_proto_serialize_size = parking_system_status_proto.ByteSize(); std::shared_ptr<Char_t> parking_system_status_data_array(new Char_t[parking_system_status_proto_serialize_size], std::default_delete<Char_t[]>()); if (!parking_system_status_proto.SerializeToArray(parking_system_status_data_array.get(), parking_system_status_proto_serialize_size)) { LOG_ERR << "Failed to serialize parking system status message."; } planner.recvParkSystemStatusMessage(parking_system_status_data_array.get(), parking_system_status_proto_serialize_size); // 然后执行规划输出 const char* output_data; planner.cruiseTrajPlanningOutput(&output_data); // // 最后发送HMI消息 // planner.sendHmiMsg(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); } }); // 主线程等待10秒 std::cout << "Running for 10 seconds...\n"; std::this_thread::sleep_for(std::chrono::seconds(10)); running = false; // 等待所有线程结束 t1.join(); t2.join(); t3.join(); std::cout << "All threads stopped\n"; } } } #endif /usr/bin/ld: CMakeFiles/planning.dir/CMakeFiles/3.16.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o: in function `main': CMakeCXXCompilerId.cpp:(.text+0x0): multiple definition of `main'; CMakeFiles/planning.dir/CruPlanningAlgTest.cpp.o:CruPlanningAlgTest.cpp:(.text+0x2b47d): first defined here collect2: error: ld returned 1 exit status make[2]: *** [CMakeFiles/planning.dir/build.make:2679: /home/cobo/shared_dirs/shared/MPA_Planning/planning] Error 1 make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/planning.dir/all] Error 2 编译问题是什么?
11-19
syntax = "proto2"; package phoenix.msg.perception.lane; message MsgHead { optional uint32 seq = 1; optional uint64 timestamp = 2; } // 车道边线形点(摄像头识别) message LaneBoundaryCurvePoint { optional bool fake = 1 [default = false]; // 是否为真实识别点,真实的填false反之填true optional float x = 2; // 形点坐标x (Float32) optional float y = 3; // 形点坐标y (Float32) } // 车道边线信息(摄像头识别) message LaneBoundaryLineCamera { // 车道线的类型定义 enum LaneMarkType { LANE_MARK_TYPE_INVALID = 0; // 无效车道标线类型 LANE_MARK_TYPE_UNKNOWN = 1; // 未知车道标线类型 LANE_MARK_TYPE_DASHED = 2; // 虚线车道标线 LANE_MARK_TYPE_SOLID = 3; // 实线车道标线 LANE_MARK_TYPE_DOUBLE_LANE_MARK = 4; // 双车道标线 LANE_MARK_TYPE_BOTTS_DOTS = 5; // 凸起路标(波特点) LANE_MARK_TYPE_ROAD_EDGE = 6; // 道路边缘标线 LANE_MARK_TYPE_DASHED_SOLID = 7; // 虚线-实线组合标线 LANE_MARK_TYPE_SOLID_DASHED = 8; // 实线-虚线组合标线 LANE_MARK_TYPE_DOUBLE_YELLOW = 9; // 双黄线标线 LANE_MARK_TYPE_FISHBONE = 10; // 鱼骨线(锯齿状导流线) }; optional int32 id = 1; // 车道编号(左正右负) optional LaneMarkType type = 2; // 边线类型 repeated LaneBoundaryCurvePoint curve = 3 ; // 形点序列 max_count = 500 } // 车道中心线形点(摄像头识别) message LaneCenterCurvePoint { optional float x = 1; // 形点坐标x optional float y = 2; // 形点坐标y optional float left_width = 3; // 中心线到左边线宽度,单位米 optional float right_width = 4; // 中心线到右边线宽度,单位米 } // 车道中心线信息(摄像头识别) message LaneCenterLineCamera { optional int32 quality = 1; // 质量等级 (0-3),3 - very good, 2 - not good, 1 - bad, 0 - invalid,默认填3 optional int32 age = 2; // 历史存在次数,随便填 optional float forward_len = 3; // 从车辆当前位置开始,车道线的前向长度(m) optional int32 id = 4; // 车道编号(左正右负) optional int32 left_boundary_index = 5; // 左边线索引 optional int32 right_boundary_index = 6; // 右边线索引 repeated LaneCenterCurvePoint curve = 7; // 形点序列 max_count = 500 } // 摄像头识别的车道线列表 message LaneInfoCameraList { optional MsgHead msg_head = 1; // 消息头 (需预先定义) optional int32 quality = 2; // 整体识别质量 optional float forward_len = 3; // 前向长度(m) optional float left_width = 4; // 当前位置左车道宽(m) optional float right_width = 5; // 当前位置右车道宽(m) repeated LaneBoundaryLineCamera boundary_lines = 6 ; // 车道边线 max_count = 6 repeated LaneCenterLineCamera center_lines = 7 ; // 车道中心线 max_count = 3 } // 警告: // 此文件是自动生成的,请勿手动修改,避免产生消息定义及序列化函数不一致、以及手动修改被自动生成覆盖的问题。 // 当需要修改消息定义时,请修改对应的消息定义文件,并重新生成代码。 #ifndef PHOENIX_AD_MSG_MSG_LANE_CAMERA_H_ #define PHOENIX_AD_MSG_MSG_LANE_CAMERA_H_ #include "utils/macros.h" #include "utils/com_utils.h" #include "msg_common.h" namespace phoenix { namespace ad_msg { // 车道线信息(摄像头识别的) struct LaneMarkCamera { // 车道线的类型定义 enum LaneMarkType { LANE_MARK_TYPE_INVALID = 0, LANE_MARK_TYPE_UNKNOWN, LANE_MARK_TYPE_DASHED, LANE_MARK_TYPE_SOLID, LANE_MARK_TYPE_DOUBLE_LANE_MARK, LANE_MARK_TYPE_BOTTS_DOTS, LANE_MARK_TYPE_ROAD_EDGE, LANE_MARK_TYPE_DASHED_SOLID, LANE_MARK_TYPE_SOLID_DASHED, LANE_MARK_TYPE_DOUBLE_YELLOW, LANE_MARK_TYPE_FISHBONE, }; // 车道编号,左边车道线为正值,右边车道线为负数 Int32_t id; // 车道线类型 Int8_t lane_mark_type; // 车道线识别的质量 Int32_t quality; // 车道线的纵向有效范围字段中的值是否有效 Int8_t view_range_valid; // 车道线的宽度 Float32_t mark_width; // 车道线的纵向有效范围的起始位置 Float32_t view_range_start; // 车道线的纵向有效范围的结束位置 Float32_t view_range_end; // 曲线参数c0 Float64_t c0; // 曲线参数c1 Float64_t c1; // 曲线参数c2 Float64_t c2; // 曲线参数c3 Float64_t c3; // 曲线参数c0(uint16) Uint16_t u16_c0; // 曲线参数c1(uint16) Uint16_t u16_c1; // 曲线参数c2(uint16) Uint16_t u16_c2; // 曲线参数c3(uint16) Uint16_t u16_c3; /** * @brief 构造函数 */ LaneMarkCamera() { Clear(); } /** * @brief 清除内部数据 */ void Clear() { id = 0; lane_mark_type = LANE_MARK_TYPE_INVALID; quality = 0; view_range_valid = 0; mark_width = 0.0F; view_range_start = 0.0F; view_range_end = 0.0F; c0 = 0.0; c1 = 0.0; c2 = 0.0; c3 = 0.0; u16_c0 = 0U; u16_c1 = 0U; u16_c2 = 0U; u16_c3 = 0U; } }; // 感知识别的车道线列表 struct LaneMarkCameraList { // 列表中最大车道线的数量 enum { MAX_LANE_MARK_NUM = 6 }; // 消息头 MsgHead msg_head; // 感知识别的车道线列表 Int32_t lane_marks_els_num; LaneMarkCamera lane_marks[MAX_LANE_MARK_NUM]; /** * @brief 构造函数 */ LaneMarkCameraList() { Clear(); } /** * @brief 清除内部数据 */ void Clear() { msg_head.Clear(); lane_marks_els_num = 0; for (Int32_t i = 0; i < MAX_LANE_MARK_NUM; ++i) { lane_marks[i].Clear(); } } }; // 车道边线信息(摄像头识别的) struct LaneBoundaryLineCamera { // 车道线中点的最大数量 enum { MAX_CURVE_POINT_NUM = 500 }; // 车道线形点 struct CurvePoint { // 是否为真实识别点 Int8_t fake; // 形点坐标x Float32_t x; // 形点坐标y Float32_t y; /** * @brief 构造函数 */ CurvePoint() { Clear(); } /** * @brief 清除内部数据 */ void Clear() { fake = 0; x = 0.0F; y = 0.0F; } }; // 车道编号,左边车道线为正值,右边车道线为负数 Int32_t id; // 边线类型 Int32_t type; // 车道线 Int32_t curve_els_num; CurvePoint curve[MAX_CURVE_POINT_NUM]; /** * @brief 构造函数 */ LaneBoundaryLineCamera() { Clear(); } /** * @brief 清除内部数据 */ void Clear() { id = 0; type = 0; curve_els_num = 0; for (Int32_t i = 0; i < MAX_CURVE_POINT_NUM; ++i) { curve[i].Clear(); } } }; // 车道中心线信息(摄像头识别的) struct LaneCenterLineCamera { // 车道线中点的最大数量 enum { MAX_CURVE_POINT_NUM = 500 }; // 车道线形点 struct CurvePoint { // 形点坐标x Float32_t x; // 形点坐标y Float32_t y; // 车道中心线到左边线的宽度 Float32_t left_width; // 车道中心线到右边线的宽度 Float32_t right_width; /** * @brief 构造函数 */ CurvePoint() { Clear(); } /** * @brief 清除内部数据 */ void Clear() { x = 0.0F; y = 0.0F; left_width = 0.0F; right_width = 0.0F; } }; // 车道线识别的质量, 3 - very good, 2 - not good, 1 - bad, 0 - invalid Int8_t quality; // 历史数据存在的次数 Int32_t age; // 从车辆当前位置开始,车道线的前向长度 Float32_t forward_len; // 车道中心线编号,左边车道中心线为正值,右边车道中心线为负数 Int32_t id; // 车道左边线的索引 Int32_t left_boundary_index; // 车道右边线的索引 Int32_t right_boundary_index; // 车道中心线 Int32_t curve_els_num; CurvePoint curve[MAX_CURVE_POINT_NUM]; /** * @brief 构造函数 */ LaneCenterLineCamera() { Clear(); } /** * @brief 清除内部数据 */ void Clear() { quality = 0; age = 0; forward_len = 0.0F; id = 0; left_boundary_index = 0; right_boundary_index = 0; curve_els_num = 0; for (Int32_t i = 0; i < MAX_CURVE_POINT_NUM; ++i) { curve[i].Clear(); } } }; // Camera识别的车道线列表 struct LaneInfoCameraList { // 列表中最大车道线的数量 enum { MAX_LANE_BOUNDARY_LINE_NUM = 6 }; // 列表中最大车道中心线的数量 enum { MAX_LANE_CENTER_LINE_NUM = 3 }; // 消息头 MsgHead msg_head; // 车道线识别的质量 Int8_t quality; // 从车辆当前位置开始,车道线的前向长度 Float32_t forward_len; // 车辆当前位置左边车道宽度 Float32_t left_width; // 车辆当前位置右边车道宽度 Float32_t right_width; // 感知识别的车道线列表 Int32_t boundary_lines_els_num; LaneBoundaryLineCamera boundary_lines[MAX_LANE_BOUNDARY_LINE_NUM]; // 车道中心线列表 Int32_t center_lines_els_num; LaneCenterLineCamera center_lines[MAX_LANE_CENTER_LINE_NUM]; /** * @brief 构造函数 */ LaneInfoCameraList() { Clear(); } /** * @brief 清除内部数据 */ void Clear() { msg_head.Clear(); quality = 0; forward_len = 0.0F; left_width = 0.0F; right_width = 0.0F; boundary_lines_els_num = 0; for (Int32_t i = 0; i < MAX_LANE_BOUNDARY_LINE_NUM; ++i) { boundary_lines[i].Clear(); } center_lines_els_num = 0; for (Int32_t i = 0; i < MAX_LANE_CENTER_LINE_NUM; ++i) { center_lines[i].Clear(); } } /** * @brief 根据ID查找车道中心线 * @param[in] id 车道中心线ID * @return 车道中心的索引 (-1 ~ 没有找到) */ Int32_t FindCenterLineById(const Int32_t id) const { for (Int32_t i = 0; i < center_lines_els_num; ++i) { if (id == center_lines[i].id) { return (i); } } return (-1); } }; } // namespace phoenix } // namespace ad_msg #endif // PHOENIX_AD_MSG_MSG_LANE_CAMERA_H_ 编码实现bool ParseProtoMsg::DecodeLaneInfoListMessage( msg::perception::LaneInfoCameraList& proto_in, ad_msg::LaneInfoCameraList *data_out)
10-25
#include <reg52.h> #include <intrins.h> sbit DATA_PIN = P1^0; sbit CLOCK_PIN = P1^1; sbit LATCH_PIN = P1^2; sbit KEY_LEFT = P3^1; sbit KEY_RIGHT = P3^4; sbit KEY_ROT = P3^5; sbit KEY_DOWN = P3^6; #define MAP_WIDTH 8 #define MAP_HEIGHT 8 #define FALL_DELAY 500 unsigned char game_map[MAP_HEIGHT] = {0}; unsigned char display_buffer[MAP_HEIGHT] = {0}; struct { unsigned char type; unsigned char rotation; char x; char y; } current_block; unsigned int fall_timer = 0; unsigned int game_speed = FALL_DELAY; bit game_over = 0; unsigned int score = 0; unsigned char code SHAPES[7][4][4] = { {{0x0F, 0x00, 0x00, 0x00}, {0x04, 0x04, 0x04, 0x04}, {0x0F, 0x00, 0x00, 0x00}, {0x04, 0x04, 0x04, 0x04}}, {{0x0E, 0x04, 0x00, 0x00}, {0x04, 0x06, 0x04, 0x00}, {0x04, 0x0E, 0x00, 0x00}, {0x04, 0x0C, 0x04, 0x00}}, {{0x08, 0x0C, 0x00, 0x00}, {0x06, 0x04, 0x04, 0x00}, {0x0C, 0x08, 0x00, 0x00}, {0x04, 0x04, 0x06, 0x00}}, {{0x04, 0x0C, 0x00, 0x00}, {0x04, 0x04, 0x06, 0x00}, {0x0C, 0x04, 0x00, 0x00}, {0x06, 0x04, 0x04, 0x00}}, {{0x06, 0x06, 0x00, 0x00}, {0x06, 0x06, 0x00, 0x00}, {0x06, 0x06, 0x00, 0x00}, {0x06, 0x06, 0x00, 0x00}}, {{0x06, 0x0C, 0x00, 0x00}, {0x04, 0x06, 0x02, 0x00}, {0x06, 0x0C, 0x00, 0x00}, {0x04, 0x06, 0x02, 0x00}}, {{0x0C, 0x06, 0x00, 0x00}, {0x02, 0x06, 0x04, 0x00}, {0x0C, 0x06, 0x00, 0x00}, {0x02, 0x06, 0x04, 0x00}} }; void send_byte(unsigned char dat) { unsigned char i; for(i=0; i<8; i++) { DATA_PIN = dat & 0x80; CLOCK_PIN = 1; _nop_();_nop_(); CLOCK_PIN = 0; dat <<= 1; } } void refresh_display() { static unsigned char row = 0; LATCH_PIN = 0; send_byte(~display_buffer[row]); send_byte(1 << row); LATCH_PIN = 1; row = (row + 1) % MAP_HEIGHT; } void timer1_init() { TMOD = 0x11; TH1 = 0xFC; TL1 = 0x18; ET1 = 1; TR1 = 1; EA = 1; } bit check_collision() { unsigned char i, j; unsigned char shape_data; for(i=0; i<4; i++) { if(current_block.y + i >= MAP_HEIGHT) return 1; shape_data = SHAPES[current_block.type][current_block.rotation][i]; for(j=0; j<4; j++) { if(shape_data & (0x08 >> j)) { int map_x = current_block.x + j; int map_y = current_block.y + i; if(map_x < 0 || map_x >= MAP_WIDTH) return 1; if(map_y >= MAP_HEIGHT) return 1; if(map_y >= 0 && (game_map[map_y] & (0x80 >> map_x))) return 1; } } } return 0; } void new_block() { current_block.type = rand() % 7; current_block.rotation = 0; current_block.x = 3; current_block.y = 0; if(check_collision()) { game_over = 1; } } void fix_block() { unsigned char i, j,shape_data; for(i=0; i<4; i++) { if(current_block.y + i < 0) continue; shape_data = SHAPES[current_block.type][current_block.rotation][i]; for(j=0; j<4; j++) { if(shape_data & (0x08 >> j)) { int map_x = current_block.x + j; int map_y = current_block.y + i; if(map_x >=0 && map_x < MAP_WIDTH && map_y >=0 && map_y < MAP_HEIGHT) { game_map[map_y] |= (0x80 >> map_x); } } } } } void clear_lines() { unsigned char y, y2,x; bit full_line; for(y=0; y<MAP_HEIGHT; y++) { full_line = 1; for( x=0; x<MAP_WIDTH; x++) { if(!(game_map[y] & (0x80 >> x))) { full_line = 0; break; } } if(full_line) { score += 10; if(game_speed > 100) game_speed -= 10; for(y2=y; y2>0; y2--) { game_map[y2] = game_map[y2-1]; } game_map[0] = 0; } } } void update_display() { unsigned char i, j,x,y,shape_data; for(i=0; i<MAP_HEIGHT; i++) { display_buffer[i] = game_map[i]; } for(i=0; i<4; i++) { y = current_block.y + i; if(y >= MAP_HEIGHT || y < 0) continue; shape_data = SHAPES[current_block.type][current_block.rotation][i]; for(j=0; j<4; j++) { x = current_block.x + j; if(x >=0 && x < MAP_WIDTH && (shape_data & (0x08 >> j))) { display_buffer[y] |= (0x80 >> x); } } } } void move_block(char dx, char dy) { current_block.x += dx; current_block.y += dy; if(check_collision()) { current_block.x -= dx; current_block.y -= dy; if(dy > 0) { fix_block(); clear_lines(); new_block(); } } } void rotate_block() { unsigned char old_rotation; old_rotation = current_block.rotation; current_block.rotation = (current_block.rotation + 1) % 4; if(check_collision()) { current_block.rotation = old_rotation; } } void scan_keys() { static bit key_flag = 0; if(!key_flag) { if(!KEY_LEFT) { move_block(-1, 0); key_flag = 1; } else if(!KEY_RIGHT) { move_block(1, 0); key_flag = 1; } else if(!KEY_DOWN) { move_block(0, 1); key_flag = 1; } else if(!KEY_ROT) { rotate_block(); key_flag = 1; } } else { if(KEY_LEFT && KEY_RIGHT && KEY_DOWN && KEY_ROT) { key_flag = 0; } } } void els() { unsigned char i; timer1_init(); new_block(); scan_keys(); while(1) { if(game_over) { for( i=0; i<MAP_HEIGHT; i++) { display_buffer[i] = (i % 2) ? 0xFF : 0x00; } continue; } if(fall_timer >= game_speed) { move_block(0, 1); fall_timer = 0; } scan_keys(); update_display(); } } void timer1_isr() interrupt 1 { TH1 = 0xFC; TL1 = 0x18; refresh_display(); fall_timer++; }程序一直在扫描矩阵
最新发布
11-26
// 规划的结果 struct PlanningResult { // 目标轨迹中点的最大数量 enum { MAX_TRAJECTORY_POINT_NUM = 16 }; // 轨迹方向 enum TrjDirection { TRJ_DIRECTION_FORWARD = 0, TRJ_DIRECTION_BACKWARD, }; // 目标轨迹 struct TarTrj { // 车辆位置点 struct Pos { // x坐标 Float32_t x; // y坐标 Float32_t y; // 航向角, Range: (-pi, pi rad) Float32_t h; // 曲率 Float32_t c; // 相对于参考线的路径长 Float32_t s; // 相对于参考线的横向偏移 Float32_t l; /** * @brief 构造函数 */ Pos() { Clear(); } /** * @brief 清除内部数据 */ void Clear() { x = 0.0F; y = 0.0F; h = 0.0F; c = 0.0F; s = 0.0F; l = 0.0F; } }; // 横向误差 struct LatErr { // 横向误差采样点 struct SamplePoint { // 横向误差 Float32_t lat_err; // 横向误差变化速率 Float32_t lat_err_chg_rate; // 角度误差 Range: (-pi, pi rad) Float32_t yaw_err; // 角度误差变化速率 Float32_t yaw_err_chg_rate; /** * @brief 构造函数 */ SamplePoint() { Clear(); } /** * @brief 清除内部数据 */ void Clear() { lat_err = 0.0F; lat_err_chg_rate = 0.0F; yaw_err = 0.0F; yaw_err_chg_rate = 0.0F; } }; // 目标轨迹是否处于避障或变道状态 Int8_t moving_flag; // 横向误差采样点 SamplePoint samples[2]; /** * @brief 构造函数 */ LatErr() { Clear(); } /** * @brief 清除内部数据 */ void Clear() { moving_flag = 0; for (Int32_t i = 0; i < 2; ++i) { samples[i].Clear(); } } }; // 目标轨迹点 struct TrjPoint { // 目标轨迹点x坐标 Float32_t x; // 目标轨迹点y坐标 Float32_t y; // 航向角, Range: (-pi, pi rad) Float32_t h; // 曲率 Float32_t c; // 沿着轨迹的长度 Float32_t s; /** * @brief 构造函数 */ TrjPoint() { Clear(); } /** * @brief 清除内部数据 */ void Clear() { x = 0.0F; y = 0.0F; h = 0.0F; c = 0.0F; s = 0.0F; } }; // 目标轨迹的时间戳,用于时间同步 Int64_t timestamp; // 当前车辆位置 Pos curr_pos; // 先导点位置 Pos leading_pos; // 横向误差 LatErr lat_err; // 轨迹的方向, 0 - 前进, 1 - 后退 Int8_t trj_direction; // 轨迹点 Int32_t points_els_num; TrjPoint points[MAX_TRAJECTORY_POINT_NUM]; /** * @brief 构造函数 */ TarTrj() { Clear(); } /** * @brief 清除内部数据 */ void Clear() { timestamp = 0; curr_pos.Clear(); leading_pos.Clear(); lat_err.Clear(); trj_direction = 0; points_els_num = 0; for (Int32_t i = 0; i < MAX_TRAJECTORY_POINT_NUM; ++i) { points[i].Clear(); } } }; // 消息头 MsgHead msg_head; // 规划状态 Uint32_t planning_status[4]; // 驾驶模式请求 Int8_t tar_driving_mode; // 使能转向系统 Int8_t enable_eps; // 使能油门系统 Int8_t enable_throttle_sys; // 使能制动系统 Int8_t enable_ebs; // 保持当前方向盘角度不变 Int8_t hold_steering_wheel; // 方向盘转速限制 (rad/s) Float32_t steering_wheel_speed; // 释放油门 Int8_t release_throttle; // 制动紧迫度 Int8_t brake_emergency; // 档位请求 Int8_t tar_gear; // 转向指示灯请求 Int8_t tar_turn_lamp; // 制动灯请求 Int8_t tar_brake_lamp; // 速度请求 Float32_t tar_v; // 加速度请求 Float32_t tar_a; // 目标轨迹 TarTrj tar_trj; /** * @brief 构造函数 */ PlanningResult() { Clear(); } /** * @brief 清除内部数据 */ void Clear() { msg_head.Clear(); common::com_memset(&planning_status[0], 0, sizeof(planning_status)); tar_driving_mode = VEH_DRIVING_MODE_INVALID; enable_eps = 0; enable_throttle_sys = 0; enable_ebs = 0; hold_steering_wheel = 0; steering_wheel_speed = 0.0F; release_throttle = 0; brake_emergency = 0; tar_gear = VEH_GEAR_INVALID; tar_turn_lamp = VEH_TURN_LAMP_INVALID; tar_brake_lamp = VEH_LAMP_INVALID; tar_v = 0.0F; tar_a = 0.0F; tar_trj.Clear(); } }; /** * @brief target trajectory status */ enum class TarTrajectoryStatus { INVALID = 0, CRUISING, BYPASSING }; /** * @brief 规划状态字 */ enum class PlanStatus : uint8_t { PLANNING_OK = 0, /** <规划成功 */ INIT_FAILED = 1, /** <初始化失败 */ PLANNING_FAILED = 2, /** <规划失败 */ PLANNING_FINISH = 3, /** <规划完成 */ PLANNING_NOT_UPDATE = 4, /** <规划轨迹不更新 */ PLANNING_BLOCKING = 5, /** <规划阻塞状态 */ }; /** * @brief紧急制动状态 */ enum class EmergencyStatesStop : uint8_t { IDLE = 0, ///**<IdleNo Braking */ COMFORTABLE = 1, ///**<Comfortable */ EMERGENCY = 2, ///**<Emergency */ RESERVED = 3, ///**<Reserved */ }; /** * @brief巡航规划算法输出 */ struct PlanningOutPut { uint32_t point_num; /**< 轨迹点个数 */ uint32_t seg_num; /**< 轨迹段数 */ uint32_t seg_start_pos[20]; /**< 每段轨迹起点在总轨迹的索引 */ uint32_t seg_end_pos[20]; /**< 每段轨迹终点在总轨迹的索引 */ float x[MAX_CRUISE_PLANNING_POINT]; /**< 轨迹点坐标x值,单位为米 */ float y[MAX_CRUISE_PLANNING_POINT]; /**< 轨迹点坐标x值,单位为米 */ float z[MAX_CRUISE_PLANNING_POINT]; /**< 轨迹点坐标z值,单位为米 */ float pitch[MAX_CRUISE_PLANNING_POINT]; /**< 轨迹点俯仰角的值,单位为弧度 */ float roll[MAX_CRUISE_PLANNING_POINT]; /**< 轨迹点横滚角的值,单位为弧度 */ float yaw[MAX_CRUISE_PLANNING_POINT]; /**< 轨迹点航向角的值,单位为弧度 */ float kappa[MAX_CRUISE_PLANNING_POINT]; /**< 轨迹点曲率的值 */ float dir[MAX_CRUISE_PLANNING_POINT]; /**< 轨迹点方向的值 */ float speed[MAX_CRUISE_PLANNING_POINT]; /**< 轨迹点速度 */ float a[MAX_CRUISE_PLANNING_POINT]; /**<轨迹点加速度 */ float s[MAX_CRUISE_PLANNING_POINT]; /**<轨迹点累计位移 */ PlanStatus planning_status; /**< 规划状态 */ TarTrajectoryStatus tar_trajectory_status; /**< target trajectory status */ EmergencyStatesStop emergency_states; ///< 紧急制动状态 }; void getPlanningOut(phoenix::ad_msg::PlanningResult &_plan_result, phoenix::ad_msg::PlanningOutPut &_plan_out);C++实现getPlanningOut
11-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值