Skip to content

Commit 6be0d53

Browse files
committed
Added test file
1 parent 12360ec commit 6be0d53

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

mission/Landmark_server/test.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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'", msg.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+
}

0 commit comments

Comments
 (0)