Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete Calibration object initialization #321

Open
andre-nguyen opened this issue Dec 5, 2019 · 1 comment
Open

Incomplete Calibration object initialization #321

andre-nguyen opened this issue Dec 5, 2019 · 1 comment
Assignees
Labels

Comments

@andre-nguyen
Copy link

Please complete the following information:

  • OS and Version: Ubuntu 18, applies to all
  • ROS Version: Melodic, applies to all
  • Built from Source or Downloaded from Official Repository: Source
  • Version: lastest master but I think the bug was introduced in Avoid unnecessary computation #194

Describe the bug
Part of the Calibration parsing code in calibration.cc is used to retag all the laser_rings using the vertical angle. This code runs on the laser_corrections vector but not on the map, thus laser_corrections_map has incomplete initialization.

double next_angle = -std::numeric_limits<double>::infinity();
for (int ring = 0; ring < num_lasers; ++ring) {
// find minimum remaining vertical offset correction
double min_seen = std::numeric_limits<double>::infinity();
int next_index = num_lasers;
for (int j = 0; j < num_lasers; ++j) {
double angle = calibration.laser_corrections[j].vert_correction;
if (next_angle < angle && angle < min_seen) {
min_seen = angle;
next_index = j;
}
}
if (next_index < num_lasers) { // anything found in this ring?
// store this ring number with its corresponding laser number
calibration.laser_corrections[next_index].laser_ring = ring;
next_angle = min_seen;
if (calibration.ros_info) {
ROS_INFO("laser_ring[%2u] = %2u, angle = %+.6f",
next_index, ring, next_angle);
}
}
}

However, looking through the code, the map is only ever used to emit a YAML of the calibration and does it by using a forward iterator. Thus, the code below could iterate over the vector and we could technically remove that unused variable.

for (std::map<int, LaserCorrection>::const_iterator
it = calibration.laser_corrections_map.begin();
it != calibration.laser_corrections_map.end(); it++)
{
out << *it;
}
out << YAML::EndSeq;
out << YAML::EndMap;
return out;
}

To Reproduce
Read code

Expected behavior
Not have redundant datastructures.

Additional context

@JWhitleyWork
Copy link
Contributor

Thanks, @andre-nguyen! Would you mind submitting a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants