提交 85088842 编写于 作者: T Tae Eun Choe 提交者: Jiangtao Hu

Perception: Removed warnings 3 in perception build (#1738)

上级 bae035cb
......@@ -142,8 +142,8 @@ void Target::Predict(CameraFrame *frame) {
void Target::Update2D(CameraFrame *frame) {
// measurements
auto obj = latest_object->object;
float width = frame->data_provider->src_width();
float height = frame->data_provider->src_height();
float width = static_cast<float>(frame->data_provider->src_width());
float height = static_cast<float>(frame->data_provider->src_height());
base::RectF rect(latest_object->projected_box);
base::Point2DF center = rect.Center();
......@@ -177,11 +177,11 @@ void Target::Update3D(CameraFrame *frame) {
z << std::sin(object->theta * 2), std::cos(object->theta * 2);
direction.AddMeasure(z);
z = direction.get_state();
float theta = std::atan2(z[0], z[1]) / 2;
float theta = static_cast<float>(std::atan2(z[0], z[1]) / 2.0);
AINFO << "dir " << id << " " << object->theta << " " << theta;
object->theta = theta;
object->direction[0] = cos(object->theta);
object->direction[1] = sin(object->theta);
object->direction[0] = static_cast<float>(cos(object->theta));
object->direction[1] = static_cast<float>(sin(object->theta));
object->direction[2] = 0;
z << object->center(0), object->center(1);
......@@ -215,8 +215,8 @@ void Target::Update3D(CameraFrame *frame) {
const Eigen::MatrixXd &var = world_center_for_unmovable.get_variance();
object->center(0) = x(0);
object->center(1) = x(1);
object->center_uncertainty(0) = var(0);
object->center_uncertainty(1) = var(1);
object->center_uncertainty(0) = static_cast<float>(var(0));
object->center_uncertainty(1) = static_cast<float>(var(1));
object->velocity(0) = 0;
object->velocity(1) = 0;
object->velocity(2) = 0;
......@@ -261,18 +261,20 @@ void Target::Update3D(CameraFrame *frame) {
object->center(0) = x(0);
object->center(1) = x(1);
object->center_uncertainty.setConstant(0);
object->center_uncertainty(0, 0) = world_center.variance_(0, 0);
object->center_uncertainty(1, 1) = world_center.variance_(1, 1);
object->velocity(0) = x(2);
object->velocity(1) = x(3);
object->center_uncertainty(0, 0) =
static_cast<float>(world_center.variance_(0, 0));
object->center_uncertainty(1, 1) =
static_cast<float>(world_center.variance_(1, 1));
object->velocity(0) = static_cast<float>(x(2));
object->velocity(1) = static_cast<float>(x(3));
object->velocity(2) = 0;
world_velocity.AddMeasure(object->velocity.cast<double>());
object->velocity_uncertainty = world_velocity.get_variance().cast<float>();
if (speed > target_param_.velocity_threshold()) {
object->direction(0) = x(2) / speed;
object->direction(1) = x(3) / speed;
object->direction(0) = static_cast<float>(x(2) / speed);
object->direction(1) = static_cast<float>(x(3) / speed);
object->direction(2) = 0;
object->theta = std::atan2(x(3), x(2));
object->theta = static_cast<float>(std::atan2(x(3), x(2)));
}
}
......@@ -422,7 +424,7 @@ bool Target::CheckStatic() {
obj1.velocity + obj2.velocity;
return ret_obj;
});
tmp_obj_vel_avg.velocity /= min_vel_size;
tmp_obj_vel_avg.velocity /= static_cast<float>(min_vel_size);
double speed_avg = tmp_obj_vel_avg.velocity.head(2).norm();
const auto &obj_type = history_world_states_.back().type;
// check speed by type
......@@ -440,12 +442,12 @@ bool Target::CheckStatic() {
if (static_cast<int>(history_world_states_.size()) >=
std::max(target_param_.min_cached_position_size(),
target_param_.calc_avg_position_window_size())) {
double move_distance = 0.0f;
double move_distance = 0.0;
Eigen::Vector3d start_position(0.0, 0.0, 0.0);
Eigen::Vector3d end_position(0.0, 0.0, 0.0);
const int start_idx = history_world_states_.size() -
target_param_.min_cached_position_size();
const int end_idx = history_world_states_.size() - 1;
const int start_idx = static_cast<int>(history_world_states_.size()) -
static_cast<int>(target_param_.min_cached_position_size());
const int end_idx = static_cast<int>(history_world_states_.size()) - 1;
// calculate window-averaged start and end positions
// and calculate moved distance
if (end_idx - start_idx >=
......
......@@ -38,60 +38,60 @@ TEST(HistogramEstimatorTest, histogram_estimator_test) {
estimator.get_val_estimation();
estimator.get_bin_value(0);
estimator.Push(params1.data_ep - 1.0);
estimator.Push(params1.data_ep + 1.0);
estimator.Push(params1.data_sp - 1.0);
estimator.Push(params1.data_sp + 1.0);
estimator.Push((params1.data_sp + params1.data_ep) / 2.0);
estimator.Push(params1.data_ep - 1.0f);
estimator.Push(params1.data_ep + 1.0f);
estimator.Push(params1.data_sp - 1.0f);
estimator.Push(params1.data_sp + 1.0f);
estimator.Push((params1.data_sp + params1.data_ep) / 2.0f);
estimator.Process();
estimator.Clear();
estimator.Push((params1.data_sp + params1.data_ep) / 2.0);
estimator.Push((params1.data_sp + params1.data_ep) / 2.0f);
estimator.Process();
estimator.Clear();
for (int i = 0; i < 10; i++) {
estimator.Push((params1.data_sp + params1.data_ep) / 2.0);
estimator.Push((params1.data_sp + params1.data_ep) / 2.0f);
}
estimator.Process();
estimator.Clear();
for (int i = 0; i < 100; i++) {
estimator.Push((params1.data_sp + params1.data_ep) / 2.0);
estimator.Push((params1.data_sp + params1.data_ep) / 2.0f);
}
estimator.Process();
estimator.Clear();
for (int i = 0; i < 10; i++) {
estimator.Push(params1.data_sp * i / 100.0 +
params1.data_ep * (1.0 - i / 100.0));
estimator.Push(params1.data_sp * static_cast<float>(i) / 100.0f +
params1.data_ep * (1.0f - static_cast<float>(i) / 100.0f));
}
estimator.Process();
estimator.Clear();
for (int i = 0; i < 10; i++) {
estimator.Push(params1.data_ep * i / 10.0 +
params1.data_sp * (1.0 - i / 10.0));
estimator.Push(params1.data_ep * static_cast<float>(i) / 10.0f +
params1.data_sp * (1.0f - static_cast<float>(i) / 10.0f));
}
estimator.Process();
estimator.Clear();
for (int i = 0; i < 10; i++) {
estimator.Push(params1.data_sp * i / 10.0 +
params1.data_ep * (1.0 - i / 10.0));
estimator.Push(params1.data_sp * static_cast<float>(i) / 10.0f +
params1.data_ep * (1.0f - static_cast<float>(i) / 10.0f));
}
for (int i = 0; i < 10; i++) {
estimator.Push((params1.data_sp + params1.data_ep) / 2.0);
estimator.Push((params1.data_sp + params1.data_ep) / 2.0f);
}
estimator.Process();
estimator.Clear();
for (int i = 0; i < 10; i++) {
estimator.Push(params1.data_ep * i / 10.0 +
params1.data_sp * (1.0 - i / 10.0));
estimator.Push(params1.data_ep * static_cast<float>(i) / 10.0f +
params1.data_sp * (1.0f - static_cast<float>(i) / 10.0f));
}
for (int i = 0; i < 10; i++) {
estimator.Push((params1.data_sp + params1.data_ep) / 2.0);
estimator.Push((params1.data_sp + params1.data_ep) / 2.0f);
}
estimator.Process();
params1.smooth_kernel_radius = params1.nr_bins_in_histogram;
......
......@@ -178,7 +178,9 @@ inline void IPlaneFitTotalLeastSquare(T *X, T *pi, int n) {
// pi is stored as 4 - vector[a, b, c, d]. x will be destroyed after calling
// this routine.
template <typename T> inline void IPlaneFitTotalLeastSquare3(T *X, T *pi) {
T mat_a[9], eigv[3], mat_q[9];
T mat_a[9];
T eigv[3];
T mat_q[9];
// compute the centroid of input Data points
IZero4(pi);
T xm = (X[0] + X[3] + X[6]) / 3;
......
......@@ -66,7 +66,7 @@ bool PlaneFitGroundDetectorParam::Validate() const {
int PlaneFitPointCandIndices::Prune(unsigned int min_nr_samples,
unsigned int max_nr_samples) {
assert(min_nr_samples < max_nr_samples);
unsigned int size = indices.size();
unsigned int size = static_cast<unsigned int>(indices.size());
unsigned int half = 0;
if (size > max_nr_samples) {
IRandomizedShuffle1(indices.data(), static_cast<int>(indices.size()),
......@@ -114,7 +114,7 @@ void PlaneFitGroundDetector::InitOrderTable(const VoxelGridXY<float> *vg,
int id = 0;
for (i = 0; i < vg->NrVoxel(); ++i) {
const auto &voxel = vg->GetConstVoxels()[i];
radius = voxel.dim_x_ * 0.5;
radius = voxel.dim_x_ * 0.5f;
cx = voxel.v_[0] + radius;
cy = voxel.v_[1] + radius;
dist2 = cx * cx + cy * cy;
......@@ -639,7 +639,8 @@ int PlaneFitGroundDetector::FitGrid(const float *point_cloud,
int nr_samples = candi->Prune(param_.nr_samples_min_threshold,
param_.nr_samples_max_threshold);
int nr_inliers_termi =
IRound(nr_samples * param_.termi_inlier_percen_threshold);
IRound(static_cast<float>(nr_samples) *
param_.termi_inlier_percen_threshold);
// 3x3 matrix stores: x, y, z; x, y, z; x, y, z;
float samples[9];
// copy 3D points
......@@ -678,7 +679,8 @@ int PlaneFitGroundDetector::FitGrid(const float *point_cloud,
// Assign number of supports
plane.SetNrSupport(nr_inliers);
fit_cost = nr_inliers > 0 ? (fit_cost / nr_inliers) : dist_thre;
fit_cost = nr_inliers > 0 ?
(fit_cost / static_cast<float>(nr_inliers)) : dist_thre;
// record the best plane
if (nr_inliers >= nr_inliers_best) {
if (nr_inliers == nr_inliers_best) {
......@@ -784,7 +786,7 @@ int PlaneFitGroundDetector::FilterCandidates(
}
}
if (count > 0) {
avg_z /= count;
avg_z /= static_cast<float>(count);
ground_z_[r][c].first = avg_z;
ground_z_[r][c].second = true;
for (i = 0; i < candi->Size(); ++i) {
......@@ -828,7 +830,8 @@ int PlaneFitGroundDetector::FitGridWithNeighbors(
}
GroundPlaneLiDAR plane;
int kNr_iter = param_.nr_ransac_iter_threshold + neighbors.size();
int kNr_iter = param_.nr_ransac_iter_threshold +
static_cast<int>(neighbors.size());
GroundPlaneLiDAR hypothesis[kNr_iter];
float ptp_dist = 0;
int best = -1;
......@@ -841,7 +844,8 @@ int PlaneFitGroundDetector::FitGridWithNeighbors(
int nr_samples = candi.Prune(param_.nr_samples_min_threshold,
param_.nr_samples_max_threshold);
int nr_inliers_termi =
IRound(nr_samples * param_.termi_inlier_percen_threshold);
IRound(static_cast<float>(nr_samples) *
param_.termi_inlier_percen_threshold);
// 3x3 matrix stores: x, y, z; x, y, z; x, y, z;
float samples[9];
// copy 3D points
......@@ -971,7 +975,7 @@ int PlaneFitGroundDetector::FitGridWithNeighbors(
}
const auto &voxel_cur = (*vg_coarse_)(r, c);
float radius = voxel_cur.dim_x_ * 0.5;
float radius = voxel_cur.dim_x_ * 0.5f;
float cx = voxel_cur.v_[0] + radius;
float cy = voxel_cur.v_[1] + radius;
float cz = -(groundplane->params[0] * cx + groundplane->params[1] * cy +
......@@ -1002,7 +1006,7 @@ float PlaneFitGroundDetector::CalculateAngleDist(
if (count == 0) {
return -1;
}
return angle_dist / count;
return angle_dist / static_cast<float>(count);
}
int PlaneFitGroundDetector::FitInOrder() {
......@@ -1123,14 +1127,19 @@ int PlaneFitGroundDetector::CompleteGrid(const GroundPlaneSpherical &lt,
supports[1] = rt.GetNrSupport();
supports[2] = up.GetNrSupport();
supports[3] = dn.GetNrSupport();
int support_sum = ISum4(supports);
int support_sum = 0;
support_sum = ISum4(supports);
if (!support_sum) {
return 0;
}
weights[0] = static_cast<float>(supports[0]) / support_sum;
weights[1] = static_cast<float>(supports[1]) / support_sum;
weights[2] = static_cast<float>(supports[2]) / support_sum;
weights[3] = static_cast<float>(supports[3]) / support_sum;
weights[0] = static_cast<float>(supports[0]) /
static_cast<float>(support_sum);
weights[1] = static_cast<float>(supports[1]) /
static_cast<float>(support_sum);
weights[2] = static_cast<float>(supports[2]) /
static_cast<float>(support_sum);
weights[3] = static_cast<float>(supports[3]) /
static_cast<float>(support_sum);
// weighted average:
gp->theta = weights[0] * lt.theta + weights[1] * rt.theta +
weights[2] * up.theta + weights[3] * dn.theta;
......@@ -1173,17 +1182,23 @@ int PlaneFitGroundDetector::SmoothGrid(const GroundPlaneSpherical &g,
supports[3] = dn.GetNrSupport();
}
supports[4] = (g.GetNrSupport() << 2);
int support_sum = ISum4(supports);
int support_sum = 0;
support_sum = ISum4(supports);
if (support_sum == 0) {
*gp = g;
return 0;
}
support_sum += supports[4];
weights[0] = static_cast<float>(supports[0]) / support_sum;
weights[1] = static_cast<float>(supports[1]) / support_sum;
weights[2] = static_cast<float>(supports[2]) / support_sum;
weights[3] = static_cast<float>(supports[3]) / support_sum;
weights[4] = static_cast<float>(supports[4]) / support_sum;
weights[0] = static_cast<float>(supports[0]) /
static_cast<float>(support_sum);
weights[1] = static_cast<float>(supports[1]) /
static_cast<float>(support_sum);
weights[2] = static_cast<float>(supports[2]) /
static_cast<float>(support_sum);
weights[3] = static_cast<float>(supports[3]) /
static_cast<float>(support_sum);
weights[4] = static_cast<float>(supports[4]) /
static_cast<float>(support_sum);
// weighted average:
gp->theta = weights[0] * lt.theta + weights[1] * rt.theta +
weights[2] * up.theta + weights[3] * dn.theta +
......
......@@ -199,7 +199,9 @@ struct PlaneFitPointCandIndices {
void Clear() { indices.clear(); }
inline void PushIndex(int i) { indices.push_back(i); }
int Prune(unsigned int min_nr_samples, unsigned int max_nr_samples);
unsigned int Size() const { return indices.size(); }
unsigned int Size() const {
return static_cast<unsigned int>(indices.size());
}
int &operator[](unsigned int i) {
assert(i >= 0 && i < indices.size());
return indices.at(i);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册