From 03b5ee3b7ce84402ad95393bc3c85eef63d028c2 Mon Sep 17 00:00:00 2001 From: Liangliang Zhang Date: Mon, 24 Sep 2018 20:18:07 -0700 Subject: [PATCH] Perception: added build for box and object. (#436) --- .travis.yml | 2 +- apollo.sh | 3 +- modules/perception/base/BUILD | 52 +++++++++++++++++++ modules/perception/base/box.h | 22 +++----- .../{test/base_box_test.cc => box_test.cc} | 7 ++- modules/perception/base/comparison_traits.h | 1 + modules/perception/base/object.cc | 1 + modules/perception/base/object.h | 9 ++-- modules/perception/base/object_supplement.h | 25 ++++----- .../base_object_test.cc => object_test.cc} | 4 +- modules/perception/base/object_types.h | 3 ++ modules/perception/base/vehicle_struct.h | 3 ++ 12 files changed, 93 insertions(+), 39 deletions(-) rename modules/perception/base/{test/base_box_test.cc => box_test.cc} (99%) rename modules/perception/base/{test/base_object_test.cc => object_test.cc} (99%) diff --git a/.travis.yml b/.travis.yml index 1ab5ca22ad..ddbc206b2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ os: linux env: - JOB=lint - JOB=cibuild - - JOB=test_cpu + - JOB=citest cache: directories: - $HOME/.cache/bazel diff --git a/apollo.sh b/apollo.sh index e174eecb6d..9175c50a65 100755 --- a/apollo.sh +++ b/apollo.sh @@ -396,6 +396,7 @@ function gen_coverage() { } function run_test() { + generate_build_targets if [ "$USE_GPU" == "1" ]; then echo -e "${YELLOW}Running tests under GPU mode. GPU is required to run the tests.${NO_COLOR}" @@ -497,7 +498,7 @@ function citest() { bash cybertron.sh build_fast cd /apollo - citest_basic + run_test if [ $? -eq 0 ]; then success 'Test passed!' return 0 diff --git a/modules/perception/base/BUILD b/modules/perception/base/BUILD index e764196419..010d3c61c6 100644 --- a/modules/perception/base/BUILD +++ b/modules/perception/base/BUILD @@ -26,4 +26,56 @@ cc_test( ], ) +cc_library( + name = "object", + hdrs = [ + "object.h", + "object_supplement.h", + "object_types.h", + "vehicle_struct.h", + ], + srcs = [ + "object.cc", + ], + deps = [ + ":point_cloud", + ":box", + ], +) + +cc_test( + name = "object_test", + size = "small", + srcs = [ + "object_test.cc", + ], + deps = [ + ":object", + "@gtest//:main", + ], +) + +cc_library( + name = "box", + hdrs = [ + "box.h", + "comparison_traits.h", + ], + deps = [ + ":point_cloud", + ], +) + +cc_test( + name = "box_test", + size = "small", + srcs = [ + "box_test.cc", + ], + deps = [ + ":box", + "@gtest//:main", + ], +) + cpplint() diff --git a/modules/perception/base/box.h b/modules/perception/base/box.h index 832aa2fc20..e31774e199 100644 --- a/modules/perception/base/box.h +++ b/modules/perception/base/box.h @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ -#ifndef MODULES_PERCEPTION_BASE_IMAGE_CORE_H_ -#define MODULES_PERCEPTION_BASE_IMAGE_CORE_H_ +#ifndef MODULES_PERCEPTION_BASE_BOX_H_ +#define MODULES_PERCEPTION_BASE_BOX_H_ -#include -#include #include +#include +#include #include #include #include #include + #include "modules/perception/base/comparison_traits.h" #include "modules/perception/base/point.h" @@ -30,9 +31,6 @@ namespace apollo { namespace perception { namespace base { -template -struct Rect; - template struct BBox2D; @@ -163,16 +161,8 @@ struct BBox2D { T ymax = 0; // bottom-right }; -typedef Rect RectI; -typedef Rect RectF; -typedef Rect RectD; - -typedef BBox2D BBox2DI; -typedef BBox2D BBox2DF; -typedef BBox2D BBox2DD; - } // namespace base } // namespace perception } // namespace apollo -#endif // MODULES_PERCEPTION_BASE_IMAGE_CORE_H_ +#endif // MODULES_PERCEPTION_BASE_BOX_H_ \ No newline at end of file diff --git a/modules/perception/base/test/base_box_test.cc b/modules/perception/base/box_test.cc similarity index 99% rename from modules/perception/base/test/base_box_test.cc rename to modules/perception/base/box_test.cc index 3dac081b59..93c726cc53 100644 --- a/modules/perception/base/test/base_box_test.cc +++ b/modules/perception/base/box_test.cc @@ -13,10 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ -#include + +#include "modules/perception/base/box.h" + #include #include -#include "modules/perception/base/box.h" + +#include "gtest/gtest.h" namespace apollo { namespace perception { diff --git a/modules/perception/base/comparison_traits.h b/modules/perception/base/comparison_traits.h index a1ce7b6b7c..34da440235 100644 --- a/modules/perception/base/comparison_traits.h +++ b/modules/perception/base/comparison_traits.h @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ + #ifndef MODULES_PERCEPTION_BASE_COMPARISON_TRAITS_H_ #define MODULES_PERCEPTION_BASE_COMPARISON_TRAITS_H_ diff --git a/modules/perception/base/object.cc b/modules/perception/base/object.cc index 7ac29516dc..296e729688 100644 --- a/modules/perception/base/object.cc +++ b/modules/perception/base/object.cc @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ + #include "modules/perception/base/object.h" #include diff --git a/modules/perception/base/object.h b/modules/perception/base/object.h index f28bc18722..d068db0ed8 100644 --- a/modules/perception/base/object.h +++ b/modules/perception/base/object.h @@ -15,11 +15,12 @@ *****************************************************************************/ #ifndef MODULES_PERCEPTION_BASE_OBJECT_H_ #define MODULES_PERCEPTION_BASE_OBJECT_H_ -#include #include #include +#include "Eigen/Core" + #include "modules/perception/base/object_supplement.h" #include "modules/perception/base/object_types.h" #include "modules/perception/base/point_cloud_types.h" @@ -28,6 +29,7 @@ namespace apollo { namespace perception { namespace base { + struct alignas(16) Object { Object(); Object(const Object &) = default; @@ -39,7 +41,7 @@ struct alignas(16) Object { int id = -1; // @brief convex hull of the object, required - PolygonDType polygon; + PointCloud polygon; // oriented boundingbox information // @brief main direction of the object, required @@ -110,9 +112,6 @@ struct alignas(16) Object { FusionObjectSupplement fusion_supplement; }; -typedef std::shared_ptr ObjectPtr; -typedef std::shared_ptr ObjectConstPtr; - } // namespace base } // namespace perception } // namespace apollo diff --git a/modules/perception/base/object_supplement.h b/modules/perception/base/object_supplement.h index a0e03b205d..31bfe78ef1 100644 --- a/modules/perception/base/object_supplement.h +++ b/modules/perception/base/object_supplement.h @@ -15,6 +15,7 @@ *****************************************************************************/ #ifndef MODULES_PERCEPTION_BASE_OBJECT_SUPPLEMENT_H_ #define MODULES_PERCEPTION_BASE_OBJECT_SUPPLEMENT_H_ + #include #include #include @@ -47,9 +48,9 @@ struct alignas(16) LidarObjectSupplement { // @brief valid only for on_use = true bool on_use = false; // @brief cloud of the object in lidar coordinates - PointFCloud cloud; + base::AttributePointCloud cloud; // @brief cloud of the object in world coordinates - PointDCloud cloud_world; + base::AttributePointCloud cloud_world; // @brief background indicator bool is_background = false; // @brief false positive indicator @@ -107,10 +108,10 @@ struct alignas(16) CameraObjectSupplement { pts8.clear(); object_feature.clear(); alpha = 0.0; - box = BBox2DF(); - projected_box = BBox2DF(); - front_box = BBox2DF(); - back_box = BBox2DF(); + box = BBox2D(); + projected_box = BBox2D(); + front_box = BBox2D(); + back_box = BBox2D(); local_center = Eigen::Vector3f(0.0f, 0.0f, 0.0f); visual_type = VisualObjectType::MAX_OBJECT_TYPE; visual_type_probs.resize( @@ -130,10 +131,10 @@ struct alignas(16) CameraObjectSupplement { std::string sensor_name; // @brief 2d box - BBox2DF box; + BBox2D box; // @brief projected 2d box - BBox2DF projected_box; + BBox2D projected_box; // @brief local track id int local_track_id = -1; @@ -142,10 +143,10 @@ struct alignas(16) CameraObjectSupplement { std::vector pts8; // @brief front box - BBox2DF front_box; + BBox2D front_box; // @brief back box - BBox2DF back_box; + BBox2D back_box; std::vector object_feature; // @brief alpha angle from KITTI: Observation angle of object, in [-pi..pi] @@ -191,7 +192,7 @@ struct SensorObjectMeasurement { size = Eigen::Vector3f(0, 0, 0); velocity = Eigen::Vector3f(0, 0, 0); type = ObjectType::UNKNOWN; - box = BBox2DF(); + box = BBox2D(); } std::string sensor_id = "unknown_sensor"; @@ -203,7 +204,7 @@ struct SensorObjectMeasurement { Eigen::Vector3f velocity = Eigen::Vector3f(0, 0, 0); ObjectType type = ObjectType::UNKNOWN; // @brief only for camera measurement - BBox2DF box; + BBox2D box; }; struct alignas(16) FusionObjectSupplement { diff --git a/modules/perception/base/test/base_object_test.cc b/modules/perception/base/object_test.cc similarity index 99% rename from modules/perception/base/test/base_object_test.cc rename to modules/perception/base/object_test.cc index 1f90b549d4..68a7bfc923 100644 --- a/modules/perception/base/test/base_object_test.cc +++ b/modules/perception/base/object_test.cc @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ -#include - #include "modules/perception/base/object.h" +#include "gtest/gtest.h" + namespace apollo { namespace perception { namespace base { diff --git a/modules/perception/base/object_types.h b/modules/perception/base/object_types.h index 92a62062e2..6e2d3535de 100644 --- a/modules/perception/base/object_types.h +++ b/modules/perception/base/object_types.h @@ -17,6 +17,7 @@ #define MODULES_PERCEPTION_BASE_OBJECT_TYPES_H_ #include +#include namespace apollo { namespace perception { @@ -93,6 +94,7 @@ enum class VisualLandmarkType { TrafficLight, MAX_LANDMARK_TYPE, }; + const std::map kVisualLandmarkType2NameMap = { {VisualLandmarkType::RoadArrow, "RoadArrow"}, {VisualLandmarkType::RoadText, "RoadText"}, @@ -228,4 +230,5 @@ const std::map kName2SubTypeMap = { } // namespace base } // namespace perception } // namespace apollo + #endif // MODULES_PERCEPTION_BASE_OBJECT_TYPES_H_ diff --git a/modules/perception/base/vehicle_struct.h b/modules/perception/base/vehicle_struct.h index df73ff7d57..6bb9129ce3 100644 --- a/modules/perception/base/vehicle_struct.h +++ b/modules/perception/base/vehicle_struct.h @@ -15,9 +15,11 @@ *****************************************************************************/ #ifndef MODULES_PERCEPTION_BASE_VEHICLE_STRUCT_H_ #define MODULES_PERCEPTION_BASE_VEHICLE_STRUCT_H_ + namespace apollo { namespace perception { namespace base { + struct CarLight { float brake_visible = 0; float brake_switch_on = 0; @@ -35,6 +37,7 @@ struct CarLight { right_turn_switch_on = 0; } }; + } // namespace base } // namespace perception } // namespace apollo -- GitLab