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

Closure Excavator Example not using closures #82

Open
flbauer opened this issue May 15, 2023 · 0 comments
Open

Closure Excavator Example not using closures #82

flbauer opened this issue May 15, 2023 · 0 comments

Comments

@flbauer
Copy link

flbauer commented May 15, 2023

In the example excavator_rr.py closure groups are referring to geometric_XXX functions and not closure_XXX functions

Following modified functions will make the closure example work:
`def closure_q_to_a_group_1(state: Dict[str, float]):
nlp = {'x': closure_1_state[1:], 'f': c_1, 'p': closure_1_state[0]}
nlp_solver = casadi.nlpsol('q_to_a', 'ipopt', nlp, opts)
solution = nlp_solver(x0=[0, 0], p=[state['q_1']['ry']])
sol_vector = np.array(solution['x'])
return {'a_1': sol_vector[1]}

def closure_a_to_q_group_1(state: Dict[str, float]):
nlp = {'x': closure_1_state[:2], 'f': c_1, 'p': closure_1_state[2]}
nlp_solver = casadi.nlpsol('a_to_q', 'ipopt', nlp, opts)
solution = nlp_solver(x0=[0, 0], p=[state['a_1']])
sol_vector = np.array(solution['x'])
return {'q_1': {'ry': sol_vector[0]}}
...
def closure_q_to_a_group_2(state: Dict[str, float]):
nlp = {'x': closure_2_state[1:], 'f': c_2, 'p': closure_2_state[0]}
nlp_solver = casadi.nlpsol('q_to_a', 'ipopt', nlp, opts)
solution = nlp_solver(x0=[0, 0], p=[state['q_2']['ry']])
sol_vector = np.array(solution['x'])
return {'a_2': sol_vector[1]}

def closure_a_to_q_group_2(state: Dict[str, float]):
nlp = {'x': closure_2_state[:2], 'f': c_2, 'p': closure_2_state[2]}
nlp_solver = casadi.nlpsol('a_to_q', 'ipopt', nlp, opts)
solution = nlp_solver(x0=[0, 0], p=[state['a_2']])
sol_vector = np.array(solution['x'])
return {'q_2': {'ry': sol_vector[0]}}

closure_group_1 = KinematicGroup(name="geometric group 1",
virtual_chain=[virtual_joint_1, link_1],
actuated_state={'a_1': 0},
actuated_to_virtual=closure_a_to_q_group_1,
virtual_to_actuated=closure_q_to_a_group_1)

closure_group_2 = KinematicGroup(name="geometric group 2",
virtual_chain=[virtual_joint_2, link_2],
actuated_state={'a_2': 0},
actuated_to_virtual=closure_a_to_q_group_2,
virtual_to_actuated=closure_q_to_a_group_2,
parent=geometric_group_1)

`

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

No branches or pull requests

1 participant