Action send_goal: add velocity parameter handling #763
+107
−13
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.
What does this PR do?
Draft PR adding handling of the velocity parameter of ros2 action send_goal. Due to a big amount of ifology present in handling edge-cases of manipulation, this PR does not work properly for now: that's why i changed its status to draft.
How it worked previously
In previous implementation, after receiving a goal, joints trajectory component would order each joint and articulation to go straight to the goal position, without taking velocity parameter into consideration at all. This would result in joints and articulations speed depending only on force limit, damping, stiffness vaules etc, without any option to adjust the speed by user.
How it works with this PR
In my proposed implementation, joints trajectory component splits the path of the joint into smaller parts, ordering joints to go to the next checkpoint each tick. This way, it is guaranteed for the joints to move with the requested velocity at max. Keep in mind that actual velocity of the joint will not always reflect requested one: joints have their inertia and need to gain speed, they can't exceed their max velocity, etc.
Edge case handling
Changing the implementation requires caution when handling some edge cases, especially when send_goal action is used in a non-standard way:
Changes in usage implied by this PR
Adding velocity parameter handling is useful, but keep in mind that with great power comes great responsibility. As velocity can be both positive and negative, before ordering a joint to move to position x, you'll have to check if its current position is greater or lower and set the velocity to positive or negative integer accordingly. Otherwise, the joint will move in the opposite direction, till it reaches the goal from the other side, reaches its limit or meets the time limit of execution. Keep in mind that this is not a change that serves just for simplifying that implementation of this PR: using negative velocities is crucial for MoveIt to work.
How was this PR tested?
This PR does not work yet and a deeper dive into the edge-case handling is necessary. I recommend caution when merging, even after correcting and testing this PR as it severely changes the usage of the send_goal action and any small mistake could cause joints and articulations to behave in the least expected ways.