-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add healthcheck to simulation * Add healthcheck hardware * Timeout * New version of Healthcheck * fix * timeout * Fix first healthcheck running * Add entrypoint * Delete debug msg * refactor * Delete ros_entrypoint * Update ros-docker-image.yaml * delete std_msgs * fix flash rw unprotecting * small ux change in flash rw unprotecting Signed-off-by: Jan Brzyk <[email protected]> * small firmware flashing fix Signed-off-by: Jan Brzyk <[email protected]> * firmware flashing fix Signed-off-by: Jan Brzyk <[email protected]> * Fix Vulcannexus healthcheck --------- Signed-off-by: Jan Brzyk <[email protected]> Co-authored-by: dominikn <[email protected]> Co-authored-by: Jan Brzyk <[email protected]>
- Loading branch information
1 parent
7f18f3f
commit f5a70da
Showing
8 changed files
with
161 additions
and
50 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
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,47 @@ | ||
#include "fstream" | ||
#include "nav_msgs/msg/odometry.hpp" | ||
#include "rclcpp/rclcpp.hpp" | ||
|
||
using namespace std::chrono_literals; | ||
|
||
#define LOOP_PERIOD 2s | ||
#define MSG_VALID_TIME 5s | ||
|
||
std::chrono::steady_clock::time_point last_msg_time; | ||
|
||
void write_health_status(const std::string &status) { | ||
std::ofstream healthFile("/health_status.txt"); | ||
healthFile << status; | ||
} | ||
|
||
void msg_callback(const nav_msgs::msg::Odometry::SharedPtr msg) { | ||
last_msg_time = std::chrono::steady_clock::now(); | ||
} | ||
|
||
void healthy_check() { | ||
std::chrono::steady_clock::time_point current_time = | ||
std::chrono::steady_clock::now(); | ||
std::chrono::duration<double> elapsed_time = current_time - last_msg_time; | ||
bool is_msg_valid = elapsed_time.count() < MSG_VALID_TIME.count(); | ||
|
||
if (is_msg_valid) { | ||
write_health_status("healthy"); | ||
} else { | ||
write_health_status("unhealthy"); | ||
} | ||
} | ||
|
||
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>( | ||
"odometry/filtered", rclcpp::SensorDataQoS(), msg_callback); | ||
|
||
while (rclcpp::ok()) { | ||
rclcpp::spin_some(node); | ||
healthy_check(); | ||
std::this_thread::sleep_for(LOOP_PERIOD); | ||
} | ||
|
||
return 0; | ||
} |
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,17 @@ | ||
#!/bin/bash | ||
|
||
HEALTHCHECK_FILE="/health_status.txt" | ||
|
||
|
||
# Now check the health status | ||
if [ -f "$HEALTHCHECK_FILE" ]; then | ||
status=$(cat "$HEALTHCHECK_FILE") | ||
if [ "$status" == "healthy" ]; then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi | ||
else | ||
echo "Healthcheck file still not found. There may be an issue with the node." | ||
exit 1 | ||
fi |
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