MMehrez / MPC-and-MHE-implementation-in-MATLAB-using-Casadi

This is a workshop on implementing model predictive control (MPC) and moving horizon estimation (MHE) on Matlab. The implementation is based on the Casadi Package which is used for numerical optimization. A non-holonomic mobile robot is used as a system for the implementation. The workshop video recording can be found here https://www.youtube.com/playlist?list=PLK8squHT_Uzej3UCUHjtOtm5X7pMFSgAL ... Casadi can be downloaded here https://web.casadi.org/
https://www.youtube.com/playlist?list=PLK8squHT_Uzej3UCUHjtOtm5X7pMFSgAL
335 stars 136 forks source link

Avoid obstacle in python #8

Closed RodrigoFBernardo closed 2 years ago

RodrigoFBernardo commented 2 years ago

Hi

I am taking your example in python and similar to what you do in Matlab, I want my robot to avoid the obstacle.

I added the constraints to my controller but the robot goes through the inside of the object. What could I be missing?

Add constraints for collision avoidance

for k in range(N+1):   
    g = ca.vertcat(g , -ca.sqrt((X[1,k]-obs_x)**2+(X[2,k]-obs_y)**2) + (rob_diam/2 + obs_diam/2))

lbg = ca.DM.zeros((n_states*(N+1) + N+1, 1))
ubg = ca.DM.zeros((n_states*(N+1) + N+1, 1))

lbg[0: n_states*(N)] = 0
ubg[0: n_states*(N)] = 0
lbg[n_states*(N+1): n_states*(N+1) + N+1] = -ca.inf
ubg[n_states*(N+1): n_states*(N+1) + N+1] = 0

Thanks for help

OWombat commented 2 years ago

Hi @RodrigoCodeBernardo,

Were you able to find a solution to this?