markers and services which appear/disapear depending on some function calls

asked 2018-07-20 10:31:43 -0600

fabriceN gravatar image

I am facing an issue with markers and services which appear/disapear depending on some function calls

Here is the setup

I have a node which is calling two classes:

ros::NodeHandle nh;

// create a costmap
costmap_2d_ros_ = new costmap_2d::Costmap2DROS("global_costmap", tfl_);

// Create a planner
planner_ = new hector_exploration_planner::HectorExplorationPlanner();

// Initialize the planner with the appropriate namespace

//setup parameters

params_.nh_ = nh;

// create a service to explore frontiers + quadtree + Astar
exploration_plan_service_server_ = nh.advertiseService("get_exploration_path", &SimpleExplorationPlanner::explorationServiceCallback, this);

exploration_plan_pub_ = nh.advertise<nav_msgs::Path>("exploration_path", 2);

// exploration planner with RRT
   nbvp::nbvPlanner<Eigen::Matrix<double, 4, 1> > rrt_planner("nbvplanner", planner_, params_);

When I call planner_->initialize(), I create some markers:

// initialize parameters
ros::NodeHandle private_nh_("~/" + name);

//ros::NodeHandle nh;

visualization_pub_ = private_nh_.advertise<visualization_msgs::Marker>("visualization_marker", 1);

visualization_astar_pub_ = private_nh_.advertise<visualization_msgs::Marker>("visualization_astar_marker", 1);

visualization_astar2_pub_ = private_nh_.advertise<visualization_msgs::Marker>("visualization_astar_goal_marker", 1);

The class nbvp::nbvPlanner when it is called creates a marker and advertize a service (nh is passed by the node) :

params_.inspectionPath_ = params.nh_.advertise<visualization_msgs::Marker>("inspectionPath", 1000);

plannerService_ = params.nh_.advertiseService("nbvplanner", &nbvp::nbvPlanner<stateVec>::plannerCallback, this);

Now here is what happens:

when I do not call nbvp::nbvPlanner (marked as a comment), I can see on RVIZ the three makers published by planner_ everything work as expected.

BUT when I call nbvPlanner, two thinks (I did not expect) happen:

  1. the makers from planner_ do not appear anyomore on rviz
  2. the service created by nbvPlanner does not show up when I do a "rosservice list" BUT the marker "inspectionPath" is visible on RVIZ

I read and read again the documentation regarding ros nodeHandle and others but I still do not understand why such behavior. I miss something, for sure, but I do not have any clue. Does somebody out there can tell me what mistake i made?

Thank you

I am running ROS Kinetic on Ubuntu 16.04

edit retag flag offensive close merge delete