diff --git a/nav2_costmap_2d/include/nav2_costmap_2d/observation.hpp b/nav2_costmap_2d/include/nav2_costmap_2d/observation.hpp index e319502078..5095a84590 100644 --- a/nav2_costmap_2d/include/nav2_costmap_2d/observation.hpp +++ b/nav2_costmap_2d/include/nav2_costmap_2d/observation.hpp @@ -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