-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bbbf4f
commit 55ac8a8
Showing
3 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "rclcpp/rclcpp.hpp" | ||
#include "nav_msgs/msg/odometry.hpp" | ||
#include "cstdlib" | ||
|
||
using namespace std::chrono_literals; | ||
|
||
#define TOPIC_NAME "/odometry/filtered" | ||
#define TIMEOUT 2s | ||
|
||
int msg_received = EXIT_FAILURE; | ||
|
||
void msg_callback(const nav_msgs::msg::Odometry::SharedPtr msg) | ||
{ | ||
std::cout << "Message received" << std::endl; | ||
msg_received = EXIT_SUCCESS; | ||
rclcpp::shutdown(); | ||
} | ||
|
||
void timeout_callback() | ||
{ | ||
std::cout << "Timeout" << std::endl; | ||
rclcpp::shutdown(); | ||
} | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
rclcpp::init(argc, argv); | ||
auto node = rclcpp::Node::make_shared("healthcheck_node"); | ||
auto sub = node->create_subscription<nav_msgs::msg::Odometry>(TOPIC_NAME, rclcpp::SensorDataQoS(), msg_callback); | ||
auto timer = node->create_wall_timer(TIMEOUT, timeout_callback); | ||
|
||
rclcpp::spin(node); | ||
return msg_received; | ||
} |