-
Notifications
You must be signed in to change notification settings - Fork 233
[Example 17] RRBot with Hardware Component that publishes diagnostics #840
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
base: master
Are you sure you want to change the base?
Conversation
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.
Thanks for the nice demo.
diagnostics
usually refers to ros/diagnostics. Should we include this here instead of simple rclcpp publishers, or rename the demo to something else?
ooh, I think since this is not particularly about diagnostics maybe it would be better to rename. would |
I like diagnostics and use it from my hardware components, so maybe this would be also good to use here? we have it already in the CM, this is no new dependency then. |
makes sense, I will use diagnostive for one of the publishers then, does that make sense? or both? |
example_17/hardware/rrbot.cpp
Outdated
// Get Default Node added to executor | ||
if (get_node()) | ||
{ | ||
default_status_publisher_ = | ||
get_node()->create_publisher<diagnostic_msgs::msg::DiagnosticArray>("/diagnostics", 10); | ||
auto default_timer_callback = [this]() -> void | ||
{ | ||
if (default_status_publisher_) | ||
{ | ||
auto diagnostic_msg = std::make_unique<diagnostic_msgs::msg::DiagnosticArray>(); | ||
diagnostic_msg->header.stamp = get_node()->now(); | ||
diagnostic_msg->status.resize(1); | ||
|
||
// Populate the status | ||
diagnostic_msg->status[0].level = diagnostic_msgs::msg::DiagnosticStatus::OK; | ||
diagnostic_msg->status[0].name = this->get_name(); | ||
diagnostic_msg->status[0].message = "Hardware is OK"; | ||
|
||
// Publish the message | ||
default_status_publisher_->publish(std::move(diagnostic_msg)); | ||
} | ||
}; | ||
using namespace std::chrono_literals; | ||
default_status_timer_ = get_node()->create_wall_timer(2.5s, default_timer_callback); | ||
} |
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.
Instead, we could use the diagnostic_updater class, which handles the timer creation etc itself?
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.
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.
Thx!
example_17/doc/userdoc.rst
Outdated
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.
now there is a third option, using a custom publisher with the default node? As you were describing it before? No need to implement that, but maybe mention it here?
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.
let me know if ac36157 works
General
This is an example to document the usage of the Executor passed from Controller Manager through the recently added Struct based
on_init()
methods. Made possible by ros-controls/ros2_control#2323as a further update that will be added in ros-controls/ros2_control#2348, this will also show how to use the default node added by the framework
This allows the user to add nodes of their own to the CMs executor and publish as necessary