Advertisement

ROS:订阅者程序

阅读量:

(一):C++编程代码

复制代码
 #include<ros/ros.h>

    
 #include<turtlesim/Pose.h>
    
 #include<iomanip>
    
  
    
  
    
 void poseMessageReceived(const turtlesim::Pose & msg)
    
 {
    
 	ROS_INFO_STREAM(std::setprecision(2) << std::fixed
    
 		<< " position =(" << msg.x << " , " << msg.y << " ) "
    
 		<< " *direction=" << msg.theta);
    
 }
    
  
    
  
    
 int main(int argc, char** argv)
    
 {
    
 	ros::init(argc, atgv, "subscribe_to_pose");
    
 	ros::NodeHandle nh;
    
  
    
 	ros::Subscriber sub = nh.subscribe("turtle1/pose", 1000,
    
 		&poseMessageReceived);
    

全部评论 (0)

还没有任何评论哟~