Ejemplo n.º 1
0
    bool initialize(int argc, char ** argv)
    {
        ros::init (argc, argv, "SegmenationAndClassificationDemo");
        n_ = new ros::NodeHandle ( "~" );

        std::string service_name_seg = "/pcl_segmentation_service/pcl_segmentation";
        std::string service_name_classify = "/classifier_service/classify";
        srv_client_seg = n_->serviceClient<segmentation_srv_definitions::segment>(service_name_seg);
        srv_client_classify = n_->serviceClient<classifier_srv_definitions::classify>(service_name_classify);

        n_->getParam ( "input_method", input_method_ );

        if ( input_method_ == 0 )
        {
            if(!n_->getParam ( "topic", topic_ ))
            {
                topic_ = "/camera/depth_registered/points";
            }
            std::cout << "Trying to connect to camera on topic " <<
                         topic_ << ". You can change the topic with param topic or " <<
                         " test pcd files from a directory by using input_method=1 and specifying param directory. " << std::endl;

            if ( checkKinect() )
            {
                std::cout << "Camera (topic: " << topic_ << ") is up and running." << std::endl;
                ros::Subscriber sub_pc = n_->subscribe (topic_, 1, &SegmenationAndClassifyDemo::callUsingCam, this);
                ros::spin();
            }
            else
            {
                std::cerr << "Camera (topic: " << topic_ << ") is not working." << std::endl;
                return false;
            }
        }
        else //input_method==1
        {
            if(n_->getParam ( "directory", directory_ ) && directory_.length())
            {
                callUsingFiles();
            }
            else
            {
                std::cout << "No test directory (param directory) specified. " << std::endl;
                return false;
            }
        }
        return true;
    }
    bool initialize(int argc, char ** argv)
    {
        ros::init (argc, argv, "MultiViewRecognizerDemoFromFiles");
        n_ = new ros::NodeHandle ( "~" );

        std::string service_name_sv_rec = "/multiview_recognition_service/multiview_recognition_service";
        sv_rec_client_ = n_->serviceClient<recognition_srv_definitions::recognize>(service_name_sv_rec);

        n_->getParam ( "input_method", input_method_ );

        if ( input_method_ == 0 )
        {
            if(!n_->getParam ( "topic", topic_ ))
            {
                topic_ = "/camera/depth_registered/points";
            }
            std::cout << "Trying to connect to camera on topic " <<
                         topic_ << ". You can change the topic with param topic or " <<
                         " test pcd files from a directory by using input_method=1 and specifying param directory. " << std::endl;

            if ( checkKinect() )
            {
                std::cout << "Camera (topic: " << topic_ << ") is up and running." << std::endl;
                ros::Subscriber sub_pc = n_->subscribe (topic_, 1, &MultiViewRecognizerDemo::callMvRecognizerUsingCam, this);
                ros::spin();
            }
            else
            {
                std::cerr << "Camera (topic: " << topic_ << ") is not working." << std::endl;
                return false;
            }
        }
        else //input_method==1
        {
            if(n_->getParam ( "directory", directory_ ) && directory_.length())
            {
                callMvRecognizerUsingFiles();
            }
            else
            {
                std::cout << "No test directory (param directory) specified. " << std::endl;
                return false;
            }
        }
        return true;
    }
Ejemplo n.º 3
0
 bool initialize(int argc, char ** argv)
 {
   checkKinect();
   return KINECT_OK_;
 }