提交 ae6bb1f7 编写于 作者: D Dong Li 提交者: lianglia-apollo

remove ErrorCode in planning (#50)

fix some style problems
上级 4712b248
......@@ -29,14 +29,7 @@ cc_library(
],
deps = [
"//modules/common/math",
"//modules/planning/common:planning_error_code",
],
)
cc_library(
name = "planning_error_code",
hdrs = [
"planning_error.h",
"//modules/common/proto:error_code_proto",
],
)
......
......@@ -26,16 +26,11 @@ namespace apollo {
namespace planning {
LogicNode::LogicNode(const std::size_t node_id, const std::string &lane_id)
: _node_id(node_id), _lane_id(lane_id) {
}
: _node_id(node_id), _lane_id(lane_id) {}
std::size_t LogicNode::node_id() const {
return _node_id;
}
std::size_t LogicNode::node_id() const { return _node_id; }
const std::string &LogicNode::lane_id() const {
return _lane_id;
}
const std::string &LogicNode::lane_id() const { return _lane_id; }
const std::unordered_set<std::string> &LogicNode::lane_name() const {
return _lane_name;
......@@ -50,15 +45,15 @@ void LogicNode::connect(const LogicNode &node) {
_edge[node.lane_id()] = node.node_id();
}
ErrorCode LogicNode::get_next_node(const std::string &lane_id,
std::size_t *const node_id) {
common::ErrorCode LogicNode::get_next_node(const std::string &lane_id,
std::size_t *const node_id) {
CHECK_NOTNULL(node_id);
*node_id = 0;
if (_edge.find(lane_id) == _edge.end()) {
return ErrorCode::PLANNING_ERROR_NOT_FOUND;
return common::ErrorCode::PLANNING_ERROR;
}
*node_id = _edge[lane_id];
return ErrorCode::PLANNING_OK;
return common::ErrorCode::OK;
}
} // namespace planning
......
......@@ -18,15 +18,15 @@
* @file logic_node.h
**/
#ifndef MODULES_PLANNING_COMMON_LOGIC_NODE_H
#define MODULES_PLANNING_COMMON_LOGIC_NODE_H
#ifndef MODULES_PLANNING_COMMON_LOGIC_NODE_H_
#define MODULES_PLANNING_COMMON_LOGIC_NODE_H_
#include <memory>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include "modules/planning/common/planning_error.h"
#include "modules/common/proto/error_code.pb.h"
namespace apollo {
namespace planning {
......@@ -39,8 +39,10 @@ class LogicNode {
const std::unordered_set<std::string> &lane_name() const;
void connect(const LogicNode &node);
void add_lane_name(const std::string &lane_name);
ErrorCode get_next_node(const std::string &lane_id,
std::size_t *const node_id);
common::ErrorCode get_next_node(const std::string &lane_id,
std::size_t *const node_id);
void f() {}
private:
std::size_t _node_id;
std::string _lane_id;
......@@ -51,4 +53,4 @@ class LogicNode {
} // namespace planning
} // namespace apollo
#endif // MODULES_PLANNING_COMMON_LOGIC_NODE_H
#endif // MODULES_PLANNING_COMMON_LOGIC_NODE_H_
......@@ -18,8 +18,8 @@
* @file logic_point.h
**/
#ifndef MODULES_PLANNING_COMMON_LOGIC_POINT_H
#define MODULES_PLANNING_COMMON_LOGIC_POINT_H
#ifndef MODULES_PLANNING_COMMON_LOGIC_POINT_H_
#define MODULES_PLANNING_COMMON_LOGIC_POINT_H_
#include <string>
#include "modules/common/math/vec2d.h"
......@@ -54,4 +54,4 @@ class LogicPoint : public ::apollo::common::math::Vec2d {
} // namespace planning
} // namespace apollo
#endif // MODULES_PLANNING_COMMON_LOGIC_POINT_H
#endif // MODULES_PLANNING_COMMON_LOGIC_POINT_H_
/******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file planning_error.h
**/
#ifndef MODULES_PLANNING_COMMON_PLANNING_ERROR_H
#define MODULES_PLANNING_COMMON_PLANNING_ERROR_H
namespace apollo {
namespace planning {
enum class ErrorCode {
PLANNING_SKIP = 1,
PLANNING_OK = 0,
PLANNING_ERROR_NOT_FOUND = -1,
PLANNING_ERROR_OUT_OF_INDEX = -2,
PLANNING_ERROR_SELF_LOOP = -3,
PLANNING_ERROR_DUPLICATE = -4,
PLANNING_ERROR_NULL_POINTER = -5,
PLANNING_ERROR_NAN = -6,
PLANNING_ERROR_TIMEOUT = -7,
PLANNING_ERROR_FAILED = -8,
};
} // namespace planning
} // namespace apollo
#endif // MODULES_PLANNING_COMMON_PLANNING_ERROR_H
......@@ -17,8 +17,8 @@
/**
* @file speed_data.h
**/
#ifndef MODULES_PLANNING_COMMON_SPEED_SPEED_DATA_H
#define MODULES_PLANNING_COMMON_SPEED_SPEED_DATA_H
#ifndef MODULES_PLANNING_COMMON_SPEED_SPEED_DATA_H_
#define MODULES_PLANNING_COMMON_SPEED_SPEED_DATA_H_
#include <vector>
......@@ -55,4 +55,4 @@ class SpeedData {
} // namespace planning
} // namespace apollo
#endif // MODULES_PLANNING_COMMON_SPEED_SPEED_DATA_H
#endif // MODULES_PLANNING_COMMON_SPEED_SPEED_DATA_H_
......@@ -18,8 +18,8 @@
* @file
**/
#ifndef MODULES_PLANNING_COMMON_SPEED_SPEED_POINT_H
#define MODULES_PLANNING_COMMON_SPEED_SPEED_POINT_H
#ifndef MODULES_PLANNING_COMMON_SPEED_SPEED_POINT_H_
#define MODULES_PLANNING_COMMON_SPEED_SPEED_POINT_H_
#include "modules/planning/common/speed/st_point.h"
......@@ -54,4 +54,4 @@ class SpeedPoint : public STPoint {
} // namespace planning
} // namespace apollo
#endif // MODULES_PLANNING_COMMON_SPEED_SPEED_POINT_H
#endif // MODULES_PLANNING_COMMON_SPEED_SPEED_POINT_H_
......@@ -18,8 +18,8 @@
* @file st_point.h
**/
#ifndef MODULES_PLANNING_COMMON_SPEED_ST_POINT_H
#define MODULES_PLANNING_COMMON_SPEED_ST_POINT_H
#ifndef MODULES_PLANNING_COMMON_SPEED_ST_POINT_H_
#define MODULES_PLANNING_COMMON_SPEED_ST_POINT_H_
#include "modules/common/math/vec2d.h"
......@@ -40,4 +40,4 @@ class STPoint : public ::apollo::common::math::Vec2d {
} // namespace planning
} // namespace apollo
#endif // MODULES_PLANNING_COMMON_SPEED_ST_POINT_H
#endif // MODULES_PLANNING_COMMON_SPEED_ST_POINT_H_
......@@ -25,7 +25,7 @@
#include "modules/common/proto/path_point.pb.h"
namespace adu {
namespace apollo {
namespace planning {
class Trajectory {
......@@ -44,6 +44,6 @@ class Trajectory {
};
} // namespace planning
} // namespace adu
} // namespace apollo
#endif // MODULES_PLANNING_COMMON_TRAJECTORY_TRAJECTORY_H_
......@@ -30,7 +30,6 @@
namespace apollo {
namespace planning {
using ::apollo::common::ErrorCode;
using ::apollo::common::PathPoint;
QuinticSpiralCurve::QuinticSpiralCurve(const common::PathPoint& s,
......@@ -191,12 +190,12 @@ bool QuinticSpiralCurve::calculate_path() {
return diff < spiral_config().newton_raphson_tol() && result_sanity_check();
}
ErrorCode QuinticSpiralCurve::get_path_vec(
common::ErrorCode QuinticSpiralCurve::get_path_vec(
const std::size_t n, std::vector<common::PathPoint>* path_points) const {
CHECK_NOTNULL(path_points);
if (n <= 1 || error() > spiral_config().newton_raphson_tol()) {
return ErrorCode::PLANNING_ERROR;
return common::ErrorCode::PLANNING_ERROR;
}
path_points->resize(n);
......@@ -243,20 +242,20 @@ ErrorCode QuinticSpiralCurve::get_path_vec(
result[k].set_y(result[k].s() * dy + result[0].y());
}
return ErrorCode::OK;
return common::ErrorCode::OK;
}
ErrorCode QuinticSpiralCurve::get_path_vec_with_s(
common::ErrorCode QuinticSpiralCurve::get_path_vec_with_s(
const std::vector<double>& vec_s,
std::vector<common::PathPoint>* path_points) const {
CHECK_NOTNULL(path_points);
if (error() > spiral_config().newton_raphson_tol()) {
return ErrorCode::PLANNING_ERROR;
return common::ErrorCode::PLANNING_ERROR;
}
if (vec_s.size() == 0) {
return ErrorCode::OK;
return common::ErrorCode::OK;
}
const std::size_t n = vec_s.size();
......@@ -304,7 +303,7 @@ ErrorCode QuinticSpiralCurve::get_path_vec_with_s(
result[k].set_y(dy + ref_point.y());
}
return ErrorCode::OK;
return common::ErrorCode::OK;
}
} // namespace planning
......
......@@ -3,6 +3,7 @@ syntax = "proto2";
package apollo.planning_internal;
import "modules/common/proto/header.proto";
import "modules/common/proto/error_code.proto";
import "modules/decision/proto/decision.proto";
import "modules/localization/proto/localization.proto";
import "modules/localization/proto/pose.proto";
......@@ -48,19 +49,12 @@ message PlanningObstacle {
}
message Debug {
enum ErrorCode {
OK = 0; ERR_NOT_READY = 1; ERR_ESTOP = 2; ERR_PATH_OPTIMIZER = 3;
ERR_SPEED_OPTIMIZER = 4;
ERR_ST_GRAPH = 5;
ERR_SANITY_CHECK = 6;
}
/*
PLEASE add id here
id = 1: st_graph_info
*/
message DebugMessage {
optional ErrorCode error_code = 1 [default = OK];
optional apollo.common.ErrorCode error_code = 1;
optional int32 id = 2;
oneof debug_string {
string trace = 3;
......@@ -71,7 +65,7 @@ message Debug {
}
}
optional ErrorCode error_code = 1 [default = OK];
optional apollo.common.ErrorCode error_code = 1;
optional PlanningData planning_data = 2;
repeated DebugMessage debug_message = 3;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册