-
Notifications
You must be signed in to change notification settings - Fork 312
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
add a semantic command interface to "semantic_components" #1945
base: master
Are you sure you want to change the base?
add a semantic command interface to "semantic_components" #1945
Conversation
RQ: not build yet, issue with rest of repos for build. Will rebase on previous TAG for now.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1945 +/- ##
==========================================
+ Coverage 89.35% 89.36% +0.01%
==========================================
Files 130 136 +6
Lines 14576 14690 +114
Branches 1258 1264 +6
==========================================
+ Hits 13024 13128 +104
- Misses 1088 1090 +2
- Partials 464 472 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I've thought about it a little bit, and I'm not sure if we should add such a component when the GPIO command controller, which is very generic, is already available |
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 PR including nice tests .
We discussed this shortly in todays WG meeting, and approve this addition.
I can understand the input @Wiktor-99, but imho
- it is an obvious extension of an existing concept
- it could also use joints and not only gpios
Please add it to the release_notes and some minor comments.
controller_interface/test/test_semantic_component_command_interface.cpp
Outdated
Show resolved
Hide resolved
controller_interface/include/semantic_components/led_rgb_device.hpp
Outdated
Show resolved
Hide resolved
Great! |
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.
LGTM overall, I just added some comments to be in line with #1940
Maybe you have to format my suggestions once again to satisfy pre-commit.
controller_interface/include/semantic_components/led_rgb_device.hpp
Outdated
Show resolved
Hide resolved
controller_interface/include/semantic_components/semantic_component_command_interface.hpp
Outdated
Show resolved
Hide resolved
controller_interface/include/semantic_components/semantic_component_command_interface.hpp
Outdated
Show resolved
Hide resolved
controller_interface/include/semantic_components/semantic_component_command_interface.hpp
Outdated
Show resolved
Hide resolved
controller_interface/include/semantic_components/led_rgb_device.hpp
Outdated
Show resolved
Hide resolved
…e.hpp Co-authored-by: Christoph Fröhlich <[email protected]>
…onent_command_interface.hpp Co-authored-by: Christoph Fröhlich <[email protected]>
…onent_command_interface.hpp Co-authored-by: Christoph Fröhlich <[email protected]>
…onent_command_interface.hpp Co-authored-by: Christoph Fröhlich <[email protected]>
…e.hpp Co-authored-by: Christoph Fröhlich <[email protected]>
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.
Something still seems to be broken with the tests, can you have a look please?
My bad, hadn't rerun the unit tests after accepting the change suggestions (minor issue with LED constructor). |
explicit SemanticComponentCommandInterface(const std::string & name, size_t size = 0) | ||
: name_(name) | ||
{ | ||
interface_names_.reserve(size); | ||
command_interfaces_.reserve(size); | ||
} |
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.
May be we can remove this Constructor. The first one seems more intuitive
/** | ||
* Constructor for a LED RGB device with custom interface names. | ||
* The constructor takes the three command interface names for the red, green, and blue channels. | ||
*/ | ||
explicit LedRgbDevice( | ||
const std::string & interface_r, const std::string & interface_g, | ||
const std::string & interface_b) | ||
: SemanticComponentCommandInterface("", 3) | ||
{ | ||
interface_names_.emplace_back(interface_r); | ||
interface_names_.emplace_back(interface_g); | ||
interface_names_.emplace_back(interface_b); | ||
} |
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.
As specified, may be this can be ruled out.
/** | ||
* \return false by default | ||
*/ | ||
bool set_values_from_message(const MessageInputType & /* message */) { return false; } |
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.
bool set_values_from_message(const MessageInputType & /* message */) { return false; } | |
virtual bool set_values_from_message(const MessageInputType & /* message */) = 0; |
Maybe we can make it pure virtual method, so all derived methods will be forced to implement this. What do you think? @christophfroehlich
controller_interface/include/semantic_components/semantic_component_command_interface.hpp
Show resolved
Hide resolved
if (interface_names_.empty()) | ||
{ | ||
for (auto i = 0u; i < interface_names_.capacity(); ++i) | ||
{ | ||
interface_names_.emplace_back(name_ + "/" + std::to_string(i + 1)); | ||
} | ||
} |
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.
if (interface_names_.empty()) | |
{ | |
for (auto i = 0u; i < interface_names_.capacity(); ++i) | |
{ | |
interface_names_.emplace_back(name_ + "/" + std::to_string(i + 1)); | |
} | |
} |
If the interfaces are not set, then assign_loaned_command_interfaces
should be getting nothing and it wouldn't make sense at all
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.
It was done as to maintain symmetry with the SemanticComponentInterface
:
ros2_control/controller_interface/include/semantic_components/semantic_component_interface.hpp
Lines 70 to 80 in f4c9dd0
virtual std::vector<std::string> get_state_interface_names() | |
{ | |
if (interface_names_.empty()) | |
{ | |
for (auto i = 0u; i < interface_names_.capacity(); ++i) | |
{ | |
interface_names_.emplace_back(name_ + "/" + std::to_string(i + 1)); | |
} | |
} | |
return interface_names_; | |
} |
However, it is true that the use case is debatable (in both cases).
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.
Yup, I agree. As this is the new one that we are introducing, it is better to have it the proper way
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 thought a bit more about it. It is actually (kind of) OK since the assign_loaned_state_interfaces
function calls the getter, so interface names are, at the latest, filled at that stage:
ros2_control/controller_interface/include/semantic_components/semantic_component_interface.hpp
Lines 51 to 56 in f4c9dd0
bool assign_loaned_state_interfaces( | |
std::vector<hardware_interface::LoanedStateInterface> & state_interfaces) | |
{ | |
return controller_interface::get_ordered_interfaces( | |
state_interfaces, interface_names_, "", state_interfaces_); | |
} |
It's not ideal, but at the same time there is no reason, in theory, to overload the assign_loaned_state_interfaces
method.
The alternative would consist in assigning the default names in the constructor, but that might be tricky to manage, since this constructor is meant to be specialized by child classes that will push into the std::vector
.
That would mean accessing the interface names by index from the constructor of inherited classes, since the vector would already be filled.
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.
@saikishor What about declaring the assign_loaned_state_interfaces
and get_ordered_interfaces
methods as final
?
controller_interface/include/semantic_components/semantic_component_command_interface.hpp
Outdated
Show resolved
Hide resolved
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.
Other than dropping the library LGTM.
controller_interface/include/semantic_components/led_rgb_device.hpp
Outdated
Show resolved
Hide resolved
…onent_command_interface.hpp Co-authored-by: Sai Kishor Kothakota <[email protected]>
- mark as virtual - fix missing const ref - add method docstring
controller_interface/include/semantic_components/led_rgb_device.hpp
Outdated
Show resolved
Hide resolved
@tpoignonec Can you please fix the pre-commit jobs? |
Hi,
Is there any interest in defining a
SemanticComponentCommandInterface
analogous to theSemanticComponentInterface
, but for hardware command interfaces?Applications could include, among others, commonly used simple write-only devices such as LED, buzzers, beepers, etc.
It could also be used for GPIO arrays the same way the state interface can be used to read them in a standarized fashion.
This PR includes such a semantic component, as well as a basic example with a 3-channel (R/G/B) LED with two scenarios:
<name>/r
,<name>/g
, and<name>/b
Additionally, basic tests are proposed.