This repository has been archived by the owner on Mar 23, 2024. It is now read-only.
-
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
Showing
9 changed files
with
97 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Configuration that disables everything | ||
# Allows us to overload the config:=... arguments such that we only launch certain nodes (useful for integration testing) | ||
network_systems: | ||
can_transceiver_node: | ||
ros__parameters: | ||
enabled: false | ||
|
||
can_transceiver_sim_node: | ||
ros__parameters: | ||
enabled: false | ||
|
||
cached_fib_subscriber: | ||
ros__parameters: | ||
enabled: false | ||
|
||
local_transceiver_node: | ||
ros__parameters: | ||
enabled: false | ||
|
||
mock_ais_node: | ||
ros__parameters: | ||
enabled: false | ||
|
||
remote_transceiver_node: | ||
ros__parameters: | ||
enabled: false |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Configuration that enables the cached_fib example module | ||
network_systems: | ||
cached_fib_subscriber: | ||
cached_fib_node: | ||
ros__parameters: | ||
enabled: true |
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,57 @@ | ||
// Include this module | ||
#include "cached_fib.h" | ||
// Include ROS headers | ||
#include <rclcpp/rclcpp.hpp> | ||
#include <std_msgs/msg/u_int64.hpp> | ||
|
||
namespace | ||
{ | ||
constexpr int ROS_Q_SIZE = 10; | ||
constexpr int INIT_FIB_SIZE = 5; | ||
} // namespace | ||
|
||
class CachedFibNode : public rclcpp::Node | ||
{ | ||
public: | ||
explicit CachedFibNode(const std::size_t initSize) : Node("cached_fib_node"), c_fib_(initSize) | ||
{ | ||
this->declare_parameter("enabled", false); | ||
bool enabled = this->get_parameter("enabled").as_bool(); | ||
if (enabled) { | ||
RCLCPP_INFO(this->get_logger(), "Running example cached fib node"); | ||
|
||
// This registers a callback function that gets called whenever CACHED_FIB_TOPIC_IN gets updated | ||
sub_ = this->create_subscription<std_msgs::msg::UInt64>( | ||
CACHED_FIB_TOPIC_IN, ROS_Q_SIZE, std::bind(&CachedFibNode::subCb, this, std::placeholders::_1)); | ||
|
||
pub_ = this->create_publisher<std_msgs::msg::UInt64>(CACHED_FIB_TOPIC_OUT, ROS_Q_SIZE); | ||
} | ||
} | ||
|
||
private: | ||
CachedFib c_fib_; | ||
rclcpp::Subscription<std_msgs::msg::UInt64>::SharedPtr sub_; | ||
rclcpp::Publisher<std_msgs::msg::UInt64>::SharedPtr pub_; | ||
|
||
/** | ||
* @brief Callback function that runs whenever the subscribed topic is updated | ||
* | ||
* @param in_msg msg that was sent to the topic | ||
*/ | ||
void subCb(const std_msgs::msg::UInt64::SharedPtr in_msg) | ||
{ | ||
int fibNum = this->c_fib_.getFib(in_msg->data); | ||
RCLCPP_INFO(this->get_logger(), "Fib num for '%lu' is '%d'", in_msg->data, fibNum); | ||
std_msgs::msg::UInt64 out_msg{}; | ||
out_msg.data = fibNum; | ||
pub_->publish(out_msg); | ||
} | ||
}; | ||
|
||
int main(int argc, char * argv[]) | ||
{ | ||
rclcpp::init(argc, argv); | ||
rclcpp::spin(std::make_shared<CachedFibNode>(INIT_FIB_SIZE)); | ||
rclcpp::shutdown(); | ||
return 0; | ||
} |
This file was deleted.
Oops, something went wrong.