initial commit

This commit is contained in:
Sem van der Hoeven
2023-03-03 10:15:52 +00:00
parent 04f6afc9fa
commit d23d11e0b6
29 changed files with 675 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
#include <chrono> //time measurement
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"
using namespace std::chrono_literals;
class HeightSensorPublisher : public rclcpp::Node
{
public:
HeightSensorPublisher() : Node("height_sensor_publisher")
{
publisher_ = this->create_publisher<std_msgs::msg::String>("height_sensor", 10);
timer_ = this->create_wall_timer(
500ms, std::bind(&HeightSensorPublisher::timer_callback, this));
}
private:
void timer_callback()
{
auto message = std_msgs::msg::String();
message.data = "Hello heigth sensor!";
RCLCPP_INFO(this->get_logger(), "Publishing: %s", message.data.c_str());
publisher_->publish(message);
}
rclcpp::TimerBase::SharedPtr timer_;
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr publisher_;
};
int main(int argc, char *argv[])
{
rclcpp::init(argc,argv);
rclcpp::spin(std::make_shared<HeightSensorPublisher>());
rclcpp::shutdown();
return 0;
}