ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You aren't calling ros::spin anywhere and the main thread of the program is blocking so the necessary callbacks aren't ever occurring. Adding an AsynSpinner is the right way to go. This code works for me:

#include <ros/ros.h>

#include <arm_navigation_msgs/SetPlanningSceneDiff.h>
#include <planning_environment/models/collision_models_interface.h>

int main(int argc, char **argv) {
  ros::init(argc, argv, "planning_scene_test_node");
  ros::NodeHandle n;

  ros::AsyncSpinner spinner(1); 

  ros::ServiceClient scene_client =
  ROS_INFO("Waiting for planning scene service");
  ROS_INFO("Planning scene service is now available");

  planning_environment::CollisionModelsInterface cmi("robot_description");
  arm_navigation_msgs::SetPlanningSceneDiff ssd;
  if (! {
    ROS_ERROR("Unable to set planning scene");
    return 1;
  ROS_INFO("Successfully set planning scene");
  return 0;