-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow timer rate to be configurable inmessage_lost_talker
#679
Open
Yadunund
wants to merge
4
commits into
rolling
Choose a base branch
from
yadu/configure_timer_rate_message_lost
base: rolling
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||||
---|---|---|---|---|---|---|
|
@@ -37,6 +37,7 @@ void print_usage() | |||||
"Usage: message_lost_talker [-h] [-s SIZE]\n\n" | ||||||
"optional arguments:\n" | ||||||
"\t-h: Print this help message.\n" | ||||||
"\t-r: Timer rate in Hz, default to 0.3 Hz\n" | ||||||
"\t-s <message_size>: Message size in KiB, default to 8192 KiB" << | ||||||
std::endl; | ||||||
} | ||||||
|
@@ -47,7 +48,8 @@ class MessageLostTalker : public rclcpp::Node | |||||
QUALITY_OF_SERVICE_DEMO_PUBLIC | ||||||
explicit MessageLostTalker(const rclcpp::NodeOptions & options) | ||||||
: Node("message_lost_talker", options), | ||||||
message_size_(8u * 1024u * 1024u) // 8MB | ||||||
message_size_(8u * 1024u * 1024u), // 8MB | ||||||
timer_period_(3000) // 3s period | ||||||
{ | ||||||
const std::vector<std::string> & args = this->get_node_options().arguments(); | ||||||
if (args.size()) { | ||||||
|
@@ -58,13 +60,38 @@ class MessageLostTalker : public rclcpp::Node | |||||
// exceptions. Raise one here, so stack unwinding happens gracefully. | ||||||
std::exit(0); | ||||||
} | ||||||
// Argument: timer period | ||||||
auto opt_it = std::find(args.cbegin(), args.cend(), "-r"); | ||||||
if (opt_it != args.cend()) { | ||||||
++opt_it; | ||||||
if (opt_it == args.cend()) { | ||||||
print_usage(); | ||||||
std::cout << "\n-r must be followed by a positive number" << std::endl; | ||||||
// TODO(ivanpauno): Update the rclcpp_components template to be able to handle | ||||||
// exceptions. Raise one here, so stack unwinding happens gracefully. | ||||||
std::exit(0); | ||||||
} | ||||||
std::istringstream input_stream(*opt_it); | ||||||
double timer_rate; | ||||||
input_stream >> timer_rate; | ||||||
if (!input_stream) { | ||||||
print_usage(); | ||||||
std::cout << "\n-s must be followed by a positive number, got: '" << | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
*opt_it << "'" << std::endl; | ||||||
// TODO(ivanpauno): Update the rclcpp_components template to be able to handle | ||||||
// exceptions. Raise one here, so stack unwinding happens gracefully. | ||||||
std::exit(0); | ||||||
} | ||||||
timer_period_ = std::chrono::duration_cast<std::chrono::milliseconds>( | ||||||
std::chrono::duration<double, std::ratio<1>>(1.0 / timer_rate)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if |
||||||
} | ||||||
// Argument: message size | ||||||
auto opt_it = std::find(args.cbegin(), args.cend(), "-s"); | ||||||
opt_it = std::find(args.cbegin(), args.cend(), "-s"); | ||||||
if (opt_it != args.cend()) { | ||||||
++opt_it; | ||||||
if (opt_it == args.cend()) { | ||||||
print_usage(); | ||||||
std::cout << "\n-s must be followed by a possitive integer" << std::endl; | ||||||
std::cout << "\n-s must be followed by a positive integer" << std::endl; | ||||||
// TODO(ivanpauno): Update the rclcpp_components template to be able to handle | ||||||
// exceptions. Raise one here, so stack unwinding happens gracefully. | ||||||
std::exit(0); | ||||||
|
@@ -73,7 +100,7 @@ class MessageLostTalker : public rclcpp::Node | |||||
input_stream >> message_size_; | ||||||
if (!input_stream) { | ||||||
print_usage(); | ||||||
std::cout << "\n-s must be followed by a possitive integer, got: '" << | ||||||
std::cout << "\n-s must be followed by a positive integer, got: '" << | ||||||
*opt_it << "'" << std::endl; | ||||||
// TODO(ivanpauno): Update the rclcpp_components template to be able to handle | ||||||
// exceptions. Raise one here, so stack unwinding happens gracefully. | ||||||
|
@@ -97,16 +124,19 @@ class MessageLostTalker : public rclcpp::Node | |||||
pub_->publish(msg_); | ||||||
}; | ||||||
// Create a publisher | ||||||
pub_ = this->create_publisher<sensor_msgs::msg::Image>("message_lost_chatter", 1); | ||||||
rclcpp::QoS qos{1}; | ||||||
qos.reliable(); | ||||||
pub_ = this->create_publisher<sensor_msgs::msg::Image>("message_lost_chatter", std::move(qos)); | ||||||
|
||||||
// Use a timer to schedule periodic message publishing. | ||||||
timer_ = this->create_wall_timer(3s, publish_message); | ||||||
timer_ = this->create_wall_timer(timer_period_, publish_message); | ||||||
} | ||||||
|
||||||
private: | ||||||
size_t message_size_; | ||||||
sensor_msgs::msg::Image msg_; | ||||||
rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr pub_; | ||||||
std::chrono::milliseconds timer_period_; | ||||||
rclcpp::TimerBase::SharedPtr timer_; | ||||||
}; | ||||||
|
||||||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think
RMW_EVENT_MESSAGE_LOST
is supported in rmw_fastrtps, i am not sure why that is not listed here?https://github.com/ros2/rmw_fastrtps/blob/21e6a44a2ef25ce51ece019b255427a0248fad65/rmw_fastrtps_shared_cpp/src/custom_subscriber_info.cpp#L449
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I also think it is premature to add in
rmw_zenoh_cpp
here, as it is not a Tier-1 RMW.