Skip to content

Commit

Permalink
Fix for visualising attached shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-touchlab committed Oct 19, 2023
1 parent be580d1 commit 4393d49
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions exotica_core/src/kinematic_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,32 @@ void KinematicTree::PublishFrames(const std::string& tf_prefix)
octomap_pub_.publish(octomap_msg);
}
}
else if(tree_[i].lock()->shape && !tree_[i].lock()->is_robot_link)
{
if (tree_[i].lock()->shape->type != shapes::ShapeType::OCTREE)
{
visualization_msgs::Marker mrk;
shapes::constructMarkerFromShape(tree_[i].lock()->shape.get(), mrk);
mrk.action = visualization_msgs::Marker::ADD;
mrk.frame_locked = true;
mrk.id = i;
mrk.ns = "CollisionObjects";
mrk.color = GetColor(tree_[i].lock()->color);
mrk.header.frame_id = tf_prefix + "/" + tree_[i].lock()->segment.getName();
mrk.pose.orientation.w = 1.0;
marker_array_msg_.markers.push_back(mrk);
}
else
{
// OcTree needs separate handling as it's not supported in constructMarkerFromShape
// NB: This only supports a single OctoMap in the KinematicTree as we only have one publisher!
octomap::OcTree my_octomap = *std::static_pointer_cast<const shapes::OcTree>(tree_[i].lock()->shape)->octree.get();
octomap_msgs::Octomap octomap_msg;
octomap_msgs::binaryMapToMsg(my_octomap, octomap_msg);
octomap_msg.header.frame_id = tf_prefix + "/" + tree_[i].lock()->segment.getName();
octomap_pub_.publish(octomap_msg);
}
}
}
shapes_pub_.publish(marker_array_msg_);
}
Expand Down
1 change: 1 addition & 0 deletions exotica_core/src/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ void Scene::UpdateSceneFrames()

std::string collision_element_name = links[i]->getName() + "_collision_" + std::to_string(j);
std::shared_ptr<KinematicElement> element = kinematica_.AddElement(collision_element_name, trans, links[i]->getName(), links[i]->getShapes()[j]);
element->is_robot_link = true;
model_link_to_collision_element_map_[links[i]->getName()].push_back(element);

// Set up mappings
Expand Down

0 comments on commit 4393d49

Please sign in to comment.