45 #include <visualization_msgs/MarkerArray.h> 46 #include <costmap_2d/VoxelGrid.h> 68 if (grid->data.empty())
77 const std::string
frame_id = grid->header.frame_id;
79 const uint32_t* data = &grid->data.front();
80 const double x_origin = grid->origin.x;
81 const double y_origin = grid->origin.y;
82 const double z_origin = grid->origin.z;
83 const double x_res = grid->resolutions.x;
84 const double y_res = grid->resolutions.y;
85 const double z_res = grid->resolutions.z;
86 const uint32_t x_size = grid->size_x;
87 const uint32_t y_size = grid->size_y;
88 const uint32_t z_size = grid->size_z;
92 for (
uint32_t y_grid = 0; y_grid < y_size; ++y_grid)
94 for (
uint32_t x_grid = 0; x_grid < x_size; ++x_grid)
96 for (
uint32_t z_grid = 0; z_grid < z_size; ++z_grid)
105 c.
x = x_origin + (x_grid + 0.5) * x_res;
106 c.
y = y_origin + (y_grid + 0.5) * y_res;
107 c.
z = z_origin + (z_grid + 0.5) * z_res;
116 visualization_msgs::Marker m;
118 m.header.stamp =
stamp;
121 m.type = visualization_msgs::Marker::CUBE_LIST;
122 m.action = visualization_msgs::Marker::ADD;
123 m.pose.orientation.w = 1.0;
131 m.points.resize(num_markers);
132 for (
uint32_t i = 0; i < num_markers; ++i)
135 geometry_msgs::Point& p = m.points[i];
144 ROS_DEBUG(
"Published %d markers in %f seconds", num_markers, (end - start).toSec());
161 int main(
int argc,
char** argv)
178 pub = n.
advertise < visualization_msgs::Marker > (
"visualization_marker", 1, connect_cb, disconnect_cb);
voxel_grid::VoxelStatus status
boost::function< void(const SingleSubscriberPublisher &)> SubscriberStatusCallback
std::vector< Cell > V_Cell
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
std::string resolveName(const std::string &name, bool remap=true) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
std::vector< Cell > V_Cell
VoxelStatus getVoxel(unsigned int x, unsigned int y, unsigned int z)
ROSCPP_DECL void spin(Spinner &spinner)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void voxelCallback(const ros::Publisher &pub, const costmap_2d::VoxelGridConstPtr &grid)
uint32_t getNumSubscribers() const