ros-controls / ros2_control

Generic and simple controls framework for ROS 2
https://control.ros.org
Apache License 2.0
512 stars 304 forks source link

Mocking: map command interface to state interface of different types #885

Closed tonynajjar closed 1 year ago

tonynajjar commented 1 year ago

Is your feature request related to a problem? Please describe.

I have a prismatic joint with one velocity command interface and one position state interface. In real world this translates to one linear actuator + a distance sensor tracking the tip. I was able to create a controller for it. My problem is in running this controller in "simple simulation" with the GenericSystem. Mirroring the command and state interfaces of the same type does not make sense here, what I need is for the velocity commands to be integrated and mapped to the position state interface - this would represent an idealistic simulation.

Do you think this is something that can be supported by the GenericSystem or should I create my own hardware interface that does this?

destogl commented 1 year ago

I have a prismatic joint with one velocity command interface and one position command interface.

Do you mean “velocity command interface and one position state interface”?

There is a PR from @livanov93 #540 that we never managed to polish out and finish. Maybe is that the best place to start. I would also need this, just didn't found time for it yet

tonynajjar commented 1 year ago

Definitely yes, edited. Thanks

destogl commented 1 year ago

@tonynajjar please check my edited comment

tonynajjar commented 1 year ago

I see. I still do wonder if it's a good idea to open up this door; the question if we implement this is where does it stop? What about deriving velocity from position (in the case of position command interface and velocity state interface)? Throw in acceleration in the mix and you have more combinations.

Do you think this is something that can be supported by the GenericSystem or should I create my own hardware interface that does this?

That's why I was asking this question. Perhaps the GenericSystem should stay as is but have an option to extend it?

destogl commented 1 year ago

I would personally like to have this. I had it already multiple times when this would be very handy. Implementing this we are covering 98+ % use-cases, from my experience having acceleration commanding interface is not so common – but we can know that first when we try it.

So, yes I would go down this path. I am pretty sure we will not get many questions about doing other crazy things there.

christophfroehlich commented 1 year ago

I too tripped over this missing feature just now ^^ (velocity command -> integration to position state)

If no one is working on this right now, I'll have a look on the work from @livanov93 and make a PR for rolling. But maybe I just cherry pick the integration-part first.

tonynajjar commented 1 year ago

Does https://github.com/ros-controls/ros2_control/pull/1028 close this ticket or is there something missing? (I haven't tested it yet but it's in backlog)

christophfroehlich commented 1 year ago

I tested the same configuration as you were describing in the beginning with the latest feature -> I think we can close this as fixed!

tonynajjar commented 1 year ago

Following up on this, you have one more successful test from my side :+1: