コード例 #1
0
ファイル: laser_nav.cpp プロジェクト: astronaut71/Navigation
int main(int argc, char **argv)
{
  ros::init(argc, argv, "lazorzzz"); 
  ros::NodeHandle nh;

  setup();

  ros::Subscriber sub = nh.subscribe("scan_throttle", 1, scan_cb);
  pub = nh.advertise<std_msgs::Bool>("laser_obs", 1);

//----------------------------------------------------------------
  scan_pub = nh.advertise<sensor_msgs::LaserScan>("scan2", 1);
  scan_pub2 = nh.advertise<sensor_msgs::LaserScan>("scan3", 1);
  scanout.ranges.resize(800); leaderless.ranges.resize(800);
//----------------------------------------------------------------

  ros::Rate spin_rate(10);
  //ros::spin(); 
  while(ros::ok())
  {
	ros::spinOnce();
	//spin_rate.sleep();
  }
  return 0;
}
コード例 #2
0
ファイル: nodelet.cpp プロジェクト: wmeeusse/kobuki
 void update()
 {
   ros::Rate spin_rate(10);
   controller_->enable(); // enable the controller when loading the nodelet
   while (! shutdown_requested_ && ros::ok())
   {
     controller_->spin();
     spin_rate.sleep();
   }
 }
コード例 #3
0
ファイル: sound_sender.cpp プロジェクト: fudger/tulip
/// Reads the parameters given by the dynamic reconfigure server 
/// and publishes corresponding sound messages.
int main(int argc, char** argv)
{
    ros::init(argc, argv, "sound_sender");
    
    // Create the dynamic reconfigure server.
    typedef dynamic_reconfigure::Server<sound_sender::SoundSenderConfig> 
            ReconfigureServer;
    ReconfigureServer reconfigure_server;
    ReconfigureServer::CallbackType callback_function;
    callback_function = boost::bind(&reconfigure_callback, _1, _2);
    reconfigure_server.setCallback(callback_function);
    
    // Create the sound message publisher.
    ros::NodeHandle nh;
    ros::Publisher publisher = nh.advertise<sound_msg::sound>("sound", 100);
    
    // Publish messages and process reconfiguration requests.
    ros::Rate spin_rate(10);        // 10 Hz.
    while (ros::ok())
    {
        // Create a sound message.
        sound_msg::sound msg;
        msg.header.stamp = ros::Time::now();
        msg.header.frame_id = "/world";
        msg.file        = file;
        msg.volume      = volume;
        msg.pitch       = pitch;
        msg.position.x  = x;
        msg.position.y  = y;
        msg.position.z  = z;
        msg.channel     = file;
        
        // Put the message in the publisher's queue.
        if (new_sound || repeat)
        {
            publisher.publish(msg);
            new_sound = false;
        }
        
        // Process messages and reconfigure requests.
        ros::spinOnce();
        
        spin_rate.sleep();
    }
    
    return EXIT_SUCCESS;
}
コード例 #4
0
int main(int argc, char **argv)
{
  ros::init(argc, argv, "depth_img_listener");
  ros::NodeHandle nh;

  setup();

  cv::namedWindow("show"); cv::namedWindow("show2"); 
  cv::startWindowThread(); cv::setMouseCallback("show", mouse_cb, NULL);

  image_transport::ImageTransport it(nh);
  image_transport::Subscriber d_sub = it.subscribe("camera/depth/image_rect", 1, depthCallback);
  image_transport::Subscriber i_sub = it.subscribe("camera/rgb/image_raw", 1, imageCallback);
  pub = nh.advertise<std_msgs::Bool>("kinect_obs", 1);

  ros::Rate spin_rate(10);
  while(ros::ok())
  {
	ros::spinOnce();
	spin_rate.sleep();
  }
  cv::destroyWindow("show"); cv::destroyWindow("show2");
  return 0;
}