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
Allocate memory for components and handles #207
Conversation
While working on the tests, I am still not totally convinced that this is the best way of initializing hardware. To sketch the problem real quick: in the URDF, we have something like: ...
<joint name="joint3"> // note the 3 here
<command_interface name="velocity"/>
<state_interface name="position"/> // note the "position" here
<state_interface name="velocity"/>
</joint>
<joint name="joint4">
<command_interface name="velocity"/>
<state_interface name="position"/>
<state_interface name="velocity"/>
</joint>
... The hardware implementation however has something like this: std::vector<StateHandle> export_state_handles()
{
std::vector<StateHandle> handles;
// implementation is free to put in arbitrary values here
// "joint3" turns into "joint1", "position" becomes "pos", order between velocity and position is changed.
// same for "joint4"
handles.push_back(StateHandle("joint1", "velocity", &velocity_ptr[0]));
handles.push_back(StateHandle("joint1", "pos", &position_ptr[0])); <-- "position" turns into "pos"
handles.push_back(StateHandle("joint2", "velocity", &velocity_ptr[0]));
handles.push_back(StateHandle("joint2", "position", &position_ptr[0]));
} The implementation is free to export its the data to its best knowledge and I even think that's preferred, because they'd know best what to export and what not. What I propose here is that we introduce some sort of remapping. That is, even though the hardware implementation exports "joint1/pos", we can remap this via the URDF to "joint3/position". <joint name="joint3">
<remap from="pos" to="position"/>
</joint>
<joint name="joint4">
<remap from="pos" to="position"/>
</joint> The remapping for the actual joint name can be done implicitly by respecting the order of the handles. This yet brings the risk that we introduce a strict ordering of the joints within the URDF, but I believe that's doable. With that remapping in place, the following handles would be exported: What do you think? I am happy for any other suggestions. |
The standard interfaces ("position", "velocity", "effort) I propose to define constants. See #140 (this file)[https://github.com/ros-controls/ros2_control/blob/6b0aca3b4d406147f1b527115c9140f2c018720f/hardware_interface/include/hardware_interface/types/hardware_interface_type_values.hpp]. Using those, we make life easier for the people using standard ros2_control stuff but still enable developers to do their own "proprietary" thing if they want to. Although using remapping is interesting, it adds unnecessary complexity, especially with the specific order of interface. This could lead to many errors/unwanted behaviors. |
That makes it easier for the interfaces, not for the actual joint names. I think it's a good idea to have these defaults, but it's still a string comparison in the end, where typos or deviations from the conventions can be made. In this case I believe a remapping makes things easier to reuse controller code.
How would you remap the joints then? The idea of having the hardware components is that I can flexibly compose a new hardware setup with these components. That however also means that the joint names are different in each setup. We've quickly touched that with @bmagyar and the only option I see so far is to rely on the joint order specified in the URDF. |
5a27bf8
to
4570e39
Compare
I think that enforcing strict ordering in a hw component should be a design choice for those components, not part of the framework. The remapping idea is nice but I think we should still keep the original setup as it's super clear what's happening. Yes, ultimately it is the hardware that exports those handles but the resource manager and the rest of the framework shouldn't entirely be at the mercy of it. The Your proposal enforces each component implementation to have a string-based internal representation which may not be necessary. Similarly, if you have string-based internals, you could support remapping with the existing setup by forwarding the relevant XML snippet to the specific component at hand. We - as in ResourceManager - can parse what we need from the URDF, the component itself can also read it and figure out what to do with it on it's own.
For development, debug use and runtime introspection, we could extend the top level interface with a new function that'd print diagnostics in a pre-defined format, something along the lines of:
Plus components could be encouraged to document their own configuration parameters for the URDF. |
9f82e64
to
608ad83
Compare
0db9f00
to
5f084f6
Compare
5f084f6
to
310d320
Compare
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
01b9341
to
f2e9432
Compare
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## remodel_component_interfaces #207 +/- ##
================================================================
+ Coverage 33.33% 34.74% +1.41%
================================================================
Files 44 50 +6
Lines 2622 2855 +233
Branches 1675 1783 +108
================================================================
+ Hits 874 992 +118
- Misses 256 287 +31
- Partials 1492 1576 +84
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I opted for a simple (and optional) validation function in order to validate that all specified command and state interfaces in the URDF are indeed existing after all hardware components are loaded. this is ready for review in order to keep the diff somehow comprehensible. |
In order to push things forward, I'll go ahead and merge this. @bmagyar please feel free to open up a follow up ticket if you're requested changes were not appropriately addressed within here. |
Thanks for the note, looks all good |
Third part of #164
implements the resource manager and the allocation for the hardware components and their handles.
sits on top of #223