Feature: Custom python functions for dependent joints #64
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.
Right now, dependent joints can be set using a simple formula: joint = parent_joint * factor + offset
However, in a lot of cases this relationship is not enough, especially for grippers. For example, it is common to deal with different grippers actuated by prismatic pistons.
This pull request allows to write custom python functions that are evaluated in runtime. Inside the dependent_joints map, by tag "fun". The parent joint value has the reserved variable name "parent_position". The final value must be stored in the reserved variable "position". Variables are allowed to be set inside the map too.
Example:
dependent_joints:
finger_1: {parent: piston_joint,
z1: 0.03636756796927724,
z2: 0.025,
q_off: -0.820403314,
fun: "position = (-2.0 * math.atan2((z1 - math.sqrt(math.pow(z1, 2) + math.pow(z2, 2) - math.pow(parent_position, 2))), (z2 - parent_position))) + q_off"
}
finger_2: {parent: finger_1, fun: "position = -1 * parent_position" }
This example is added as a test.
To avoid breaking the current functionality, if no function is provided, it uses the standard joint = parent_joint * factor + offset