43 int main(
int argc,
char** argv)
45 ros::init(argc, argv,
"visualize_robot_collision_volume");
51 double lifetime = 600.0;
54 std::shared_ptr<tf2_ros::Buffer>
tf_buffer = std::make_shared<tf2_ros::Buffer>();
55 std::shared_ptr<tf2_ros::TransformListener> tf_listener =
56 std::make_shared<tf2_ros::TransformListener>(*
tf_buffer, nh);
64 std::cout <<
"\nListening for planning scene...\nType the number of spheres to generate and press Enter: "
67 std::cin >> num_spheres;
70 std::vector<double>
aabb;
71 scene->getCurrentState().computeAABB(
aabb);
74 visualization_msgs::Marker mk;
76 mk.header.frame_id = scene->getPlanningFrame();
77 mk.ns =
"bounding_box";
79 mk.type = visualization_msgs::Marker::CUBE;
80 mk.action = visualization_msgs::Marker::ADD;
81 mk.pose.position.x = (
aabb[0] +
aabb[1]) / 2.0;
82 mk.pose.position.y = (
aabb[2] +
aabb[3]) / 2.0;
83 mk.pose.position.z = (
aabb[4] +
aabb[5]) / 2.0;
84 mk.pose.orientation.w = 1.0;
93 visualization_msgs::MarkerArray arr;
94 arr.markers.push_back(mk);
99 std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d>> points;
100 std::size_t published = 0;
104 std_msgs::ColorRGBA color;
110 for (
int i = 0; i < num_spheres; ++i)
114 scene->getWorldNonConst()->clearObjects();
117 scene->checkCollision(req, res);
120 points.push_back(
t.translation());
121 if (points.size() - published >= 100 || (points.size() > published && i + 1 >= num_spheres))
124 for (std::size_t k = published; k < points.size(); ++k)
126 visualization_msgs::Marker mk;
128 mk.header.frame_id = scene->getPlanningFrame();
131 mk.type = visualization_msgs::Marker::SPHERE;
132 mk.action = visualization_msgs::Marker::ADD;
133 mk.pose.position.x = points[k].x();
134 mk.pose.position.y = points[k].y();
135 mk.pose.position.z = points[k].z();
136 mk.pose.orientation.w = 1.0;
137 mk.scale.x = mk.scale.y = mk.scale.z = radius;
140 arr.markers.push_back(mk);
144 published = points.size();