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

Explicit assignment operators for Observation, default assignment is a bug here #2413

Merged
merged 3 commits into from
Jun 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions nav2_costmap_2d/include/nav2_costmap_2d/observation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,18 @@ class Observation
}

/**
* @brief Explicitly define copy assignment operator for Observation as it has a user-declared destructor
*/
Observation & operator=(const Observation &) = default;
* @brief Copy assignment operator
* @param obs The observation to copy
*/
Observation & operator=(const Observation & obs)
{
origin_ = obs.origin_;
cloud_ = new sensor_msgs::msg::PointCloud2(*(obs.cloud_));
obstacle_range_ = obs.obstacle_range_;
raytrace_range_ = obs.raytrace_range_;

return *this;
}

/**
* @brief Creates an observation from an origin point and a point cloud
Expand Down