-
Notifications
You must be signed in to change notification settings - Fork 0
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
94a2197
commit 5303ee8
Showing
8 changed files
with
313 additions
and
251 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#ifndef HEARTBEAT_CLIENT_HPP | ||
#define HEARTBEAT_CLIENT_HPP | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
#include <boost/circular_buffer.hpp> | ||
#include <std_srvs/srv/empty.hpp> | ||
|
||
#include "csm_common_interfaces/msg/e_stop.hpp" | ||
|
||
class HeartbeatClient : public rclcpp::Node { | ||
public: | ||
/** | ||
* @brief Construct a new Heartbeat Client object | ||
* | ||
*/ | ||
HeartbeatClient(); | ||
|
||
/** | ||
* @brief Establishes connection to heartbeat server | ||
* | ||
*/ | ||
void handshake(); | ||
|
||
private: | ||
/** | ||
* @brief Checks for handshake response | ||
* | ||
*/ | ||
void handshake_callback(); | ||
|
||
/** | ||
* @brief Sends requests to server and checks if responses are sent | ||
* | ||
*/ | ||
void ping_callback(); | ||
|
||
|
||
// Time since last ping was received | ||
unsigned int _lastResponseTime; | ||
boost::circular_buffer<std::shared_future<std::shared_ptr<std_srvs::srv::Empty_Response>>> _futures; | ||
|
||
// heartbeat and handshake | ||
rclcpp::Client<std_srvs::srv::Empty>::SharedPtr handshakeClient; | ||
rclcpp::Client<std_srvs::srv::Empty>::SharedPtr heartbeatClient; | ||
|
||
// storing handshake futures and setting up timer to send requests and check for responses | ||
std::shared_future<std::shared_ptr<std_srvs::srv::Empty_Response>> _handshakeFuture; | ||
rclcpp::TimerBase::SharedPtr handshakeTimer; | ||
rclcpp::TimerBase::SharedPtr pingTimer; | ||
|
||
// the estop | ||
rclcpp::Publisher<csm_common_interfaces::msg::EStop>::SharedPtr estopPub; | ||
}; | ||
|
||
#endif // (HEARTBEAT_CLIENT_H) |
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,55 @@ | ||
#ifndef HEARTBEAT_SERVER_HPP | ||
#define HEARTBEAT_SERVER_HPP | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
#include <std_srvs/srv/empty.hpp> | ||
|
||
#include "csm_common_interfaces/msg/e_stop.hpp" | ||
|
||
class HeartbeatServer : public rclcpp::Node { | ||
public: | ||
/** | ||
* @brief Construct a new Heartbeat Server object | ||
* | ||
*/ | ||
HeartbeatServer(); | ||
|
||
private: | ||
/** | ||
* @brief Establishes connection with heartbeat client | ||
* | ||
* @param request empty request | ||
* @param response empty response | ||
*/ | ||
void handshake(std_srvs::srv::Empty::Request::SharedPtr request, std_srvs::srv::Empty::Response::SharedPtr response); | ||
|
||
/** | ||
* @brief Watches if client stops sending requests | ||
* | ||
*/ | ||
void watchdog_callback(); | ||
|
||
/** | ||
* @brief Processes requests from client | ||
* | ||
* @param request empty request | ||
* @param response empty response | ||
*/ | ||
void heartbeat_callback(std_srvs::srv::Empty::Request::SharedPtr request, std_srvs::srv::Empty::Response::SharedPtr response); | ||
|
||
// last time request was received | ||
unsigned int _lastPingTime; | ||
|
||
// handshake and heartbeat | ||
rclcpp::Service<std_srvs::srv::Empty>::SharedPtr handshakeSrv; | ||
rclcpp::Service<std_srvs::srv::Empty>::SharedPtr heartbeatSrv; | ||
|
||
// timer to periodically check for pings and send responses | ||
rclcpp::TimerBase::SharedPtr watchdog; | ||
|
||
// estop | ||
rclcpp::Publisher<csm_common_interfaces::msg::EStop>::SharedPtr estopPub; | ||
}; | ||
|
||
|
||
#endif // (HEARTBEAT_SERVER_H) |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
<package format="3"> | ||
<name>heartbeat2</name> | ||
<version>0.0.0</version> | ||
<description>establish a heartbeat between drivestation and ROV</description> | ||
<description>Establish a heartbeat between drivestation and ROV</description> | ||
<maintainer email="[email protected]">kadin</maintainer> | ||
<license>Apache-2.0</license> | ||
|
||
|
@@ -13,11 +13,9 @@ | |
<test_depend>ament_lint_common</test_depend> | ||
|
||
<depend>rclcpp</depend> | ||
<depend>builtin_interfaces</depend> | ||
<depend>std_msgs</depend> | ||
<depend>csm_common_interfaces</depend> | ||
<depend>std_srvs</depend> | ||
<depend>boost/circular_buffer</depend> | ||
<depend>boost</depend> | ||
|
||
|
||
<export> | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.