Skip to content
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

Feature: Custom python functions for dependent joints #64

Open
wants to merge 2 commits into
base: noetic-devel
Choose a base branch
from

Conversation

Rogerpi
Copy link

@Rogerpi Rogerpi commented Aug 31, 2021

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.

gripper_example

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant