3 #include <octomap_ros/OctomapROS.h>    10 #define _1DEG 0.01745329251994329577    12 int main(
int argc, 
char** argv) {
    17   OcTreeROS tree (0.05);
    20   point3d origin (0.01, 0.01, 0.02);
    23   point3d point_on_surface (2.01,0.01,0.01);
    25   cout << 
"generating sphere at " << origin << 
" ..." << endl;
    27   for (
int i=0; i<360; i++) {    
    28     for (
int j=0; j<360; j++) {
    30       if (!tree.insertRay(originPt, endPt)) {
    31         cout << 
"ERROR while inserting ray from " << origin << 
" to " << point_on_surface << endl;
    41   OcTreeROS::NodeType* treeNode = tree.search(pointTf);
    43     cout << 
"Occupancy of node at (0, 0, 0) = " << treeNode->getOccupancy() << 
" (should be free)\n";
    45     cerr << 
"ERROR: OcTreeNode not found (NULL)\n";
    47   treeNode = tree.search(
tf::Point(10.01, 2.01, 0.01));
    49     cout << 
"Occupancy of node at (0.01, 2.01, 0.01) = " << treeNode->getOccupancy() << 
" (should be occupied)\n";
    51     cerr << 
"ERROR: OcTreeNode not found (NULL)\n";
    53   cout << 
"writing to sphere.bt..." << endl;
    54   tree.octree.writeBinary(
"sphere.bt");
    58   cout << 
"\ncasting rays ..." << endl;
    60   OcTreeROS sampled_surface(0.05);
    66   unsigned int miss (0);
    69   for (
int i=0; i<360; i++) {    
    70     for (
int j=0; j<360; j++) {
    72       geometry_msgs::Point obstaclePt;
    73       if (!tree.castRay(originPt, directionPt, obstaclePt, 
true, 3.)) {
    79         mean_dist += (obstacle - origin).norm();
    80         sampled_surface.octree.updateNode(obstacle, 
true);
    86   cout << 
"done." << endl;
    88   mean_dist /= (double) hit;
    89   std::cout << 
" hits / misses: " << hit  << 
" / " << miss << std::endl;
    90   std::cout << 
" mean obstacle dist: " << mean_dist << std::endl;
    92   cout << 
"writing sampled_surface.bt" << endl;
    93   sampled_surface.octree.
writeBinary(
"sampled_surface.bt");
    97         cout << 
"\ngenerating single rays..." << endl;
    98         OcTreeROS single_beams(0.03333);
   100         double beamLength = 10.0;
   101         point3d single_origin (1.0, 0.45, 0.45);
   103         point3d single_end(beamLength, 0.0, 0.0);
   106         for (
int i=0; i<num_beams; i++) {
   108           if (!single_beams.insertRay(single_originPt, single_endPt)) {
   109                                 cout << 
"ERROR while inserting ray from " << single_origin << 
" to " << single_end << endl;
   114           cout << 
"done." << endl;
   115                 cout << 
"writing to beams.bt..." << endl;
 
static octomap::point3d pointMsgToOctomap(const geometry_msgs::Point &ptMsg)
Conversion from geometry_msgs::Point to octomap::point3d. 
int main(int argc, char **argv)
Vector3 & rotate_IP(double roll, double pitch, double yaw)
std::ostream & writeBinary(std::ostream &s) const 
static geometry_msgs::Point pointOctomapToMsg(const point3d &octomapPt)
Conversion from octomap::point3d to geometry_msgs::Point. 
octomath::Vector3 point3d