File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ //  /home/philliab/ros2_ws/src/vortex-auv/mission/Landmark_server/test.cpp
2+ #include  < chrono> 
3+ #include  < memory> 
4+ #include  < string> 
5+ 
6+ #include  " rclcpp/rclcpp.hpp" 
7+ #include  " std_msgs/msg/string.hpp" 
8+ 
9+ using  namespace  std ::chrono_literals; 
10+ 
11+ class  LandmarkServer  : public  rclcpp ::Node
12+ {
13+ public: 
14+     LandmarkServer ()
15+     : Node(" landmark_server" 
16+     {
17+         RCLCPP_INFO (this ->get_logger (), " landmark_server node started" 
18+ 
19+         pub_ = this ->create_publisher <std_msgs::msg::String>(" chatter" 10 );
20+ 
21+         timer_ = this ->create_wall_timer (500ms, [this ]() {
22+             auto  msg = std_msgs::msg::String ();
23+             msg.data  = " hello from landmark_server" 
24+             pub_->publish (msg);
25+             RCLCPP_DEBUG (this ->get_logger (), " published: '%s'" data .c_str ());
26+         });
27+     }
28+ 
29+ private: 
30+     rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_;
31+     rclcpp::TimerBase::SharedPtr timer_;
32+ };
33+ 
34+ int  main (int  argc, char  ** argv)
35+ {
36+     rclcpp::init (argc, argv);
37+     rclcpp::spin (std::make_shared<LandmarkServer>());
38+     rclcpp::shutdown ();
39+     return  0 ;
40+ }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments