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

Fix geometric shapes related memory leaks #2138

Merged
merged 2 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void collision_detection::BodyDecomposition::init(const std::vector<shapes::Shap
bodies_.clear();
for (unsigned int i = 0; i < shapes.size(); i++)
{
bodies_.addBody(shapes[i]->clone(), poses[i], padding);
bodies_.addBody(shapes[i].get(), poses[i], padding);
rhaschke marked this conversation as resolved.
Show resolved Hide resolved
}

// collecting collision spheres
Expand Down
8 changes: 4 additions & 4 deletions moveit_core/planning_scene/src/planning_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,8 @@ bool PlanningScene::loadGeometryFromStream(std::istream& in, const Eigen::Isomet
in >> shape_count;
for (std::size_t i = 0; i < shape_count && in.good() && !in.eof(); ++i)
{
shapes::Shape* s = shapes::constructShapeFromText(in);
if (!s)
const auto shape = shapes::ShapeConstPtr(shapes::constructShapeFromText(in));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are reasonable.

if (!shape)
{
ROS_ERROR_NAMED(LOGNAME, "Failed to load shape from scene file");
return false;
Expand All @@ -1041,12 +1041,12 @@ bool PlanningScene::loadGeometryFromStream(std::istream& in, const Eigen::Isomet
ROS_ERROR_NAMED(LOGNAME, "Improperly formatted color in scene geometry file");
return false;
}
if (s)
if (shape)
{
Eigen::Isometry3d pose = Eigen::Translation3d(x, y, z) * Eigen::Quaterniond(rw, rx, ry, rz);
// Transform pose by input pose offset
pose = offset * pose;
world_->addToObject(ns, shapes::ShapePtr(s), pose);
world_->addToObject(ns, shape, pose);
if (r > 0.0f || g > 0.0f || b > 0.0f || a > 0.0f)
{
std_msgs::ColorRGBA color;
Expand Down